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

  1. Say that the test set must estimate performance on data the model has never influenced.
  2. Explain that choosing by test score is a form of fitting, so the reported number is optimistic.
  3. 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 k parts, and each part takes a turn as the validation set.

Common mistakes

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?