Practice is not the exam

A model should be evaluated on data it did not use to fit its parameters.

The idea

Practice questions teach you; unseen questions tell you whether you actually learned instead of memorized.

Training data is used to fit the model. Held-out test data estimates how the fitted model behaves on unseen samples. Leakage makes that estimate unreliable.

How it works

  1. Partition data using a strategy that matches how the system will encounter future examples.
  2. Fit preprocessing only on training data, then apply the fitted transformations to validation/test data.
  3. Use validation or cross-validation for model and hyperparameter selection.
  4. Evaluate once on a protected test set after the development decisions are fixed.

Generalization gap

A positive and growing gap can be a warning sign of overfitting. The absolute values still depend on the task, metric, sample size, and whether the splits represent the same deployment distribution.

gap = L_validation − L_train

Check your understanding

Why keep a test set separate during fitting?

Answer and explanation

A held-out test set gives evidence about generalization because those samples were not used to fit the parameters.

A common misconception

A test set is not automatically trustworthy just because it is named ‘test’. It must be protected from the decisions you make during development.

Open Cross-Validation lab

ML Basics

Learn the learning loop before diving into individual models: data, splits, regression, and probabilities.

  1. Clues in, answer out
  2. Practice is not the exam
  3. Fit a straight-line rule
  4. Turn a score into a probability