devnotes.

Why Split Data?

A machine learning model must be judged on data it has never seen. If you test a model on the same data it learned from, the score only measures memorization, not the ability to generalize to new data. Data splitting divides your dataset into separate parts used for training, tuning and final evaluation.

Overfitting and generalization

  • Overfitting: the model performs very well on training data but poorly on new data because it memorized noise.
  • Underfitting: the model is too simple and performs poorly everywhere.
  • Generalization: performing well on unseen data — this is the real goal.

Only a separate, untouched dataset can reveal whether a model generalizes.

The three sets

SetPurposeTypical share
Training setThe model learns its parameters from it60-80%
Validation setTune hyperparameters, compare models, early stopping10-20%
Test setOne-time, final, unbiased performance estimate10-20%

Common split ratios

Ratio (train/val/test)When to use
80 / 0 / 20Small or medium data, with cross-validation on the training part
70 / 15 / 15The classic balanced choice
60 / 20 / 20When lots of tuning is needed
98 / 1 / 1Very large datasets (millions of rows)

The test set is like a final exam. If you keep peeking at it while building the model, it stops being an honest exam.

Golden rules

  1. Keep the test set locked away until the very end.
  2. Never tune hyperparameters on the test set.
  3. Every preprocessing step that learns from data is fitted on the training set only.
Why Split Data? - Splitting Data | Data Preparation | DevNotes