How does k-fold cross-validation work?
Show the answer and explanation
Correct answer: D, The data is split into k folds; each fold is the validation set once while the other k − 1 folds train the model.
Explanation Cross-Validation
In k-fold cross-validation the rows are split into k folds of (nearly) equal size. Then k models are trained: in round i, fold i is held out for validation and the remaining k − 1 folds form the training set. The k validation scores are averaged (and their spread is reported). Every row is used for validation exactly once and for training k − 1 times.
Why the other descriptions are wrong:
- Training on one fold and validating on the rest reverses the roles; each model would see only 1/k of the data.
- Bootstrap samples with out-of-sample scoring is the bootstrap (out-of-bag) estimate, a different resampling method.
- A single split scored once is a holdout split, not k-fold; only one model and one score are produced.
| k | training share per fold | models fitted |
|---|---|---|
| 5 | 80% | 5 |
| 10 | 90% | 10 |
Interview tip: mention shuffling the rows before splitting when the data is ordered, except for time series, where order must be preserved.