Suppose you evaluate M hyperparameter settings using a single 5-fold cross-validation loop and report the minimum CV error min⁡merr^m 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 Kout-outer, Kin-inner nested CV over G hyperparameter candidates require for Kout=5, Kin=4 and G=10 (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 err^m is unbiased on its own, E[min⁡merr^m]≤min⁡mE[err^m] by Jensen's inequality; nested CV separates hyperparameter selection (inner loop) from performance evaluation (outer loop).

Steps

  1. Prove the optimistic bias: let err^m be the CV error estimate for setting m∈{1,…,M}. Because min⁡(⋅) is concave, Jensen's inequality gives E ⁣[min⁡1≤m≤Merr^m]≤min⁡1≤m≤ME[err^m]. 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 M is large).
  2. Explain nested CV: split the data into Kout outer folds. For each outer fold j: (1) hold out fold j purely for outer evaluation; (2) run an inner Kin-fold CV across all G hyperparameters on the remaining Kout−1 folds to pick the winning hyperparameter setting hj∗; (3) refit a model with hj∗ on all outer training folds and score it on outer fold j. Average the Kout outer scores to estimate the generalisation error of the *entire tuning procedure*.
  3. Count the model fits: each outer fold runs KinG inner fits plus 1 refit of the outer winner, and at the very end you tune or pick a single hyperparameter configuration on the full dataset and fit 1 final deployment model (or KinG+1 more if re-tuning on all data). Excluding the final deployment tuning, the nested evaluation loop itself runs Kout(KinG+1)=5×(4×10+1)=205 fits; adding a final full-data inner CV and final fit (4×10+1=41) brings the complete workflow to 246 fits.

Common mistakes

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 M=100 candidate models (with 0–1 loss) on a validation set of size nval. Using Hoeffding's inequality and the union bound, how large must nval be so that simultaneously all M validation errors are within ϵ=0.05 of their true errors with probability at least 95%, why do large datasets not need 20\% validation splits, and should you retrain on train+validation before testing?