Machine Learning · Chapter 5 of 40
Overfitting & Underfitting
OVERFITTING: model memorises training data but fails on new data. UNDERFITTING: model is too simple to capture the pattern.
The goal is generalisation — good performance on unseen data.
Example 1 (python)
# Overfitting: 100% train, 60% test
# Underfitting: 55% train, 54% testCompare train vs test scores.
Example 2 (python)
# Fix overfitting: more data, regularization, simpler model, cross-validationCommon remedies.
Key points
- Overfit = great train, poor test.
- Underfit = poor everywhere.
- Balance model complexity.
- Cross-validation helps detect it.
💡 Note: A wide gap between training and validation accuracy is the tell-tale sign of overfitting.
