Cross-Validation interview question

Machine LearningCross-Validationbasic

How does k-fold cross-validation work?

  1. AEach of the k folds trains the model once while the other k − 1 folds validate it, and the k scores are averaged.
  2. Bk bootstrap samples are drawn with replacement, and each model is scored on the rows left out of its own sample.
  3. CThe data is split once into k parts, the model trains on the first k − 1 parts and is scored once on the last part.
  4. DThe data is split into k folds; each fold is the validation set once while the other k − 1 folds train the model.
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.
ktraining share per foldmodels fitted
580%5
1090%10

Interview tip: mention shuffling the rows before splitting when the data is ordered, except for time series, where order must be preserved.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Machine Learning questions

  1. How does grid search look for good hyperparameters?
  2. What is the difference between batch gradient descent and stochastic gradient descent (SGD)?
  3. In reinforcement learning vocabulary, what is the reward?
  4. Both series below rise at a similar average rate. Series A was generated as a linear trend plus stationary noise; Series B is a random walk with drift. Which…
  5. A churn model produced this confusion matrix on 10,000 customers, and a manager celebrates its 98.8% accuracy. What is the model's balanced accuracy, and what…