Suppose you evaluate hyperparameter settings using a single 5-fold cross-validation loop and report the minimum CV error as your model's expected generalisation error. Why is this estimate optimistically biased, how does nested cross-validation eliminate this selection bias, and how many model fits does a -outer, -inner nested CV over hyperparameter candidates require for , and (including refitting)?
Foundations, Model selection
Level L4 Advanced. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you can prove why choosing the minimum of noisy CV scores creates winner's-curse optimism, design nested CV, and count its compute cost.
Key idea
Even if every model's CV score is unbiased on its own, by Jensen's inequality; nested CV separates hyperparameter selection (inner loop) from performance evaluation (outer loop).
Steps
- Prove the optimistic bias: let be the CV error estimate for setting . Because is concave, Jensen's inequality gives Taking the minimum picks whichever hyperparameter happened to get lucky on that fixed fold partition, so the reported CV error is lower on average than true test error (severe when is large).
- Explain nested CV: split the data into outer folds. For each outer fold : (1) hold out fold purely for outer evaluation; (2) run an inner -fold CV across all hyperparameters on the remaining folds to pick the winning hyperparameter setting ; (3) refit a model with on all outer training folds and score it on outer fold . Average the outer scores to estimate the generalisation error of the *entire tuning procedure*.
- Count the model fits: each outer fold runs inner fits plus refit of the outer winner, and at the very end you tune or pick a single hyperparameter configuration on the full dataset and fit final deployment model (or more if re-tuning on all data). Excluding the final deployment tuning, the nested evaluation loop itself runs fits; adding a final full-data inner CV and final fit () brings the complete workflow to fits.
Common mistakes
- Confusing what nested CV produces: nested CV estimates the generalisation error of the *model-selection pipeline*, not of a single fixed hyperparameter, because each outer fold may choose a different .
- Miscounting the fits as simply by forgetting the outer-fold refits () and the final model fit.
How long your answer should be
Half a page; 5 minutes.
Last checked on 4 December 2026.
Read this
Previous in Foundations: Does Occam's razor claim that nature itself prefers simple laws, or is there a formal statistical reason to prefer simpler hypotheses that fit the training data — and when can counting parameters mislead you?
Next in Foundations: Suppose you use a train/validation/test split to choose among candidate models (with 0–1 loss) on a validation set of size . Using Hoeffding's inequality and the union bound, how large must be so that simultaneously all validation errors are within of their true errors with probability at least , why do large datasets not need 20\% validation splits, and should you retrain on train+validation before testing?