Understand the idea
Imagine drawing a curve that passes exactly through every single point on a scatterplot, wiggling wildly to do so. It has zero error on those exact points, but ask it to predict a new point and it can be wildly wrong, because the wiggles were fitting random noise in that specific sample, not the real underlying pattern.
This is the central trade-off in every predictive model: a model with too few parameters (too simple) misses real structure (UNDERFITTING); a model with too many parameters, or too much flexibility relative to the amount of data, memorizes the training sample's noise (OVERFITTING). Somewhere between the two is the sweet spot that generalizes best to new data.
The tell is a gap between training performance and performance on data the model never saw during fitting: a model that scores 98% accuracy on the data it was trained on but only 62% on new data has overfit, regardless of how impressive that 98% looked in isolation. This is exactly why performance must always be measured on held-out data, never on the training set alone.
The bias-variance trade-off describes this balance: a model that is too simple misses real patterns (bias), and one that is too flexible chases noise (variance). Model complexity, meaning how many terms or how much flexibility a model has, is the dial that controls overfitting. The generalization error is how wrong the model is on new data it has not seen, and it is the number that overfitting makes worse.
Practitioner explanation
Formally this is the bias-variance trade-off: adding model flexibility (more parameters, higher-degree polynomials, deeper trees, more predictors) reduces bias but increases variance; the model's predictions become more sensitive to which particular training sample it happened to see. Overfitting is the regime where the variance term dominates the trade-off.
In-sample metrics (training R-squared, training accuracy) are BIASED optimistic estimates of future performance and grow monotonically worse as a diagnostic the more flexible the model is allowed to become; the only trustworthy estimate of generalization is performance on data withheld from fitting, via a train/test split or cross-validation. Regularization (ridge, lasso, elastic net; tree pruning; early stopping; dropout) directly penalizes complexity to counteract overfitting rather than relying on the analyst to notice the training/test gap after the fact.
KernelStats' cross-validation tool (the cross-validation function) reports both the cross-validated metric and its standard error across folds, and applies the 'one-standard-error rule' (preferring the simplest model within one SE of the best cross-validated score) as a principled defense against choosing an overfit model purely because it scored marginally higher on one particular split of the data.
When to use it
Consider it when
Whenever a model's flexibility (number of predictors, tree depth, polynomial order, number of hidden units) is a choice being made from the data; overfitting risk rises with every added degree of freedom relative to the sample size.
Use caution when
Do not judge overfitting from the training-set score alone; a low training error is uninformative about generalization without a held-out comparison.
Common misconceptions
Misconception
A model with a very high training R-squared or accuracy is a good model.
Correction
A very high training-set score is exactly the pattern overfitting produces. To judge how well a model will predict, measure it on data it did not see during fitting; to judge whether it describes the data well, also check the residual diagnostics.
Read more: Misconception: a model's training-set accuracy is its real-world performance
References
- NIST/SEMATECH e-Handbook of Statistical Methods, §4.4.3.7 Model validation, NIST/SEMATECH (2012), §4.4.3.7.
