Answer: Optimism of Training Error
Key Idea / Intuition
Training error is optimistic โ it underestimates true prediction error โ because the model was fit to the same data it is evaluated on. The key insight is that the bias comes entirely from the covariance between predictions y^โiโ and the training responses yiโ: when your model has "seen" yiโ, it adjusts y^โiโ toward it, making the training loss look artificially small. The optimism measures exactly how much the model overfits, in units of covariance.
Formal Proof / Solution
Setup. Assume an additive noise model:
yiโ=f(xiโ)+ฮตiโ,ฮตiโโผ(0,ฯฮต2โ)
and Yi0โ=f(xiโ)+ฮตi0โ is an independent fresh observation at xiโ (same distribution as yiโ, but independent of the training set).
Step 1: Expand Errinโ.
E[Errinโ]=N1โโi=1NโE[(Yi0โโy^โiโ)2]
Since Yi0โโฅy^โiโ (fresh response, independent of training):
E[(Yi0โโy^โiโ)2]=E[(Yi0โโf(xiโ))2]+E[(f(xiโ)โy^โiโ)2]
=ฯฮต2โ+E[(f(xiโ)โy^โiโ)2]
Step 2: Expand err.
E[err]=N1โโi=1NโE[(yiโโy^โiโ)2]
Write yiโ=f(xiโ)+ฮตiโ and add/subtract f(xiโ):
yiโโy^โiโ=ฮตiโโ(y^โiโโf(xiโ))
So:
E[(yiโโy^โiโ)2]=E[ฮตi2โ]โ2E[ฮตiโ(y^โiโโf(xiโ))]+E[(y^โiโโf(xiโ))2]
=ฯฮต2โโ2E[ฮตiโ(y^โiโโf(xiโ))]+E[(y^โiโโf(xiโ))2]
Step 3: Compute the optimism.
E[Errinโโerr]=N1โโi=1Nโ(2E[ฮตiโ(y^โiโโf(xiโ))])
=N2โโi=1NโE[ฮตiโy^โiโ]โE[ฮตiโf(xiโ)]
Since f(xiโ) is deterministic and E[ฮตiโ]=0:
E[ฮตiโf(xiโ)]=f(xiโ)E[ฮตiโ]=0
So:
E[Errinโโerr]=N2โโi=1NโE[ฮตiโy^โiโ]
Step 4: Recognize the covariance.
Cov(y^โiโ,yiโ)=Cov(y^โiโ,f(xiโ)+ฮตiโ)=Cov(y^โiโ,ฮตiโ)=E[y^โiโฮตiโ]โE[y^โiโ]E[ฮตiโ]
Since E[ฮตiโ]=0:
Cov(y^โiโ,yiโ)=E[y^โiโฮตiโ]
Therefore:
E[Errinโโerr]=N2โi=1โNโCov(y^โiโ,yiโ)โ
Conceptual meaning.
- For a linear smoother y^โ=Sy, we get โiโCov(y^โiโ,yiโ)=trace(S)ฯฮต2โ, which is why trace(S) counts the effective degrees of freedom.
- For OLS with p parameters, trace(S)=p, so optimism =N2pฯ2โ, exactly the penalty in Mallows' Cpโ.
- The more the model adapts to training noise (high covariance), the more optimistic the training error is, and the larger the gap to test error.
Source: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, 2nd ed., Section 7.4โ7.5