Skip to content
Lambdian

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 kk equal folds (often 5 or 10). The model is trained kk times, each time leaving one fold out for validation, and the kk 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, λ\lambda, 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