Why does reporting the best validation score from -fold hyperparameter tuning give an optimistically biased error estimate, how does nested cross-validation fix this, and how many total model fits are required for 5 outer folds, 4 inner folds and 6 hyperparameter candidates?
ML systems and evaluation, Cross-validation
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you understand model-selection optimism ("winner’s curse") and can trace and cost a nested CV loop.
Key idea
Selecting the best hyperparameter setting by its -fold score picks whichever candidate got luckiest on those folds; nested CV isolates an untouched outer test fold to evaluate the entire tuning procedure, requiring model fits for outer folds, inner folds and hyperparameter candidates.
Steps
- Explain selection bias: evaluating candidates on the same folds and reporting has positive bias (the winner’s curse), because random fold noise helps whichever candidate overfits the validation folds.
- Describe the outer and inner loops: split data into outer folds; inside each outer training split ( of the data), run -fold inner CV across all candidates to pick the best setting, refit that winner on the outer training split, and score it on the unseen outer fold.
- Count the fits: each outer fold runs inner fits plus outer refit fits, so 5 outer folds require model fits.
- Note final deployment: nested CV produces an unbiased estimate of the tuning pipeline’s generalisation performance, not a single deployable model—to ship one model, run one final 5-fold CV on all data ( more fits) to pick the final model.
Common mistakes
- Forgetting the outer refit ( per outer fold) or thinking nested CV outputs a single set of hyperparameters instead of an unbiased performance estimate.
- Computing and missing that the outer loop still needs a refit on the full outer training split to evaluate on the outer test fold.
How long your answer should be
4–5 sentences plus the fit arithmetic; 3–4 minutes.
Last checked on 4 December 2026.
Read this
Previous in ML systems and evaluation: A student standardises features and applies PCA on the full dataset before running 5-fold cross-validation, obtaining 92% accuracy, whereas fitting both inside each fold yields 81%. Why does the first setup leak information, how does a pipeline fix it, and why is supervised feature selection before CV even more damaging?
Next in ML systems and evaluation: On four binary outcomes , Forecaster A predicts and Forecaster B predicts . What are their Brier scores, and how do you prove that the Brier score is a strictly proper scoring rule?