Cross-validation
Estimating how well a model generalises by training and validating it on several different splits of the data.
In k-fold cross-validation the training data is cut into equal folds (often 5 or 10). The model is trained times, each time leaving one fold out for validation, and the validation scores are averaged. Every example is used for validation exactly once, so the estimate is steadier than a single split.
It is used to compare models and choose hyperparameters (the degree of a polynomial, , the depth of a tree). Use stratified folds for classification, grouped folds when examples share a source (the same patient or user), and time-ordered splits for time series.
See it in action
- Bias, variance and cross-validationWhy models fail to generalise, the error decomposition, and how cross-validation chooses complexity.
- What machine learning is, and the workflowSupervised, unsupervised and reinforcement learning, empirical risk, and why a test set must stay hidden.
- Polynomial regression and model capacityFit curves by expanding features, and learn to pick the complexity that generalises.