Overfitting and Underfitting: 6 Proven Fixes That Work

⚡ TL;DR: Overfitting and underfitting are opposite failures. Underfitting means high error on training and test data — the model is too simple. Overfitting means low training error but high test error — it memorised the noise. Diagnose from the gap between the two scores.

Overfitting and underfitting are the two ways a model fails. Almost every practical decision in machine learning — how complex a model to use, how much data to gather, when to stop training — is really a decision about where to sit between them.

Overfitting and underfitting, in one picture

Picture fitting a line through scattered points on a graph. There are three outcomes:

Overfitting and underfitting compared across three panels: a too-simple straight line, a good fit following the trend, and a curve chasing every noisy point
Overfitting and underfitting are opposite failures. The middle panel is the target: follow the trend, ignore the jitter.

Underfitting is the straight line through data that clearly curves. The model is too simple to capture what is there. It performs badly on training data and badly on new data — which at least has the virtue of being obvious.

Overfitting is the wiggling curve that passes through every single point, including the ones that are just noise. On training data it looks flawless. On new data it is worse than the straight line, because it committed to accidents of the sample rather than the underlying pattern.

Diagnosing overfitting and underfitting from two numbers

You do not need to plot anything. Compare performance on your training set against your held-out test set:

Training errorTest errorDiagnosis
HighHighUnderfitting. The model cannot even fit what it has seen.
LowHighOverfitting. Learned the sample, not the pattern.
LowLowA good fit. This is the target.

The gap between the two is what separates overfitting and underfitting. A model at 99% on training and 71% on test is overfitting badly. One at 86% and 84% is healthy — a small gap is normal and not worth chasing.

Why overfitting and underfitting happen

🧪 Signal and noise

Real data contains two things: signal, the genuine relationship you want, and noise, random variation specific to the rows you happened to collect — a house sold cheap because the seller was in a hurry, a reading taken on a bad day.

A flexible model cannot tell them apart. Given the freedom, it will contort itself to accommodate that hurried seller, because doing so lowers training error. But that discount will not recur, so the contortion actively hurts on new data.

Underfitting has the opposite cause: too little capacity, or features that simply do not carry the answer. Overfitting becomes more likely when the model has many parameters relative to the data, when you have few rows, when features are noisy or irrelevant, or when you simply train for too long.

The bias–variance tradeoff behind it

This is the formal framing, and the terms appear everywhere.

High bias
Wrong assumptions, too rigid → underfitting. Retrain on five samples and you get five near-identical models, all wrong the same way.
High variance
Too sensitive to the sample → overfitting. Retrain on five samples and you get five wildly different models.

Traditionally these trade off: reducing one raises the other, and total error is lowest somewhere in the middle rather than at either extreme. In very large modern neural networks the picture is more complicated — see the work on double descent — but the intuition remains the right starting point.

Six proven fixes for overfitting

✅ Start with more data. It is the most reliable fix by a distance — noise averages out as the sample grows, and a fixed number of parameters cannot memorise an ever-larger dataset. It is also usually the most expensive, which is why the other five exist.
  1. Get more data. As above.
  2. Simplify the model. Fewer parameters, fewer layers, a shallower tree — less capacity to memorise.
  3. Regularisation. Add a penalty to the loss function proportional to parameter size, so the model is charged for complexity. L2 shrinks weights smoothly; L1 drives some to exactly zero, doubling as feature selection. That difference is really the difference between L1 and L2 norms.
  4. Early stopping. Watch validation performance during training. Training error falls continuously, but validation error falls then rises — that turning point is where memorisation begins.
  5. Drop useless features. Every irrelevant column is another opportunity to find a coincidence.
  6. Dropout, in neural networks: randomly switch off a fraction of neurons each pass, so the network cannot lean on any single one.

Fixing underfitting: the opposite moves

The opposite moves, and underfitting is generally the easier problem to solve:

  • Use a more capable model — more parameters, more layers, a higher-degree polynomial.
  • Add or improve features. Often the model is fine and the inputs simply do not contain the answer. No algorithm can predict house prices from the front door colour.
  • Reduce regularisation if you have over-applied it.
  • Train longer. Sometimes it has just not converged yet.

A practical order of work

⚠️ Do not reach straight for a bigger model

  1. Check your split is sound and nothing leaked. A surprising share of “overfitting” is really a bug.
  2. Get training error down first. If the model cannot fit what it has seen, that is underfitting and it is your only problem.
  3. Only then look at the gap to test error. That gap is the overfitting.
  4. Change one thing at a time, judged on validation data — never the test set.

🔑 Key Takeaways

  • Overfitting and underfitting are opposite failures — diagnose them from the gap between training and test error.
  • High error on both means underfitting; low training error with high test error means overfitting.
  • Bias is rigidity, variance is sensitivity to the sample. Total error is lowest between the extremes.
  • More data is the most reliable fix for overfitting; regularisation and early stopping are the cheap ones.
  • Fix underfitting first — overfitting and underfitting are solved in that order.

Further reading

Google’s Machine Learning Crash Course on generalisation covers the same ground with interactive examples, and scikit-learn’s underfitting vs overfitting example reproduces the three-panel figure above in runnable code.

Where to go next

Scroll to Top