Repaso
Español
ML fundamentalsAdvancedML-37

When and why do you use nested cross-validation?

Answer

  • Problem: if you choose hyperparameters with cross-validation and then report that same score, the number is optimistic, because the best result was picked.
  • Outer loop: splits the data into k folds to estimate performance on unseen data.
  • Inner loop: inside each outer training part, runs a separate cross-validation (for example a grid search) to choose the hyperparameters.
  • Report the average of the outer test scores: it estimates the whole procedure "tune and fit", not one fixed model.
  • It costs k times the search. Use it with small datasets or to compare model families fairly; with a lot of data a held-out test set is enough.
  • The final model is then tuned on all the data with one more search.

Key terms

Practice this question in Repaso