Why must you never tune hyperparameters on the test set?
Foundations, Model selection
Level L1 Beginner. Length One-liner. Nature Th Theoretical.
What's being asked
Whether you know that the test set exists to give an unbiased estimate of performance on new data.
Key idea
Hyperparameters are settings you choose rather than learn, such as the regularisation strength. Every decision made by looking at the test set fits the model to that set, so the test score becomes optimistically biased. Tune on a validation set or with cross-validation, and use the test set only once.
Steps
- Say that the test set must estimate performance on data the model has never influenced.
- Explain that choosing by test score is a form of fitting, so the reported number is optimistic.
- Give the fix: train / validation / test splits, or k-fold cross-validation for tuning plus a held-out test set. In k-fold cross-validation, the training data is split into parts, and each part takes a turn as the validation set.
Common mistakes
- Saying it “overfits the model”. The model may be fine; it is the estimate of its performance that is biased.
- Forgetting that repeatedly peeking at test results leaks information, even without explicit tuning.
How long your answer should be
One sentence; two if asked why.
Last checked on 4 December 2026.
Read this
Previous in Foundations: What is the bias–variance tradeoff?
Next in Foundations: What is empirical risk minimisation?