14/20
K-Fold Cross Validation Β· Page 1 of 1

Don't Trust a Single Split

K-Fold Cross Validation

The Flaw of Train/Test Split

What if your single random split accidentally put all the easy examples in the test set? Your accuracy would be artificially high.

K-Fold to the Rescue

Instead of one split, we chop the data into K equal pieces (folds) (usually K=5 or K=10).

  • Iteration 1: Train on Folds 2-5, Test on Fold 1.
  • Iteration 2: Train on Folds 1,3,4,5, Test on Fold 2.
  • ...Repeat for all K folds.
  • Final Score: Average the scores from all K tests.

Why this is the Gold Standard

It ensures every single data point gets to be in a test set exactly once, giving you a highly reliable estimate of how your model behaves in the real world.

main.py
Loading...
OUTPUT
β–ΆClick "Run Code" to execute…