Cross-Validation
Goal
By the end of this lesson, you can explain k-fold cross-validation, interpret both average performance and fold-to-fold variation, and keep learned preprocessing inside each training fold.
One split can give a lucky or unlucky impression
Suppose a small dataset is divided into training and validation data once.
By chance, the validation set might contain unusually easy examples. Another split might contain several difficult cases.
If you choose a model from only one small split, your decision can depend too strongly on that accident.
Cross-validation repeats the train/validation process across several partitions so you can see whether performance is stable across different held-out subsets.
A fold is one of those subsets. In k-fold cross-validation, the dataset is divided into k folds, and each fold gets one turn as the validation data.
Five-fold cross-validation, step by step
Imagine 10 examples divided into five folds of two examples each.
On the first round:
- train on folds 2–5;
- validate on fold 1.
On the second round:
- train on folds 1, 3, 4, and 5;
- validate on fold 2.
Continue until every fold has served as validation once.
The model is fitted from scratch five times. Cross-validation is not one fitted model being scored five times on different slices.
At the end, you have five validation scores.