The student who memorised the answers
Imagine a student who prepares for an exam by memorising every past paper word for word. If the real exam repeats those questions, the student scores perfectly. If the questions are new, the student is lost, having learned the answers but not the subject. Machine-learning models can fall into exactly this trap, which is called overfitting. A model is trained by adjusting its internal settings to fit a set of examples. Fit them too closely and it starts to capture accidental details, such as noise, errors and coincidences that will not appear in new data. It then performs impressively in training and disappointingly in real use.
Signal and noise
Real data mixes a genuine pattern, the signal, with randomness, the noise. House prices, for example, depend broadly on size, location and age, but each sale also reflects chance factors, such as a buyer in a hurry. A good model captures the broad relationship and ignores the chance. A model with enormous flexibility can instead bend itself to pass through every single data point. With ten points on a chart, a curve with enough freedom can hit all ten exactly, wriggling wildly between them. It has zero error on those ten and makes absurd predictions everywhere else. The opposite failure, underfitting, uses a model too simple to capture the real pattern.
Testing on unseen data
The core defence is to judge a model on data it never saw during training. Engineers usually split their data into three parts: a training set, from which the model learns; a validation set, used to compare designs and decide when to stop; and a test set, kept locked away for a final, honest score. During training, error on the training set keeps falling. Error on the validation set falls at first, then flattens and starts to rise as the model begins memorising. That turning point signals overfitting. Stopping training around there, called early stopping, is one of the simplest and most widely used safeguards.
Making the most of limited data
Holding data back is costly when examples are scarce. Cross-validation offers a compromise. The data is divided into, say, five equal folds. The model is trained five times, each time learning from four folds and being tested on the fifth, so every example is used for testing once. With 10,000 examples, each round trains on 8,000 and tests on 2,000, and the five scores are averaged for a more reliable estimate. Other techniques reduce overfitting directly: gathering more data, simplifying the model, penalising extreme internal settings, a method called regularisation, and dropout, which randomly switches off parts of a neural network during training so it cannot rely on any single path.
Hidden leaks
Some of the most damaging failures come from leakage, when information from the test data slips into training. A medical model might learn to recognise the hospital where scans were taken, not the disease, if one hospital supplied most of the sick patients. A model judged on images that also appeared in its training set will look far better than it is. Leakage produces excellent scores that evaporate in practice, and it can be very hard to spot. Careful teams make sure the test data is genuinely separate, for example drawn from later dates, different locations or different patients, so that the score reflects the conditions the model will really meet.
Overfitting in large models
Very large modern models complicate the picture. Neural networks with billions of settings can memorise huge amounts of data, yet they often generalise well, a behaviour researchers are still working to explain. Overfitting has not disappeared, though. Large language models can reproduce passages from their training text, and benchmark scores can be inflated if test questions leaked into training data, a problem known as contamination. For that reason, evaluators increasingly create fresh tests after a model is built. For anyone relying on an AI system, the lesson is practical: ask how it was tested, on what data and how closely that data resembles the situations where it will be used.
Sources & further reading
- Google for Developers · Machine Learning Crash Course: overfitting ↗
- scikit-learn · Cross-validation ↗
Figures are rounded and widely published; check the linked organisations for the latest editions. These organisations do not endorse this website.



