MODEL EVALUATION · 8 MIN
Overfitting & Train/Test Split
A model that memorises training data but fails on new data is overfitting.
PIXEL explains
- Hold out a test set the model never sees during training.
- Training accuracy ≫ test accuracy is the classic sign of overfitting.
- Fixes: more data, simpler model, regularisation, early stopping, cross-validation.
Real world: Memorising last year's exam answers instead of understanding the subject.
Code
import random
data = list(range(100)); random.seed(1); random.shuffle(data)
train, test = data[:80], data[80:]
print(len(train), len(test))Output ›
80 20Try it in the online compiler →Checkpoint quiz
Train 99%, test 61% suggests…