Data Science · Chapter 28 of 43
Overfitting & Underfitting
OVERFITTING: model memorises training data but flops on new data. UNDERFITTING: model is too simple to capture the pattern.
Aim for the middle — good generalisation.
Example 1 (python)
# Overfitting: train 99% / test 60%
# Underfitting: train 55% / test 54%Diagnose from the train/test gap.
Example 2 (python)
# Fix overfitting: more data, regularisation, simpler model, CVCommon remedies.
Key points
- Overfit: big train/test gap.
- Underfit: poor on both.
- Regularisation helps overfitting.
- More features can worsen overfitting.
💡 Note: Learning curves (accuracy vs training-set size) are the fastest way to diagnose bias vs variance.
