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% test

Compare train vs test scores.

Example 2 (python)
# Fix overfitting: more data, regularization, simpler model, cross-validation

Common 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.

📝 Quick Quiz

1. Overfitting means the model:

2. Underfitting means the model:

3. A fix for overfitting is: