VIZRA BLOG · Batch 2 · Machine Learning & Advanced AI · ARTICLE 14 OF 20
Overfitting and Underfitting in Machine Learning
Every machine learning system walks a razor's edge between ignoring the pattern and memorizing the noise. Here is how statistical learning theory framed that tension—and how modern deep networks, double descent, and large language models forced researchers to rewrite the rules.
The Illusion of a Perfect Score
A model that achieves zero error on the data it studied can still fail catastrophically on the very first real-world example it encounters. In machine learning, accuracy on past observations is never the ultimate prize; it is only a proxy for generalization —the ability to make reliable predictions on unseen data drawn from the same underlying process. Between the twin hazards of underfitting, where a model is too rigid to capture the true structure of a problem, and overfitting, where a model contorts itself to absorb random noise and dataset quirks, lies the central intellectual problem of statistical learning.
Historical Roots: From Penalized Regression to Statistical Learning Theory
The tension between fitting observed data and predicting future outcomes predates modern computing. Early statisticians recognized that an (n-1)-degree polynomial can pass through any n distinct points in a plane, yielding zero residual error while oscillating wildly between observations. By the second half of the twentieth century, researchers began formalizing how to constrain estimation when predictors were noisy or collinear. In February 1970, Arthur E. Hoerl and Robert W. Kennard introduced ridge regression in *Technometrics*, showing that adding a small positive constant to the diagonal of a regression design matrix deliberately introduces a controlled bias in exchange for a dramatic reduction in parameter variance [4].
The Core Concept: Signal, Noise, and the Generalization Gap
Every supervised learning dataset is a mixture of signal ( the repeatable relationship between inputs x and targets y) and noise ( measurement error, labeling ambiguity, unmeasured variables, or inherent stochasticity). Suppose a true data-generating process takes the form y = f(x) + ϵ, where ϵ is zero-mean random noise with variance σ2. Because a learning algorithm only ever sees a finite training set D = {(x1, y1), …, (xn, yn)}, it must infer an approximation f without knowing which fluctuations in D belong to f(x) and which belong to ϵ.
Technical Foundations of Classical Learning Theory
Every machine learning system walks a razor's edge between ignoring the pattern and memorizing the noise. Here is how statistical learning theory framed that tension—and how modern deep networks, double descent, and large language models forced researchers to rewrite the rules.
Diagnosing Overfitting and Underfitting in Practice
In low-dimensional toy problems, you can visually inspect whether a curve misses the trend or zigzags through noise. In real industrial models with hundreds of tabular features or millions of pixels, visualization is impossible [7]. Practitioners instead rely on systematic resampling and
The Mitigation Toolkit: Regularization, Ensembles, and Normalization
When diagnostics reveal underfitting, the remedies are straightforward: increase model capacity, engineer richer features, relax regularization penalties, or train longer with an appropriate learning rate. When diagnostics reveal overfitting, engineers draw from a mature arsenal of explicit and structural regularizers, each acting on a different lever of the learning pipeline.
The Modern Paradox: Overparameterized Deep Networks
If classical statistical learning theory were the complete story, modern deep learning should not work. Deep convolutional networks and large transformers routinely contain far more tunable parameters than training examples, allowing them to achieve zero training error on complex datasets. According to the textbook corollary of the U-shaped bias–variance curve, any model that interpolates noisy training data—fitting it with zero empirical error—should generalize poorly [20]. Yet in practice, huge interpolating models routinely outperform smaller,
Memorization vs. Generalization in Large Language Models
Large language models (LLMs) occupy a fascinating middle ground between classical and overparameterized regimes. Pretrained for roughly one to a few epochs over trillions of internet tokens, frontier LLMs rarely reach zero training loss in the way a small image classifier does on CIFAR-10. Yet because they possess billions or hundreds of billions of parameters, they exhibit a striking capacity for verbatim memorization alongside remarkable out-of-distribution generalization.
Real-World Failure Case Studies: When Overfitting Leaves the Lab
In academic benchmarks, overfitting costs a few percentage points on a leaderboard. In deployed systems, it misdiagnoses patients, burns capital, and misleads public health agencies. Three well-documented industry and scientific case studies show how subtle—and costly—generalization failures can be.
Advantages, Limitations, and Open Challenges
Understanding overfitting and underfitting at both the classical and modern levels gives engineering teams concrete leverage. In structured tabular domains—credit scoring, churn prediction, industrial sensor forecasting— the classical bias–variance framework remains remarkably predictive: gradient-boosted trees and regularized linear models guided by stratified cross-validation and learning curves still deliver the most reliable performance per unit of compute. In high-dimensional unstructured domains—vision, speech, and natural language— recognizing the overparameterized regime frees teams from artificially bottlenecking network width, allowing them to pair large, expressive architectures with AdamW, data augmentation, and massive curated corpora.
Frequently Asked Questions
Key technical questions answered in Overfitting and Underfitting in Machine Learning:
- What is the quickest way to tell whether a model is underfitting or overfitting?
- Compare training performance against validation performance. If both training and validation errors are high, the model is underfitting (high bias). If training error is very low while validation error is significantly higher, the model is overfitting (high variance).
- Does adding more training data fix both overfitting and underfitting?
- No. Adding more representative training data is one of the most effective ways to reduce overfitting (high variance), because it makes spurious noise harder to memorize. However, if a model is underfitting because it lacks capacity or informative features, adding more of the same data will rarely improve accuracy—the learning curve will simply stay flat.
- Why is AdamW preferred over standard Adam with L2 regularization?
- In standard SGD, L2 regularization and weight decay are mathematically equivalent. In adaptive optimizers like Adam, L2 penalties are scaled by the running gradient variance, which weakens regularization on weights with large gradients. AdamW decouples weight decay from the adaptive gradient update, consistently improving generalization in deep neural networks and transformers.
- Does double descent mean overfitting is no longer a problem in deep learning?
- No. Double descent shows that very large overparameterized models can generalize well past the interpolation threshold under favorable data and optimization conditions, but they can still overfit badly—especially near the interpolation peak, under heavy label noise, or by learning spurious "Clever Hans" shortcuts that fail under distribution shift.
- What is the difference between double descent and grokking?
- Double descent describes how test error rises and then falls again as you increase model capacity (or epochs/data) past the interpolation threshold. Grokking is a specific delayed-generalization phenomenon observed on small algorithmic datasets where a network completely memorizes the training set early (zero training loss, random-chance validation accuracy) and only generalizes abruptly thousands of optimization steps later as weight decay prunes memorizing circuits in favor of compact generalizing circuits.
- How does memorization in large language models relate to overfitting?
- Classic overfitting occurs when a model's average test loss worsens because it fits training noise. Large language models can exhibit strong average generalization (low test perplexity) while simultaneously memorizing specific rare or duplicated training sequences verbatim—creating privacy extraction risks and benchmark contamination even without a traditional spike in validation loss.
- Why can a model score well on a held-out test set and still fail in production?
- If the training and test sets are split from the same source, any hidden confounders—such as hospital-specific X-ray markers, image borders, or seasonal proxies—exist in both splits. The model exploits those shortcuts to achieve high internal test accuracy, then fails when deployed in an external environment where those spurious cues vanish or reverse.
- When should you use k-fold cross-validation instead of a single train–validation split?
- Use stratified k-fold cross-validation (typically 5 or 10 folds) whenever datasets are small to moderate in size, where a single split has high variance. For time-series or multi-record grouped data (such as multiple scans per patient), use chronological splits or group-aware cross-validation so future or patient-specific information never leaks into training folds.
Primary Sources
32 verified primary references cited in this monograph:
- [1] Neural Networks and the Bias/Variance Dilemma — Stuart Geman, Elie Bienenstock, and René Doursat (Neural Computation, Vol. 4, No. 1, pp. 1–58) — January 1992 — Peer-Reviewed Journal Article (https://direct.mit.edu/neco/article/4/1/1/5624/Neural-Networks-and-the-Bias-Variance-Dilemma)
- [2] On the Uniform Convergence of Relative Frequencies of Events to Their Probabilities — Vladimir N. Vapnik and Alexey Ya. Chervonenkis (Theory of Probability and Its Applications, Vol. 16, No. 2, pp. 264–280) — 1971 — Peer-Reviewed Journal Article (https://epubs.siam.org/doi/10.1137/1116025)
- [3] Rademacher and Gaussian Complexities: Risk Bounds and Structural Results — Peter L. Bartlett and Shahar Mendelson (Journal of Machine Learning Research, Vol. 3, pp. 463–482) — November 2002 — Peer-Reviewed Journal Article (https://www.jmlr.org/papers/v3/bartlett02a.html)
- [4] Ridge Regression: Biased Estimation for Nonorthogonal Problems — Arthur E. Hoerl and Robert W. Kennard (Technometrics, Vol. 12, No. 1, pp. 55–67) — February 1970 — Peer-Reviewed Journal Article (https://www.tandfonline.com/doi/abs/10.1080/00401706.1970.10488634)
- [5] Regression Shrinkage and Selection via the Lasso — Robert Tibshirani (Journal of the Royal Statistical Society: Series B, Vol. 58, No. 1, pp. 267–288) — January 1996 — Peer-Reviewed Journal Article (https://academic.oup.com/jrsssb/article/58/1/267/7027929)
- [6] A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection — Ron Kohavi (Proceedings of the 14th International Joint Conference on Artificial Intelligence — IJCAI 1995) — August 1995 — Conference Proceedings Paper (https://ijcai.org/proceedings/1995/147)
- [7] 3.5. Validation curves: plotting scores to evaluate models — scikit-learn 1.9.1 documentation — scikit-learn Developers — 2026 — Official Software Documentation (https://scikit-learn.org/stable/modules/learning_curve.html)
- [8] 3.1. Cross-validation: evaluating estimator performance — scikit-learn 1.9.1 documentation — scikit-learn Developers — 2026 — Official Software Documentation (https://scikit-learn.org/stable/modules/cross_validation.html)
- [9] Bagging Predictors — Leo Breiman (Machine Learning, Vol. 24, No. 2, pp. 123–140; UC Berkeley Technical Report No. 421) — August 1996 — Peer-Reviewed Journal Article / Technical Report (https://www.stat.berkeley.edu/~breiman/bagging.pdf)
- [10] Dropout: A Simple Way to Prevent Neural Networks from Overfitting — Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov (Journal of Machine Learning Research, Vol. 15, pp. 1929–1958) — June 2014 — Peer-Reviewed Journal Article (https://jmlr.org/papers/v15/srivastava14a.html)
- [11] Decoupled Weight Decay Regularization — Ilya Loshchilov and Frank Hutter (International Conference on Learning Representations — ICLR 2019; arXiv:1711.05101v3) — January 4, 2019 — Conference Paper / arXiv Preprint (https://arxiv.org/abs/1711.05101)
- [12] AdamW — PyTorch 2.15 documentation — PyTorch Contributors / Linux Foundation — 2025 — Official Software Documentation (https://docs.pytorch.org/docs/stable/generated/torch.optim.AdamW.html)
- [13] Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift — Sergey Ioffe and Christian Szegedy (Proceedings of the 32nd International Conference on Machine Learning — ICML 2015, PMLR Vol. 37) — July 2015 — Conference Proceedings Paper (https://proceedings.mlr.press/v37/ioffe15.html)
- [14] Layer Normalization — Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E. Hinton (arXiv:1607.06450) — July 21, 2016 — Research Preprint (https://arxiv.org/abs/1607.06450)
- [15] Rethinking the Inception Architecture for Computer Vision — Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna (CVPR 2016; arXiv:1512.00567) — December 2, 2015 — Conference Paper / arXiv Preprint (https://arxiv.org/abs/1512.00567)