Overfitting

Overfitting is when a model learns its training data so closely, noise included, that it performs well on those examples but poorly on new data.

The point of training a model is for it to work on data it has never seen. Overfitting is the failure of that goal: Google's machine learning glossary defines it as creating a model that matches the training data so closely that it fails to make correct predictions on new data. The model has learned the quirks of its examples rather than the pattern behind them.

Wikipedia describes the essence as mistaking noise for structure. In the extreme case, a model with as many parameters as there are data points can fit the training data perfectly simply by memorising it, and will then fail badly on anything new. Google's glossary offers a comparison: a student who follows only one favourite teacher's advice may do well in that class and struggle in every other.

The standard warning sign shows up in loss curves. Engineers track error on the training data and on a separate validation set. If training error keeps falling while validation error starts rising, the model has begun to overfit, and the best version is usually the one from just before validation error turned upwards. Stopping training there is called early stopping.

The usual remedies are a larger and more varied training set and regularisation, which penalises complexity; Google's glossary names both. Specific techniques include cross-validation, early stopping, pruning and dropout. The term has been used in machine learning since at least the 1980s to describe models that break Occam's razor by being more complicated than the data justify. The opposite failure, a model too simple to capture the pattern, is called underfitting.

For anyone judging an AI product, the lesson is to ask how it was tested. A system that is near perfect on the examples its makers chose may be overfitted to them; the meaningful results come from data the model never saw during development.

Common questions

What is overfitting in simple terms?

It is when a model memorises its training examples instead of learning the general pattern. It then looks excellent on the data it was trained on but makes poor predictions on anything new, a bit like a student who memorises past exam answers without understanding the subject.

How can you tell if a model is overfitting?

Compare its performance on training data with its performance on data held back from training. A large gap, with much better results on the training data, is the classic sign. During training, validation loss that rises while training loss keeps falling points to the same problem.

How do you prevent overfitting?

The main tools are more and more varied training data, regularisation techniques such as L1 or L2 penalties and dropout, early stopping, and simpler models. Cross-validation helps detect overfitting by testing on several different held-out subsets of the data.

What is the difference between overfitting and underfitting?

Overfitting means the model is too closely tailored to its training data and fails to generalise. Underfitting means the model is too simple, or trained too little, to capture the real pattern, so it performs poorly even on the training data. Good models sit between the two.

Finding more

Search for "overfitting vs underfitting", "training vs validation loss" or "how to prevent overfitting" to see how the problem is diagnosed and fixed. Reliable sources include Google's Machine Learning Crash Course and Glossary, statistics and machine learning textbooks and encyclopedia articles that cite them. When a product's accuracy figures are quoted, look for whether they come from data held out from training.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.