Cross-Validation Visualizer illustration

Cross-Validation Visualizer

How well will a model do on data it has never seen? K-fold cross-validation answers by cutting the training set into k parts, holding out each part once and averaging the k validation errors. The task here is polynomial regression on a noisy sine: pick the degree, the number of points and k (or press leave-one-out to set k = n), optionally shuffling before the split. Press Play and the folds animate: the strip of squares highlights the current validation fold in orange, the model refits on the rest, its curve redraws, and the fold’s MSE drops into a bar row. When all folds finish you get mean ± standard deviation, next to a histogram of 30 single 70/30 splits — showing how much luck-of-the-split variance a lone holdout hides.

Runs 100% in your browser — models are trained and computed locally on your device.

Notes

  • The CV estimate is nearly unbiased for a model trained on (k−1)/k of the data, so with small k it slightly pessimistically rates the final model trained on everything.
  • Leave-one-out is the k = n extreme: almost unbiased, but the n fits are highly correlated, so the estimate itself can be noisy — k = 5 or 10 is the usual compromise.
  • A single train/test split is an estimate built from one sample; repeating the split reveals a spread that is often wider than the gap between competing models.
  • Runs 100% in your browser — models are trained and computed locally on your device.