Skip to content

What is overfitting?

When a model learns the noise in its training data instead of the rule, and collapses on new data it has never seen.

Overfitting is the situation where a model learns the accidental details of the data it was trained on, the noise, instead of the general rule it was supposed to extract, and consequently scores excellently on that data and poorly on new data. It is the most common way a machine learning project fails, and it is insidious because during development it presents itself as success: the metrics go up, the model looks better and better, and what it is actually doing is memorizing. The opposite phenomenon, underfitting, is recognized immediately because the model does badly everywhere, which is why it causes far less damage. The structural cause is that a sufficiently flexible model can always find a rule that perfectly explains a finite set of examples, coincidences included, and nothing in the training process distinguishes a coincidence from a signal. The only thing that distinguishes them is a test on data the model has never seen.

See also: Ensemble learning · Combining the predictions of several models to obtain one more accurate than any single model on its own.

Why it is measured, not intuited

There is no way to look at a model and see whether it is generalizing: you can only put it to the test. Hence the discipline of splitting data into one part for training, one for choosing settings and one, untouchable until the end, for the final evaluation. The rule most often violated, and almost always in good faith, is the last one: every time you look at the result on the final set and change something as a consequence, that set stops being an independent test and you start overfitting the evaluation itself. The tools for containing it are well known and none is sufficient alone: simplify the model, penalize oversized coefficients, stop training before convergence, add data, or combine several models through ensemble learning, which reduces variance precisely by averaging errors that differ from one another.

On the other side sits underfitting, the mirror defect: the model is too rigid to capture the structure the data genuinely contains, and it gets things equally wrong on the training data and on new data. It is far less dangerous precisely because it is visible immediately, whereas overfitting disguises itself as success. The two defects sit at opposite ends of the same axis, the model's flexibility: stiffening it too much to escape overfitting lands you in underfitting, and the balance point is not found by reasoning about it, it is found by testing and measuring on data the model has never seen.

An enterprise example

A company trains a model to predict which customers will leave the service. In validation the model is nearly perfect, and in production it turns out to be useless. Analyzing the case reveals that among the variables was the number of support contacts in the last thirty days, which in the historical data always rose right before cancellation because those contacts were the cancellation itself being processed. The model had not learned to predict churn, it had learned to recognize it after it was already decided. This is the most expensive variant of the problem, because the defect is not in the algorithm but in how the data was constructed, and no amount of regularization catches it.

Why it matters for decision makers

A decision maker does not need to know how to fix overfitting, but does need to recognize the conversation in which they are about to fall victim to it, and has a single question to ask: on what data was this result measured, and had the model ever seen that data before. If the answer is muddled, the number being presented is not an estimate of how well the system will work, it is a description of how well it crammed. It is the same reason a convincing demo is never proof that something works, and why the systematic evaluation stage has to be designed before starting rather than negotiated afterward, when the results are already on the table and there is a launch date to defend. The gap between test and reality does not close once and for all, either: the world's data changes, and a model that generalized well degrades over time, which is why the measurement has to be repeated in production rather than filed away at delivery. Finally, overfitting is not only about models: a strategy chosen because it would have worked beautifully on past data suffers from exactly the same defect, with the difference that nobody calls it by that name.

  • Ensemble learning · Combining the predictions of several models to obtain one more accurate than any single model on its own.
  • Data augmentation · Expanding a training set by transforming the real samples already collected, without changing their labels.
  • Confidence Calibration · How well an AI model's stated confidence actually matches its real probability of being right.
  • Monte Carlo simulation · A method that estimates the outcome of an uncertain process by simulating it thousands of times with randomly drawn inputs.
  • Apophenia · The tendency to perceive meaningful patterns or correlations in data that is random or unrelated.

See it in the universe

If you need the AI in production, not in a demo, that is my job.

SEE AI INTEGRATIONS

Or write to me.