Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
📘 Lesson  ·  Lesson 57

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.

💡 Underfit = too simple, misses patterns. Overfit = too complex, memorises noise. Good fit = just right.

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

PointUnderfittingOverfitting
ModelToo simpleToo complex
Training accuracyLowHigh
Test accuracyLowLow
FixAdd complexitySimplify / 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.

Frequently Asked Questions

What is overfitting in machine learning?
Overfitting is when a model learns the training data too well — including its noise and quirks — so it performs great on training data but poorly on new, unseen data. It has memorised instead of learning general patterns.
What is underfitting?
Underfitting is when a model is too simple to capture the patterns in the data, so it performs poorly on both training and new data. It has not learned enough.
How do I know if my model is overfitting?
Compare training and test accuracy. If training accuracy is high but test accuracy is much lower, the model is overfitting — it does well on what it has seen but fails on new data.
How do I fix overfitting?
Use more training data, simplify the model, apply regularisation, use dropout (for neural networks), or stop training earlier. These stop the model from memorising noise.
How do I fix underfitting?
Make the model more complex, add more useful features, train longer, or reduce regularisation. Underfitting means the model needs more capacity to learn the patterns.
← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

Next topicActivation Functions Your progress: 57 / 66 (86%) · Lesson 58 / 66 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free