What is overfitting in machine learning?
Overfitting is when a model fits its training data so closely, noise included, that it performs worse on new data. Its opposite, underfitting, is when a model is too simple to capture the real pattern and does poorly on both training and new data. The goal of training is a model that generalizes: low error on examples it has never seen.
Every supervised model faces this tradeoff, from linear regression to large neural networks. Practitioners detect it by holding out a validation set and comparing training and validation error. The fixes include more data, regularization such as weight decay and dropout, early stopping, data augmentation, and choosing a model of the right size.
Key ideas
- Underfitting means high error on both training and test data.
- Overfitting means low training error but much higher test error.
- A model with as many parameters as data points can fit the training set exactly.
- Expected test error splits into bias², variance, and irreducible noise.
- Model settings should be chosen with validation data, never with the test set.
- More data, regularization, and early stopping are the standard remedies for overfitting.
Short takes on this topic
Common questions
How do I know if my model is overfitting?
Compare training and validation performance. If training error keeps falling while validation error flattens or rises, the model is overfitting. A large and growing gap between the two curves is the clearest sign.
Is some overfitting acceptable?
Yes. Training error is almost always lower than validation error, and a small gap is normal. What matters is validation performance. A model with a larger gap but lower validation error is still the better model.
Can deep neural networks overfit?
They can, and with enough parameters they can memorize any training set. In practice, large networks trained with weight decay, data augmentation, and early stopping often generalize well despite having far more parameters than examples, which classical theory did not predict.
Does more data always reduce overfitting?
More data from the same distribution reduces variance, so it usually shrinks the gap between training and validation error. It does not fix underfitting, and it does not help if the new data is noisy, mislabeled, or drawn from a different distribution than the test data.
Related explainers
- Bias-Variance Tradeoff — Why models underfit or overfit — the fundamental decomposition
- Regularization — Dropout, L1, and L2 — keeping models honest
- Train, Validation & Test Sets — Splitting data to measure generalization and avoid overfitting
- Learning Curves — Diagnosing underfitting and overfitting from training size
- Cross-Validation — K-fold, stratified, and leave-one-out evaluation
- Model Evaluation & Metrics — Precision, recall, F1, ROC curves, and regression metrics
References
- James, Witten, Hastie & Tibshirani, "An Introduction to Statistical Learning", chapter 2
- Goodfellow, Bengio & Courville (2016), "Deep Learning", section 5.2: Capacity, Overfitting and Underfitting
- Zhang et al. (2016), "Understanding deep learning requires rethinking generalization"
- Belkin et al. (2019), "Reconciling modern machine learning practice and the bias-variance trade-off"
Last updated