Three sets, three jobs
The topic Data, features and leakage removed the leaks: no feature carries the answer, and every fitted step of the pipeline, from scaling to target encoding, sees only training rows. A clean split is necessary. It is not yet a measurement of the risk.
Three things can still go wrong. A validation score is an average over finitely many examples, so it is a random number with a spread. The model we report is usually the best of many tried on the same examples, so its score is biased upward. And the split must imitate how the model will be used, or the score answers a different question. This topic builds a protocol that handles all three.
Some notation first. The data hold labelled pairs. A model trained on a set is . Its average loss on a disjoint set is
The topic What machine learning is showed the training error falling to zero while the risk exploded. So the standard protocol splits the data into three disjoint parts:
- the training set fits the parameters of the model;
- the validation set makes the choices that training does not make: hyperparameters, features, the model family, when to stop;
- the test set is touched once, at the end, to report the risk of the final choice.
Why three and not two? Every decision made by looking at a set uses up some of its honesty. Compare twenty values of a hyperparameter on the validation set, and the winner's score includes the luck of that comparison. Only a set that played no part in any decision still gives an unbiased estimate.
A test score on independent examples is an average of losses, so its error bar is the one from Confidence intervals and the bootstrap: for an accuracy the standard error is . A churn model with accuracy on 500 test customers is at at the 95% level. Two models that differ by on this test set cannot be told apart by separate intervals. The paired bootstrap from the same topic compares them on the same examples and is much sharper.