Concept/Probability and Statistics/No. 0707

Overfitting

Overfitting occurs when a model learns chance details in its training data and predicts new data poorly as a result. In statistics and machine learning, its risk depends on model flexibility, sample size, and how often the same data guide model selection.

a concept: name it

01You've seen this when…

  1. in life

    You add separate adjustments for every shopping day to your grocery-budget spreadsheet. It reproduces last month’s bills almost exactly. This month’s predictions miss by $40.

  2. at work

    A team tries dozens of formulas for predicting support tickets. The winning formula tracks the historical chart beautifully, but staffing shortages return as soon as it goes live.

  3. out in the world

    A weather app advertises a perfect record on last month’s weather after its developers tune the forecast rules to match every day. In its first week of new forecasts, it repeatedly promises sunshine before downpours.

02The idea

Suppose you plot a handful of observations and draw a curve through them. A straight line may capture the broad trend. A sufficiently flexible curve can pass through every point, bending around a measurement error here and an unusual day there. Those bends improve its fit to the observations already collected. They may make its next prediction worse.

The data used to build a model are its training data. They contain both recurring patterns and incidental details: sampling variation, measurement errors, unusual events. Overfitting happens when the model absorbs those details strongly enough to hurt its performance on fresh cases.

Flexibility creates opportunities for this. So does searching. Even a simple formula can overfit if someone tries enough versions and keeps the one that happens to match the sample best. The full search process matters, including discarded formulas and hand-tuned exceptions.

Training error therefore gives an incomplete picture. A model has already had the chance to accommodate those observations. Its performance on unused data provides a stronger test of whether the pattern carries over.

03Why it matters

Overfitting makes evidence look stronger precisely where a model has received the most attention. Another adjustment lowers the historical error. Another exception explains an awkward case. Each improvement can feel like progress while the model becomes less dependable outside that sample.

That matters when forecasts set inventory levels, lending models approve loans, or medical tools estimate risk. The cost arrives after deployment, when decisions depend on predictions for cases the model has never seen.

The same problem reaches beyond formal software. An investor can search past prices for a profitable trading rule. A manager can build an elaborate account of which employee traits predict success from a small hiring history. Both searches can select patterns that happened to work in the available sample. This connects overfitting to the multiple comparisons problem and the inflated performance of selected winners, or winner’s curse in estimation.

04A worked example

Consider an illustrative housing-price exercise. An analyst has records for 80 sales from one neighborhood. She sets aside 20 records before doing any modeling and uses the remaining 60 to build two predictors.

The first uses floor area, bedroom count, and building age. The second adds many interactions and adjustable curves, allowing the effect of one feature to change depending on several others.

What it looks like The complex model wins comfortably. On the 60 training sales, its average absolute prediction error is $9,000. The simpler model’s is $32,000. A chart of predicted prices against sale prices makes the complex model look impressively accurate.

What’s actually going on On the 20 untouched sales, the complex model’s average error rises to $58,000. The simpler model’s is $35,000. In this constructed example, the complex model has absorbed peculiarities of the training sales that fail to carry over. Its attractive historical fit concealed weaker prediction.

What would have helped Reserving those 20 sales before tuning gives the analyst a useful warning. She can reduce flexibility or apply regularization, which restrains how strongly the model responds to the training sample. Because 20 test cases provide a noisy estimate, she should also assess performance across additional held-out samples before drawing a firm conclusion.

05Where people trip up

  • They keep consulting the final test set. After seeing disappointing test results, people adjust the model and test again. Repeating this turns the test set into another source of training feedback. Keep a final evaluation untouched until choices are settled. When tuning many candidates, cross-validation can rotate which observations are held out; a separate outer evaluation can assess the whole selection process.
  • They treat all rows as independent evidence. Ten thousand readings from ten patients provide different information from ten thousand readings from ten thousand patients. Putting readings from the same patient in both training and test sets can flatter performance on unfamiliar patients. Split by the unit the model will encounter next: patient, customer, site, or time period.
  • They let information cross the evaluation boundary. Choosing features using all the outcomes, or using information that becomes available only after a prediction, contaminates the test. This is data leakage. Fit preprocessing and feature-selection steps using training data, then apply those steps to held-out cases.
  • They assume simpler always means better. A model can also miss important structure because it has too little flexibility. That is underfitting. Compare candidates against a simple baseline on unused data, and choose flexibility according to that evidence. The bias–variance trade-off helps explain why both extremes can fail.
  • They report the winning score alone. A result selected from many attempts usually looks better than a typical result. Record the search process, examine variation across evaluation splits, and report uncertainty around performance. An impressive single score can hide substantial model risk.

06When it isn’t overfitting

A model can fail on fresh data because the world changes. A demand forecast built before a new competitor opens faces different conditions afterward. That is distribution shift. Overfitting concerns learning incidental features of the available sample; distribution shift concerns changes between the conditions represented by the sample and those encountered later. Both can occur together.

A perfect training fit also does not establish overfitting. Some highly flexible models predict well despite fitting their training observations exactly. Their training procedure, constraints, and the structure of the data affect what they learn. Research on double descent shows that increasing model complexity can sometimes improve test performance again after an intermediate region of poor performance. Parameter counts and training scores alone cannot settle the diagnosis.

07Roots

In 1974, statistician Mervyn Stone examined a practical problem: how should someone choose a statistical predictor and assess its likely accuracy? A regression equation could earn a better fit by gaining another adjustable coefficient. Scoring it on the observations that helped choose those coefficients gave it a built-in advantage.

Stone’s paper developed cross-validation for choosing and assessing predictions. Its concrete move was to leave observations out, fit using the remainder, and predict the omitted cases. Repeating that exercise made prediction beyond the fitting sample part of the assessment.

The underlying problem was already familiar in statistical curve fitting, and overfitting has no single inventor. As machine learning expanded the range of models and automated searches, the issue grew to include the entire selection procedure. Researchers showed how repeated optimization of validation scores could overfit the evaluation itself. Modern practice carries that lesson into feature selection, tuning, and preprocessing: every choice made from the data belongs inside the process being tested.

08How solid is this?

ContestedMixedUsefulEstablished

Overfitting is supported by statistical theory and extensive empirical work. Its severity depends on the data and the full fitting and selection procedure; modern results show that model size or a perfect training fit alone cannot diagnose it.

09Connections

confused withconfused withcountered bycountered bycountered bycountered byin tensionpart ofpart ofOverfittingDistributionShiftData LeakageEcologicalRationalityOccam’s RazorCross-ValidationRegularizationUnderfittingBias-VarianceTrade-OffModel RiskCalibration

+ 2 more in the list

10Origin and sources

A longstanding problem in statistical model fitting, with no single inventor. Mervyn Stone’s 1974 work on cross-validation helped formalize methods for choosing predictors and assessing performance beyond the fitting sample.

  1. [1]Stone, M. (1974). Cross-Validatory Choice and Assessment of Statistical Predictions. Journal of the Royal Statistical Society: Series B (Methodological), 36(2), 111–147.
  2. [2]Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction. Second edition. Springer.
  3. [3]Cawley, G. C., & Talbot, N. L. C. (2010). On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation. Journal of Machine Learning Research, 11, 2079–2107.
  4. [4]Belkin, M., Hsu, D., Ma, S., & Mandal, S. (2019). Reconciling modern machine-learning practice and the classical bias–variance trade-off. Proceedings of the National Academy of Sciences, 116(32), 15849–15854.

Updated 2026-10-05