What is overfitting in machine learning?
Also called: Overfit, Over-fitting
In one minute
Overfitting is when an AI in machine learning fits the data it was trained on so closely that it does well on that data but gets new data it has never seen wrong.
An AI learns by finding patterns in many examples. But examples also contain chance quirks and wrongly labeled answers (together called noise). When there are few examples, or the AI’s design is too complex and free, it learns not only the real pattern but those chance quirks too. So even a near-perfect score on the training data doesn’t tell you whether the AI is any good.
That is why it is checked on data kept out of training. To prevent overfitting, you can collect more data, make the design simpler or stop training at the right moment.
A common mix-up
“Overfitting means an AI has learned from too much data.”
Only partly right. Training on the same data for too many rounds can lead to overfitting, and stopping training once the error (the size of the mistakes) on data not used for training starts to rise is called “early stopping.” But having too much data is not the cause. In fact, the less data there is, the easier it is to mistake chance quirks for real patterns, and the more likely overfitting becomes. Collecting more varied examples is usually one way to prevent it. As the name “over-fitting” says, what goes too far is not the amount of data but how closely the model fits the training data.
Explained in pictures
Think of it like this
A student who memorized the workbook’s answers
Imagine two students studying for a test with a workbook. One practices by thinking through how to solve each problem; the other memorizes the workbook’s answers. If the test uses the workbook’s questions, both get full marks. But when new questions with different numbers appear, the one who learned how to solve them can do it, and the one who memorized can’t. That memorizing is overfitting.
That is why teachers check real skill with questions not used for practice. It is the same as checking an AI on data kept out of training. Looking only at workbook scores, you can’t tell the two students apart.
But the comparison has limits. A student knows they memorized, but an AI doesn’t notice on its own. As an AI adjusts its numbers (parameters) to reduce its mistakes, it can pick up the real pattern and, at the same time, simply memorize the chance quirks as they are. And a big AI can train until it fits its training data exactly and still do well on new data, which is not the same as a person’s rote memorizing.
Key points
How do you spot it?
Measuring results only on the data used for training won’t reveal overfitting, because the more an AI overfits, the better it does on that data. So the data is split. Apart from the data used for learning (the training set), some is kept to check results during training (the validation set) and some for a final check at the end (the test set). One example split is 70% training, 15% validation and 15% test. The validation set is looked at again and again during training to choose where to stop and which settings to use, so with repeated use the choices come to fit that data. That is why the final check uses the test set, which hasn’t been used until then.
During training, the error (the size of the mistakes) is measured on both the training and validation sets and plotted against the number of rounds. At first both fall in the same way. If at some point the training error keeps falling while the validation error starts to rise, that is a sign of overfitting.
If the checking data contains the same examples as the training data, overfitting can be missed, so duplicates are removed from the validation and test sets. For example, if the data for an AI that spots spam email is split without removing emails with the same text, the AI effectively sees many of the test emails during training, and its test score looks better than it really is. Only new examples give a fair check.
Why does it happen?
Besides the real pattern, data contains chance quirks and wrong answers (noise). With little data, there are more shapes that happen to appear in the training data but not in new data. Overfitting is when the AI learns those as if they were the real pattern. It also happens when the training data doesn’t represent well the data the AI will meet in real use (for example, an AI trained only on daytime photos that is also used on night photos).
A design that is too complex can also cause it. For example, take 30 points: values on a smooth curve with noise added. Try fitting a straight line, a moderately curved line and a line that curves in fine detail. The straight line doesn’t fit even the training points. The moderately curved line matched the original curve almost exactly. The finely curving line memorized the noise too, and its error on the checking data became larger by orders of magnitude.
The opposite, where the AI is too simple to do well even on its training data, is called underfitting. A good AI aims for the right spot in between. The ability to get data it has never seen right is called generalization.
How can it be prevented?
First, by getting more data. With many varied examples, the chance quirks differ from example to example, so the real pattern stands out. Other ways are to make the AI’s design simpler, and to make training aim not only for small mistakes but also for “not too complex.” The latter is called regularization. In L2 regularization, for example, the numbers inside the AI (its weights) are penalized for their size too, so that none grows too big (the sum of the squares of the weights is added to the size of the mistakes, and training tries to make both small). This pulls the weights toward zero, which helps avoid overly complex ways of answering, because bigger weights are taken to mean a more complex way of answering. The strength of regularization is one of the hyperparameters (settings people choose before training) and is chosen on the validation set.
Early stopping means stopping training where the error on the validation set starts to rise. It is quick, since nothing about complexity has to be calculated. But it is said to be very unlikely to do as well as an AI trained thoroughly with regularization of just the right strength.
A 2014 paper (Srivastava et al., University of Toronto) studied and described in detail a method for neural networks (computing systems modeled loosely on the brain’s nerve connections) called “dropout.” During training, units (artificial neurons) in the network are picked at random and temporarily removed. For the layers between the input and the output (hidden layers), the paper says, keeping each unit with a probability of one half seems close to the best value for a wide range of networks and tasks. This stops units from relying on each other too much, and has an effect close to averaging the answers of many different networks. On a task of reading handwritten digits (MNIST), the error rate fell from 1.60% to 1.35% (about 16% fewer mistakes). The paper says dropout prevented overfitting even when a big network with more than 65 million numbers inside (parameters) was trained on 60,000 examples.
If an AI scores 100% on its training data, is it good?
Not necessarily. A 2017 paper (Zhang et al., Google Brain and others) took a task of sorting photos into 10 kinds, such as airplanes, cars, birds and cats (CIFAR10, with 50,000 training photos), replaced all the photos’ answers (the names of what they show) at random, and then trained an AI on them. There was no pattern at all linking photos and answers. Even so, the AI memorized the answers for the training photos and came to get 100% of them right. On new photos it got about 10% right, the same as guessing.
The same AI trained on the true answers also scored 100% on the training photos, and about 86% on new photos. On the training photos, both scored the same 100%. Whether an AI learned a pattern or just memorized can only be told by checking it on held-out data.
Memorizing the random answers took only a little longer than learning the true ones. This AI had about 1.65 million numbers inside (parameters), far more than the number of training photos. In other words, it had plenty of room to memorize. The paper says neural networks have enough capacity to memorize the whole dataset. Regularization can also improve results on new data. But the paper says an AI can do well on new data even without regularization, and regularization alone can’t fully prevent overfitting.
Are bigger AIs more likely to overfit?
The traditional view was that as an AI is made more complex, its error on new data first falls and then, past some point, rises (a U shape). Textbooks have said that a model (a trained AI) with zero error on its training data is overfit and will typically do poorly on new data. Yet today’s big neural networks often fit their training data exactly and still do well on new data.
A 2019 paper (Belkin et al., Ohio State University and Columbia University) showed, across many kinds of AI and data, that as an AI is made bigger (with more numbers inside), the error on new data peaks around the size where the AI first becomes able to fit its training data exactly (where it has just enough numbers inside), and falls again as the AI gets bigger still. It says the error often ends up lower than the bottom of the U. Because the error falls twice, this is called “double descent.”
A study the same year (Nakkiran et al., Harvard University and OpenAI) showed that double descent happens in a variety of today’s deep learning tasks (deep learning means learning with neural networks of many stacked layers), such as AIs that recognize photos and AIs that translate. It also happened when the number of training rounds was increased. And in a translation task, for AIs of a size near the peak, there were cases where making the training data 4.5 times larger made the results worse. That is because more data changes the size at which the AI becomes able to fit it exactly, shifting where the peak falls. The peak showed most clearly when the data had wrong answers mixed in. With data that had no wrong answers, sometimes there was no peak, only a stretch where the error stayed flat for a while.
So it is not true that bigger AIs always overfit, nor that bigger is always better. What matters is not how exactly an AI fits its training data, but whether it gets new data right. That is why, at any size, checking on held-out data is what matters.
Check yourself
Q1While training an AI, you measure the error (the size of its mistakes) after each round on both the training data and data kept out of training. With “early stopping,” a way to prevent overfitting, where do you stop training?
Answer and explanation
Answer: C Where the held-out data’s error is smallest
Early stopping stops training where the error on the held-out data (the validation set) reaches its lowest point and starts to rise. The error on the training data keeps falling after that, but only because the AI has begun memorizing chance quirks, and it starts missing more on new data. A small gap between the two errors can also mean both are still large (the AI hasn’t learned enough yet), so the gap alone can’t tell you where to stop.
Q2In a 2017 paper, an AI that sorts photos into 10 kinds was trained on photos whose names had been swapped at random (a cat photo labeled “airplane,” for example). It got 100% of the training photos right, but only about 10% of new photos (the same as guessing). Why could it get the training photos 100% right?
Answer and explanation
Answer: B It memorized the name given to each photo, one by one
With the names swapped at random, there is no pattern linking photos and names. If the AI had found real clues in the photos, it would also get new photos right, but it got only about 10%. If it had noticed the true names, they wouldn’t match the random names, so it wouldn’t get even the training photos right. The AI memorized the names of all 50,000 training photos one by one. Right on the training data, wrong on new data: this is overfitting in its most extreme form.
Q3In a study published in 2019, AIs were made bigger step by step (with more numbers inside), each was trained, and their errors on new data were compared. How did the error change, across several kinds of AI and data?
Answer and explanation
Answer: A It fell, then rose, then fell again
As the AI was made bigger, the error on new data first fell, peaked around the size where the AI first became able to fit its training data exactly, and fell again as it got bigger still. Because it falls twice, this is called “double descent.” In the traditional view (the U shape), once it started rising, it should have kept rising. But how clearly the peak shows up depends on things such as whether the data has wrong answers mixed in. It also doesn’t mean bigger is always better.
More on this → Key points: Are bigger AIs more likely to overfit?
Related terms
- Machine learning
- Deep learning
- Neural network
- Parameter
- Hyperparameter
- Generalization
- Underfitting
- Regularization
- Early stopping
- Dropout
- Double descent
Sources and how we checked
- Google, "Overfitting" (Machine Learning Crash Course; the meaning of overfitting, generalization and underfitting, loss curves and causes; read November 10, 2026)
- Google, "Overfitting: Interpreting loss curves" (Machine Learning Crash Course; the curve where validation loss starts rising; read November 10, 2026)
- Google, "Overfitting: Model complexity" (Machine Learning Crash Course; regularization as a penalty on complexity; read November 10, 2026)
- Google, "L2 regularization" (Machine Learning Crash Course, Overfitting module; L2 regularization, regularization rate and early stopping; read November 10, 2026)
- Google, "Dividing the original dataset" (Machine Learning Crash Course; training, validation and test sets, and removing duplicates; read November 10, 2026)
- Google, "Machine Learning Glossary" (entries for overfitting, generalization, generalization curve, regularization, early stopping and dropout regularization; read November 10, 2026)
- scikit-learn, "Underfitting vs. Overfitting" (example in the scikit-learn 1.9.1 documentation: polynomials of degree 1, 4 and 15 fitted to 30 noisy points on a cosine curve; read November 10, 2026)
- Srivastava et al., "Dropout: A Simple Way to Prevent Neural Networks from Overfitting" (University of Toronto; Journal of Machine Learning Research 15, pp. 1929–1958, 2014; abstract, Section 1 and Section 6.1.1; read November 10, 2026)
- Zhang et al., "Understanding deep learning requires rethinking generalization" (MIT, UC Berkeley, Google Brain and Google DeepMind; ICLR 2017; arXiv, November 2016, version 2 February 2017; Section 1, Section 2.1, Section 3, Table 1 and Appendix A; read November 10, 2026)
- Belkin et al., "Reconciling modern machine learning practice and the bias-variance trade-off" (Ohio State University and Columbia University; PNAS, 2019; read the abstract, Section 1, Figure 1, Section 2 and Figure 4 of arXiv version 2, September 2019; read November 10, 2026)
- Nakkiran et al., "Deep Double Descent: Where Bigger Models and More Data Hurt" (Harvard University and OpenAI; arXiv, December 2019; abstract, Section 1, Figures 1–3, Section 2 and the remarks on label noise; read November 10, 2026)
- AWS, Japanese page “What is overfitting?” (for the Japanese names “kagakushū” and “kajō tekigō”; read November 10, 2026)
- IBM, Japanese page “What is overfitting?” (for the Japanese names “kajō tekigō” and “kashō tekigō,” underfitting; read November 10, 2026)
AI wrote this page from the sources above, and a different AI checked it against the text of those sources (November 10, 2026). A person with a master’s degree in science and a Japanese high-school science teaching license also read and checked it before publishing. Numbers are as of that date. If anything was hard to follow, you spot a mistake, or there’s a term you’d like explained, please write to [email protected].
AI terms
- AI agent
- Artificial general intelligence (AGI)
- Artificial intelligence (AI)
- Context window
- Deep learning
- Fine-tuning
- Generative AI
- Hallucination
- Hyperparameter
- Intelligence explosion
- Large language model (LLM)
- Machine learning
- Mixture of experts (MoE)
- Neural network
- You are hereOverfitting
- Parameter
- Prompt
- Prompt injection
- Reasoning model
- Recursive self-improvement (RSI)
- Reinforcement learning (RL)
- Retrieval-augmented generation (RAG)
- Superintelligence (ASI)
- Technological singularity
- Token
- Transformer