100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Machine Learning with Scikit-learn
30 minintermediate

Cross-Validation — k-Fold and Stratified

Cross-validation is the statistical technique that produces a reliable estimate of a model's generalisation performance by training and evaluating it multiple times on different subsets of the data, averaging the results to reduce the variance of the estimate. It exists because a single train-test split produces a noisy estimate: the performance depends heavily on which records happen to fall in the test set, and an unlucky split can make a good model look bad or a bad model look good. Cross-validation mitigates this by rotating the test set across the entire dataset, so every record is used for evaluation exactly once, and the average is a much more stable estimate of true generalisation. Mastering cross-validation — when to use it, which variant to choose, and how to avoid contaminating it — is what separates a data scientist who produces trustworthy model comparisons from one whose results are dominated by split noise.

Analogy🏏Cricket
🏏 Think of it like cricket: A batting coach who teaches only one shot — the forward defensive — gives advice with high bias: it is consistently wrong for deliveries that demand a drive or a pull, regardless of how much practice the batsman does. A coach who memorises every ball of the batsman's training career gives advice with high variance: he predicts each training ball perfectly but fails completely on new balls from a different bowler, because he learned the noise of that specific bowler rather than the underlying principles. The great coach finds the balance — teaching the core principles that generalise, without over-specifying for the particular training environment. Just as great coaching lies between the extremes, great ML models balance bias and variance.
Lesson 4 of 35
0% complete