The Optimistic Scientist: Why Cross-Validation Beats Training Error, and When It Fails
You fit a model with parameters to training points using ordinary least squares. The training MSE is:
and the true (expected) test MSE on a fresh draw is .
(a) Show that , i.e., training error is systematically optimistic. Give a clean formula for the gap.
(b) Now suppose (you fit as many parameters as data points). What happens to ? What does this mean for using training error as a model selection criterion?
(c) Leave-one-out cross-validation (LOO-CV) is proposed as a fix. For linear smoothers (where is the hat matrix), LOO-CV has a remarkable shortcut formula:
Explain intuitively why the factor appears in the denominator. What does measure, and why does a large make the correction large?
Answer: Optimism of Training Error and the LOO Shortcut
Key Idea / Intuition
Training error is optimistic because the model was tuned on the training data โ it gets to "see the answers" before being tested. The gap between training and test error is precisely the in-sample optimism, which grows with model complexity (degrees of freedom used). When , OLS interpolates perfectly and training error collapses to zero โ a complete breakdown of it as a quality measure. LOO-CV corrects for this by simulating a held-out test, and the hat-matrix shortcut works because removing one point and refitting is equivalent (for linear smoothers) to rescaling the residual by how much that point influenced its own fitted value.
Formal Proof / Solution
Part (a): Training error is optimistically biased
For a linear model with parameters fit by OLS, the fitted values are where has trace .
The optimism of training error is defined as:
A classical result (ESL ยง7.4) gives:
For OLS with noise variance :
so:
Therefore:
The gap grows with (complexity) and shrinks with (more data). This is exactly the correction used by Mallows' and AIC.
Part (b): Interpolation when
When and is invertible, OLS fits the data exactly:
Meanwhile, the true test error is:
(or more precisely, grows with the noise level). Training error is maximally misleading: it says the model is perfect, while the actual generalization error can be arbitrarily bad. This makes training error useless for model selection in overparameterized regimes โ exactly the regime of modern neural networks.
Part (c): The LOO shortcut and the meaning of
What is ? The diagonal entry measures the leverage of point โ how much point influences its own fitted value. High leverage means: "if I move , my prediction moves a lot."
The LOO shortcut. When you remove point and refit, the new prediction at is:
More precisely, the Sherman-Morrison-Woodbury identity gives:
Intuition for the correction: The residual when point is included is artificially small โ the model pulled toward by a fraction . Dividing by inflates the residual back to what it would have been if point hadn't been used in fitting.
- If : point has little influence; residual is already honest.
- If : the model fits point almost perfectly regardless of ; the correction is huge, reflecting that would be very different from .
This is why the LOO-CV formula:
is computable from a single fit โ no refitting required. It is one of the most elegant computational shortcuts in statistics.
Source: The Elements of Statistical Learning, Chapter 7 (Hastie, Tibshirani, Friedman)