Skip to content
Lambdian

Train–test split

Holding back part of the data so the model can be judged on examples it never saw.

Before building a model, set aside a test set (often 20%) and do not look at it until the very end. Use the remaining training data to fit models and a validation split (or cross-validation) to choose between them.

Any preprocessing, such as scaling or feature selection, must be fitted on the training split only; otherwise information from the test set leaks into training and the final score is too optimistic.

See it in action