Back to ML Foundations: The Mental Model

Cross-Validation — When Data is Scarce

Make every row count. K-fold and its variants for robust evaluation. FIND_VIDEO: search 'cross validation k-fold stratified' — recommended channel: StatQuest. Aim for 10 min or under.

6 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Introduction & GoalThe lesson introduces the goal of using patient variables to predict heart disease using machine learning.
  2. Comparing MethodsCross-validation is introduced as the tool necessary to compare different machine learning methods like Logistic Regression or SVM.
  3. Training vs. TestingData must be split to both train (estimate parameters) and test (evaluate performance) the algorithm.
  4. Bad ApproachesReusing all data or using a fixed, arbitrary split (e.g., 75/25) are shown to be flawed methods for evaluation.
  5. K-Fold MechanismCross-validation solves the splitting problem by systematically rotating which block of data is used for testing.
  6. Summarizing ResultsAfter all blocks have been tested, the overall performance is summarized to select the best performing method.
  7. Types of CVThe number of blocks (K) is arbitrary, leading to K-fold CV (e.g., 10-fold) and Leave-One-Out CV.
  8. Tuning ParametersCross-validation can also be used to optimize the value of a tuning parameter that is not estimated by the data.
PDF notes

Frequently asked questions

Why is reusing training data for testing a bad idea?

The algorithm will appear overly accurate because it has memorized the training data. This method fails to generalize to new, unseen data.

What is the difference between 4-fold and 10-fold cross-validation?

4-fold divides the data into four blocks, testing on 25% at a time. 10-fold divides it into ten blocks, testing on 10% at a time.

How do I decide which machine learning method to use?

Use cross-validation to compare the performance (e.g., accuracy) of different methods on the test blocks. Select the method with the best summarized performance.

Is Leave-One-Out CV always better since it tests every sample individually?

LOOCV is computationally expensive and often yields results with high variance. 10-fold CV is generally preferred in practice.