Why training performance is not enough
A model is selected to fit the training data, so evaluating it on the same observations usually gives an optimistic picture of how it will perform on new cases. Flexible models can learn noise as well as signal.
The purpose of held-out evaluation is to approximate performance on future data generated from a similar process.
What a train/test split does
A simple split reserves one part of the data for model development and another for evaluation. The test set should not be repeatedly inspected during tuning, because each decision based on test performance leaks information back into the modelling process.
With limited data, one split can also be unstable because results depend on which observations happen to fall into each set.
How cross-validation helps
In k-fold cross-validation, the training portion is divided into k folds. The model is trained on k−1 folds and evaluated on the remaining fold, repeating until every fold has served as validation data.
Averaging performance across folds uses the available data more efficiently for model comparison and tuning. A separate final test set can then provide a less biased final performance estimate.
Avoid leakage
Preprocessing steps that learn from data—such as scaling by sample means, imputation, feature selection or target encoding—should be fitted inside each training fold rather than on the full dataset before cross-validation.
Leakage can make validation performance look much better than what a real deployment will achieve.
