Why Overfitting Hurts Machine Learning

Photo: Google DeepMind / Pexels
Give a decision tree algorithm enough freedom and it can reach 100% accuracy on any training dataset, simply by growing branches specific enough to isolate every training example into its own leaf. That perfect score is not a sign of a good model. It is a sign the model has stopped learning general patterns and started memorizing the exact examples it was shown, including their noise, quirks, and one-off coincidences. This is overfitting, and it is arguably the single most common failure mode in applied machine learning, quietly turning models that look flawless on a spreadsheet into models that fail the moment they meet real data.
What overfitting actually is, mathematically
Overfitting — when a model learns the noise and idiosyncrasies of its training data instead of the general pattern connecting inputs to outputs — is best understood through a formal lens called the bias-variance tradeoff. Every prediction error a model makes can be decomposed conceptually into two competing sources. Bias is error from a model being too simple to capture the real structure in the data, the kind of error a straight line makes when the true relationship is a curve. Variance is error from a model being too sensitive to the specific noise present in whichever training set it happened to see, the kind of error a wildly flexible model makes when small changes to the training data would produce wildly different predictions.
Overfitting is fundamentally a variance problem. An overfit model has learned the training data's noise as if it were signal, so its predictions swing based on quirks of exactly which examples happened to be included in training rather than on the underlying relationship the model is supposed to be approximating. If you retrained that same overfit model architecture on a slightly different sample drawn from the same population, it would produce meaningfully different predictions on the same test points, because it never learned the stable pattern in the first place, only the noise that happened to be sitting on top of one particular sample.
This tradeoff traces to statistical learning theory formalized by Vladimir Vapnik and Alexey Chervonenkis starting in the early 1970s, whose work on VC dimension (a way of measuring how many distinct patterns a hypothesis class can fit, and therefore how easily it can overfit a small dataset) provided the mathematical scaffolding modern practitioners still lean on (Kuriko Iwai's applied research summary on VC dimension and generalization bounds). VC theory gives a probabilistic bound on the gap between a model's error on its training data (empirical risk) and its error on data it has never seen (expected risk), which is exactly the gap that shows up in practice as the difference between training accuracy and validation accuracy. The tension the theory describes is unavoidable: reducing bias by giving a model more flexibility to fit complex patterns generally increases variance, and vice versa. The goal of a practitioner is never to eliminate bias or variance entirely, since that is mathematically impossible for any finite dataset, but to find the balance appropriate for the specific problem, the specific dataset size, and the specific amount of noise present.
Picture two archers. One always aims at the exact same spot slightly left of the bullseye and clusters every arrow tightly around that wrong spot: high bias, low variance, consistently wrong in the same direction. The other aims correctly on average but scatters arrows wildly across the target, some near the bullseye, some far outside it: low bias, high variance, correct on average but unreliable on any single shot. An overfit model behaves like the second archer when evaluated on new targets it has not practiced on, even though it looked perfectly accurate on the targets it trained against.
Why a model with too much capacity always risks this
A model's capacity — the complexity of the function it is capable of representing, determined by factors like the number of layers in a neural network, the depth of a decision tree, or the number of parameters in a regression — determines how much room it has to overfit. Models with capacity far exceeding what the underlying real pattern actually requires have more than enough flexibility to fit not just the genuine signal in the training data but also its incidental noise, essentially memorizing specific examples rather than the pattern connecting them.
Picture trying to draw a smooth curve through a handful of noisy data points scattered around a general trend. A straight line captures the trend but misses some individual points, an acceptable tradeoff since those misses are the noise, not the signal. A wildly wiggling curve, by contrast, can be drawn to pass through every single point exactly, at the cost of representing a shape that has nothing to do with the actual underlying trend and everything to do with the specific noise in those particular points. Hand that wiggling curve a new data point drawn from the same trend and it will often predict wildly wrong values, precisely because it was never fitting the trend to begin with.
This is why the naive intuition "a more powerful model is always a better model" fails so often in practice. A deep neural network with millions of parameters trained on a few thousand labeled examples has more than enough capacity to memorize every training example individually, effectively behaving like a lookup table with extra steps. It can report near-perfect training accuracy while having learned essentially nothing generalizable, which is why capacity has to be matched to the amount of available data and the true complexity of the problem, not maximized indiscriminately. Modern deep learning research has found this relationship to be more nuanced than the classical U-shaped bias-variance curve suggests. In heavily overparameterized regimes, some architectures exhibit what researchers call "double descent," where test error can rise as capacity increases past the interpolation threshold, then fall again as capacity increases further still, a phenomenon documented in analyses of the bias-variance tradeoff in modern neural networks (OpenReview, "A Modern Take on the Bias-Variance Tradeoff in Neural Networks"). The existence of double descent does not repeal the underlying danger of overfitting for a typical practitioner working with a typical dataset size. It mainly shows that the relationship between capacity and generalization is an active area of theoretical research, not a fully closed question, and that the classical warning against blindly maximizing model capacity still applies to the overwhelming majority of real-world projects.
The telltale signature: training accuracy up, validation accuracy down
The most reliable diagnostic sign of overfitting is a growing gap between a model's performance on its training data and its performance on a separate validation set it never saw during training. As training continues, or as model complexity increases, training accuracy typically keeps improving, or stays near-perfect, while validation accuracy improves initially, then plateaus, then actually starts declining. This pattern is visible clearly in learning curves, plots of training and validation performance across training iterations, which is why plotting both curves side by side is one of the first diagnostic steps any experienced practitioner runs before trusting a model's reported accuracy.
Underfitting produces a different, easily distinguishable signature: both training and validation accuracy stay low and roughly track each other, because the model is too simple to capture the real pattern in either dataset. A well-fit model produces a third signature, high accuracy on both training and validation sets that track closely together, indicating the model has captured the genuine underlying pattern without also absorbing the noise.
| Signal | What it indicates |
|---|---|
| Training accuracy high, validation accuracy low | Classic overfitting signature |
| Both training and validation accuracy low, tracking together | Underfitting (model too simple) |
| Both training and validation accuracy high, tracking closely | Well-fit model |
| Validation accuracy declining as training continues | Overfitting worsening with more training |
| Validation accuracy still improving as training continues | More training or capacity may still help |
Reading the gap between training and validation curves is the fastest way to diagnose which of the three regimes a model is currently in.
How cross-validation strengthens this diagnosis
A single training/validation split can itself be misleading if the split happens to be unrepresentative by chance, especially with smaller datasets. K-fold cross-validation — splitting the dataset into k roughly equal parts, training on k-1 of them and validating on the held-out part, then rotating which part is held out and averaging the results — produces a more reliable estimate of how a model generalizes, because it evaluates performance across several different train/validation splits rather than trusting the outcome of just one. It does not replace the need for a genuinely untouched final test set, but it substantially reduces the risk of drawing the wrong conclusion from a single lucky or unlucky split.
How regularization fights back against overfitting
Regularization techniques deliberately constrain a model's flexibility to discourage it from fitting noise, trading a small amount of training accuracy for a meaningful gain in generalization. L1 and L2 regularization are mathematical penalty terms added to a model's loss function that grow larger as model parameters grow larger, which pushes a model toward simpler solutions by penalizing unnecessarily large or numerous parameter weights. L1 regularization tends to push some weights all the way to zero, effectively performing a form of automatic feature selection, while L2 regularization tends to shrink weights toward zero without eliminating them entirely, producing smoother, more evenly distributed weight values.
Dropout, introduced by Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov in a 2014 paper published in the Journal of Machine Learning Research, randomly disables a fraction of neurons during each training step in a neural network, forcing the remaining network to learn more robust, redundant representations rather than depending heavily on any single, potentially noise-fitting pathway (Srivastava et al., 2014, "Dropout: A Simple Way to Prevent Neural Networks from Overfitting," JMLR vol. 15, pp. 1929-1958). The intuition behind dropout is close to how a sports team trains without relying on a single star player: if any player might be missing on a given day, the team is forced to develop redundant skills across the roster instead of building its entire strategy around one player's specific quirks. A neural network trained with dropout similarly cannot lean too heavily on any single neuron or narrow pathway, because that pathway might be randomly switched off during any given training step, which pushes the network toward representations that hold up even when parts of it are missing.
Data augmentation takes a different approach entirely: rather than constraining the model directly, it expands the effective size and diversity of the training set by applying realistic transformations to existing examples, such as rotating, cropping, or slightly distorting images, or paraphrasing text while preserving its meaning. A model trained on augmented data has a harder time memorizing any single exact example, since it never sees quite the same example twice, which pushes it toward learning transformation-invariant patterns instead of memorized pixel-level or token-level noise.
| Technique | Mechanism | Best suited for |
|---|---|---|
| L1 regularization | Adds a penalty proportional to the absolute value of weights, pushing some weights to exactly zero | Feature selection, sparse models, high-dimensional data |
| L2 regularization | Adds a penalty proportional to the squared value of weights, shrinking weights smoothly toward zero | General-purpose regularization, most linear and neural models |
| Dropout | Randomly disables a fraction of neurons during each training step | Deep neural networks, especially with dense fully connected layers |
| Early stopping | Halts training once validation performance stops improving | Any iterative training process, especially deep learning |
| Cross-validation | Rotates which data subset is held out for validation across multiple folds | Reliable model evaluation, especially with smaller datasets |
| Data augmentation | Expands training data with realistic transformations of existing examples | Image, audio, and text tasks with limited labeled data |
None of these techniques works in isolation; production machine learning pipelines typically combine several of them at once, since each addresses a slightly different mechanism by which a model can overfit.
Why early stopping is a simple but effective fix
Early stopping monitors validation performance during training and halts the process at the point where validation accuracy stops improving, even if training accuracy would continue climbing with more iterations. This directly targets the exact moment overfitting typically begins, since continuing to train past that point generally improves training fit at the direct expense of generalization to new data. Because it requires no change to the model's architecture or loss function, only a monitoring rule applied during training, early stopping is one of the cheapest and most widely used regularization techniques in practice.
In practice, early stopping is usually implemented with a "patience" parameter: rather than stopping the instant validation performance fails to improve for a single step, which can trigger prematurely due to normal noise in the validation metric, training continues for a fixed number of additional steps to confirm the plateau or decline is real before stopping and reverting to the best-performing checkpoint observed so far. This small addition prevents early stopping from being fooled by a single noisy epoch that happens to look like the start of overfitting when it is really just statistical fluctuation.
Why early stopping alone is rarely sufficient
Early stopping addresses the timing of overfitting but does nothing to change a model's underlying capacity or its tendency to fit noise if training continued. This is why practitioners almost always combine early stopping with other techniques like regularization or dropout rather than relying on it exclusively, since a model with excessive capacity relative to its dataset can still overfit meaningfully even within relatively few training iterations.
Why more data usually helps, but isn't a complete cure
Increasing the amount and diversity of training data generally reduces overfitting risk, since a model has a harder time memorizing noise specific to a larger, more varied dataset, and genuine underlying patterns become statistically more distinguishable from noise as sample size grows. This is one of the most consistent, empirically observed relationships in machine learning: for a fixed model architecture, more representative training data almost always narrows the gap between training and validation performance, because random noise averages out across a larger sample while genuine structure in the data does not.
However, more data alone cannot fully compensate for an extremely high-capacity model relative to the true complexity of the underlying problem, which is why data volume and regularization are typically used together rather than as substitutes for one another. A model with enough capacity to memorize a training set of ten thousand examples individually will often still find ways to overfit a training set of one hundred thousand examples, just with somewhat more difficulty. There is also a practical ceiling on how much labeled data most real-world projects can realistically obtain, since labeling is expensive, slow, and sometimes requires specialized expertise, which is exactly why data augmentation and transfer learning, reusing representations learned on a large related dataset, have become such widely used workarounds when collecting more raw labeled data is not feasible.
It is also worth distinguishing data quantity from data quality here. Doubling a dataset's size with examples that share the same biases, labeling errors, or narrow coverage as the original dataset does relatively little to reduce overfitting, since the "noise" a model can latch onto includes systematic errors, not just random statistical fluctuation. A smaller but more diverse, more carefully labeled dataset frequently outperforms a much larger dataset assembled carelessly, which is why data curation is treated as seriously as model architecture in most mature machine learning teams.
Common misconceptions
A common misunderstanding is that overfitting only affects unusually complex models like deep neural networks. Simple models, including linear regression, can overfit too if they are given too many features relative to the number of training examples, since the model can still find spurious correlations in high-dimensional data even without deep architectural complexity. A linear regression with a hundred features fit to only fifty training examples has more than enough freedom to find a combination of feature weights that fits every training point almost perfectly, purely by exploiting coincidental correlations that will not hold on new data.
Another misconception is that a model's training accuracy is a meaningful measure of its real-world quality. Training accuracy alone reveals nothing about generalization, and an overfit model's near-perfect training score is precisely the warning sign practitioners are taught to watch for rather than celebrate. A related misconception treats validation accuracy as a permanently trustworthy final answer once it has been checked once. In practice, repeatedly tuning a model's hyperparameters against the same validation set, adjusting, re-checking, adjusting again, can cause the model to indirectly overfit to that validation set too, which is why disciplined machine learning workflows reserve a separate, untouched test set that is only evaluated once, at the very end, after all tuning decisions have already been finalized.
A third misconception assumes overfitting is purely a technical inconvenience rather than something with real consequences once a model is deployed. An overfit fraud-detection model that memorized quirks of last year's transaction data instead of learning genuine fraud patterns will systematically miss new fraud tactics it has never encountered, exactly the tactics it most needs to catch. An overfit medical diagnosis model trained on data from one hospital's patient population may perform impressively in validation while failing badly on patients from a different demographic or a different hospital's equipment, a generalization failure with consequences well beyond a lower accuracy score on a leaderboard.
How overfitting shows up differently across model types
Not every model overfits the same way, and understanding those differences helps in choosing the right countermeasure for a given situation. Decision trees overfit by growing branches deep enough to isolate individual training examples, which is why pruning, limiting the maximum depth a tree is allowed to grow, is such an effective and commonly used countermeasure. Ensemble methods that combine many individual trees, such as random forests, reduce this risk substantially by averaging predictions across trees trained on different random subsets of the data and features, which cancels out much of the noise any individual tree might have overfit to.
Neural networks overfit differently, by adjusting millions of individual weight parameters to fit training examples with more precision than the underlying signal actually warrants, which is why dropout, weight decay (a form of L2 regularization applied specifically during neural network training), and early stopping are the dominant countermeasures in that setting rather than pruning. Support vector machines overfit primarily through an overly flexible choice of kernel function, the mathematical transformation that determines how the model separates classes, which is why kernel choice and the regularization parameter that controls the tradeoff between margin width and misclassification tolerance are the primary levers practitioners adjust.
What this means for building and evaluating models
Overfitting hurts machine learning because it optimizes for the wrong target: instead of learning the general pattern connecting inputs to outputs, an overfit model learns the specific, noisy details of exactly the examples it happened to be trained on. That distinction matters enormously in practice, because a model's entire value depends on how well it performs on data it has not already seen, not on how well it can recite answers it memorized during training. Detecting the gap between training and validation performance, and actively constraining model complexity through regularization, early stopping, cross-validation, or additional high-quality data, is what keeps a model's apparent competence from being an illusion that collapses the moment it meets data it has not already memorized.
The takeaway
The core insight behind overfitting is simple even though the mathematics underneath it, rooted in decades of statistical learning theory, is not: a model that performs suspiciously well on the data it was trained on has not necessarily learned anything useful about the world beyond that specific dataset. Practitioners who trust training accuracy without checking a held-out validation set, or who chase ever-higher model capacity without matching it to the amount and quality of available data, are the ones most likely to be blindsided when a seemingly excellent model fails in production. The fixes, regularization, early stopping, cross-validation, thoughtful data collection, are not exotic techniques reserved for advanced practitioners; they are baseline hygiene that separates a model that genuinely works from one that only appears to.
Read next:
- Why training and test data must be separated
- How random forests reduce error
- What model drift means in production
FAQ
Q: What is overfitting in machine learning?
Overfitting occurs when a model learns the noise and specific quirks of its training data rather than the genuine underlying pattern, resulting in high accuracy on training data but poor performance on new, unseen data. It is fundamentally a variance problem in the bias-variance tradeoff framework formalized in statistical learning theory.
Q: How can you tell if a model is overfitting?
The clearest sign is a growing gap between training accuracy, which keeps improving or stays near-perfect, and validation accuracy on unseen data, which plateaus and then starts declining as training continues or model complexity increases. Plotting learning curves for both metrics side by side is the standard diagnostic method.
Q: What is regularization, and how does it help with overfitting?
Regularization techniques, such as L1 and L2 penalty terms or dropout, deliberately constrain a model's flexibility, discouraging it from fitting noise in the training data and pushing it toward simpler, more generalizable solutions. Dropout specifically was introduced by Srivastava, Hinton, and colleagues in a 2014 JMLR paper.
Q: Does adding more training data always prevent overfitting?
More and more varied training data generally reduces overfitting risk, since genuine patterns become statistically more distinguishable from noise as sample size grows, but it cannot fully compensate for a model whose capacity is far greater than the underlying problem actually requires. Data quality matters as much as data quantity.
Q: Can simple models like linear regression overfit too?
Yes. Even simple models can overfit if they are given too many features relative to the number of training examples, since spurious correlations can still be found in high-dimensional data without requiring deep architectural complexity.
Q: What is the difference between overfitting and underfitting?
Overfitting means a model fits the training data too closely, including its noise, and performs poorly on new data. Underfitting means a model is too simple to capture the real pattern in the data, performing poorly on both training and validation data alike.
Q: Does cross-validation prevent overfitting?
Cross-validation does not directly prevent overfitting on its own, but it produces a more reliable estimate of how well a model generalizes by evaluating performance across multiple train/validation splits rather than trusting a single split, which helps practitioners catch overfitting that a single validation set might miss by chance.
Follow new articles
Add SciHub101 to your feed reader to see new science and technology stories.
About the Author
SciHub101 is an independent science and technology publication founded and edited by Buğra Sözeri, a software engineer and app developer based in Türkiye. AI tools assist with drafting and research. Source documentation in the existing archive is uneven, and articles are being reviewed and corrected. The Editorial Team byline identifies editorial responsibility; it does not certify specialist or independent human review. Where we compare products, anything built by our own team is labelled as such — see the editorial guidelines and About page for how corrections and disclosures work.
Related Articles




Overfitting & Underfitting — ML Bias-Variance Tradeoff
Overfitting and underfitting in ML explained simply: bias-variance tradeoff, how to detect, regularization, cross-validation, and practical fixes for both.
PCA Explained: How Dimensionality Reduction Works
Principal component analysis explained: how PCA finds the directions of greatest variance, how to choose components, and when PCA, t-SNE, or UMAP mislead.
Why 99% Accuracy Can Be Useless: Precision and Recall
Why 99% accuracy can be useless: how the confusion matrix, precision, recall, F1, and PR curves behave on imbalanced data, with a fully worked example.