beginnermachine-learning

Underfitting vs Overfitting

Too simple and you miss the pattern. Too complex and you memorize the noise. Goldilocks is in the middle.

Key Points

What it is

Underfitting happens when your model is too simple to capture the real pattern in the data. It makes large errors on both training data and new data. Overfitting happens when your model is too complex and learns not just the pattern but also the random noise in the training data. It performs great on training data but fails on new data. The sweet spot is a model that is just complex enough to capture the real pattern but not so complex that it memorizes random quirks.

Why it exists

Every dataset has a real signal (the true relationship) and random noise (measurement errors, one-off flukes). A good model learns the signal and ignores the noise. An underfit model does not even learn the signal. An overfit model learns the signal plus the noise, so it fails when the noise changes. This tradeoff exists because we never have perfect data. We have to decide how much complexity is appropriate.

What it measures

We measure underfitting by looking at training error – if it is high, the model is too simple. We measure overfitting by looking at the gap between training error and test error. If the test error is much higher than training error, the model is overfitting. The ideal is training error low enough and test error close to training error.

Intuition

Imagine you are learning to predict a friend's mood. You have 5 days of data. Underfitting: you always predict 'neutral'. You ignore all the details. You are wrong a lot. Overfitting: you notice that on Tuesday when they wore a red shirt and it was raining, they were grumpy. But that happened only once by chance. Next Tuesday, you predict grumpy but they are happy. You memorized a coincidence. Good fit: you notice they are grumpy when tired, happy when well-rested. That pattern holds on new days.

When to use

When not to use

Common mistakes

In practice

Every time you train a model, you check for overfitting. It is the most common problem in machine learning. Standard workflow: split data into train, validation, test. Train on train, evaluate on validation to tune hyperparameters. Finally evaluate once on test. If train accuracy is 99% and validation is 70%, you are overfitting. Add regularization or reduce model complexity. If train accuracy is 60% and validation is 58%, you are underfitting. Use a more complex model.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

bias-variance-tradeoffcross-validationregularization
Chirp at me!