Cross-Validation
The Problem with One Split
Unstable estimates
A single train/test split gives an unreliable estimate — the result depends on which data lands where.
Step 1 of 6: The Problem with One Split
Unstable estimates
A single train/test split gives an unreliable estimate — the result depends on which data lands where.
Step 2 of 6: K-Fold Cross-Validation
Every point gets validated
K-fold ensures every data point is used for both training and validation exactly once.
Step 3 of 6: Walking Through Folds
Rotate the validation set
Each fold takes a turn as the validation set — we average all fold scores for a stable estimate.
Step 4 of 6: Stratified K-Fold
Preserving class balance
Stratified folds maintain the same class ratio in every fold — critical for imbalanced datasets.
Step 5 of 6: Leave-One-Out
The extreme case
LOO uses N folds — low bias but high variance and expensive for large datasets.
Step 6 of 6: Choosing k
Bias-variance of the estimator
Standard compromise — k=5 or k=10 balances bias, variance, and compute.