Overfitting vs Underfitting
In this lesson: What overfitting and underfitting are, how to spot them and fixes like regularization and more data. In Hindi & English.
The fitting problem
When you train a machine learning model, two things can go wrong: it can learn too little or too much. Learning too little is underfitting; learning too much (including noise) is overfitting. The goal is a good balance — a model that learns the real patterns and works well on new data.
Underfitting
An underfitting model is too simple to capture what is going on in the data.
- Sign: poor accuracy on both training and test data.
- Cause: the model or features are too basic, or training was too short.
- Analogy: a student who barely studied — they do badly on practice and the real exam.
Overfitting
An overfitting model learns the training data too well, including random noise.
- Sign: very high training accuracy but much lower test accuracy.
- Cause: the model is too complex, or there is too little training data.
- Analogy: a student who memorised the practice questions — great on those, lost on new ones.
How to spot them
Compare performance on training data versus new (test) data:
- Both low → underfitting.
- Training high, test low → overfitting.
- Both high and close → a good fit.
This gap between training and test accuracy is the key clue to which problem you have.
How to fix them
Fix underfitting:
- Use a more complex model.
- Add more useful features.
- Train longer; reduce regularisation.
Fix overfitting:
- Get more training data.
- Simplify the model; add regularisation.
- Use dropout (neural nets); stop training earlier.
Comparison
| Point | Underfitting | Overfitting |
|---|---|---|
| Model | Too simple | Too complex |
| Training accuracy | Low | High |
| Test accuracy | Low | Low |
| Fix | Add complexity | Simplify / more data |
Common confusions
- Judging only on training accuracy. Always check test/new data too, or you miss overfitting.
- Thinking more complex is always better. Too complex causes overfitting.
- Adding data to fix underfitting. More data helps overfitting; underfitting needs more model capacity.
- Ignoring the train-test gap. That gap is your main diagnostic tool.
Summary
- Underfitting: model too simple, bad on both training and test data.
- Overfitting: model too complex, great on training but poor on new data.
- Spot them by comparing training vs test accuracy.
- Fix underfitting with more complexity; fix overfitting with more data or simpler models.
- Aim for a good fit that generalises to new data.
Next, understand ML types in supervised, unsupervised and reinforcement, or see a model in spam detection.
