What is k-fold cross-validation, how do the bias and the computation cost of the error estimate change with k, and why are k=5 and k=10 the usual choices?

Foundations, Model selection
Level L2 Elementary. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you understand how k-fold cross-validation works and how k trades training-set size against computation cost.

Key idea

You split n data points into k equal parts (folds), train k times leaving one fold out each time, and average the k validation errors: CVk=1k∑j=1kErrj. Small k trains on much less than n points (pessimistic bias), while very large k (such as leave-one-out, k=n) requires many fits.

Steps

  1. Describe the procedure: shuffle and split the dataset into k equal folds. Train the model on k−1 folds, evaluate its error Errj on the held-out fold j, repeat so each fold is held out once, and average the k scores: CVk=1k∑j=1kErrj.
  2. Explain the bias effect: each model trains on only k−1k of the data — 50% when k=2, 80% when k=5, and 90% when k=10. Because models usually improve with more data, a small k overestimates the error of the final model trained on all n points.
  3. Explain the computation cost: k-fold cross-validation fits the model k times, so k=n (leave-one-out) costs n fits, which is prohibitive for large datasets (aside from special shortcuts like ordinary least squares).
  4. Conclude why k=5 or 10 is standard: each fold trains on 80%–90% of the data (low bias) at a modest cost of 5 or 10 fits, while avoiding k=n where nearly identical training sets share n−2 points and yield redundant, correlated fold errors (analysed formally at later levels).

Common mistakes

How long your answer should be

About 2–3 minutes: explain the procedure, then bias, cost and why k=5 or 10 works well.

Read this

Previous in Foundations: Your model has 2% training error and 25% validation error. What is the problem, and what would you try? What if instead both errors were about 24%?
Next in Foundations: Data are spread uniformly in the unit hypercube [0,1]d. A nearest-neighbour method uses a small cube around each point that contains 1% of the data. What edge length must that cube have for d=1, 10 and 100, and what does this say about local methods in high dimensions?