What Is Overfitting? And Why You Should Care
Overfitting is when a model memorizes the past instead of learning patterns that work in the future. This guide explains it with practical examples.
The Exam Cramming Analogy
Picture a student preparing for a history exam. Instead of understanding the causes and consequences of major events, they memorize the exact wording of practice test questions and their answers. On exam day, they score 98%. Ask them a week later to explain what actually happened and why - or give them a question phrased differently - and they have no idea.
That student did not learn history. They learned the practice tests. Machine learning models can do exactly the same thing.
Overfitting happens when a model performs very well on the data it trained on and poorly on new data it has never seen. It has memorized patterns that are specific to the training examples rather than learning the underlying rules that generalize to new situations.
Training Data vs. Test Data - Without the Math
When you train a machine learning model, you hold back some of your data - the test set - and never show it to the model during training. This held-out data represents the real world: examples the model has to predict correctly without having seen them before.
A well-fitted model performs similarly on training data and test data. An overfitted model performs much better on training data. That gap is the overfitting signal.
Imagine measuring only training accuracy and declaring success at 98%. Then the model hits production and performs at 67%. The training accuracy was meaningless because the model had simply memorized the training examples.
Why Complexity Is the Culprit
A simple model - say, one that predicts house prices based on square footage - can only fit a straight line through the data. It misses some nuances, but those misses are small and predictable. It generalizes reasonably well.
A very complex model - with hundreds of parameters - can fit a wiggly, twisting curve that passes through every single training point perfectly. It gets a perfect score on training data. But that wiggly curve is reacting to noise, outliers, and quirks of this specific dataset, not the true underlying relationship. On new data, it fails.
Complexity enables memorization. Simplicity encourages generalization. The goal is always to find the sweet spot.
Bias and Variance - the Intuition Without Equations
There is a classic tradeoff in machine learning called bias versus variance.
A high-bias model makes strong assumptions and is too simple. It consistently misses patterns. Think of someone who always predicts "sunny" regardless of the forecast - wrong in a predictable direction.
A high-variance model is too sensitive and complex. It reacts to every quirk in training data. Think of someone who changes their weather prediction every hour based on every passing cloud - unstable and unreliable on new days.
Overfitting is a high-variance problem. The model is too tuned to the noise of the training data to be useful on anything new.
What Regularization Does - in Plain Terms
Regularization is a family of techniques that impose a cost on model complexity. They tell the training process: "yes, you could fit the training data more closely by adding complexity, but we are going to penalize you for that complexity."
The result is a model that accepts slightly imperfect performance on training data in exchange for better generalization on new data. Think of it as a discipline rule: you are not allowed to memorize. You must understand.
Early Stopping and Dropout
Two more practical tools are worth knowing. Early stopping means you monitor performance on a held-out validation set during training, and you stop when validation performance stops improving - even if training performance is still climbing. That divergence is the overfitting signature.
Dropout is used in neural networks. During training, the network randomly ignores (drops out) a fraction of its neurons on each pass. This prevents the model from relying too heavily on any single path through the network, forcing it to develop more robust, distributed representations.
Why "98% Accuracy" Should Raise a Question
When a team reports impressive accuracy, the right follow-up question is always: "On what data?" If the answer is "on the training set," the number tells you almost nothing about real-world performance. If the answer is "on a held-out test set," that is meaningful - provided the test set was not leaked into training.
Any time you see performance numbers that seem suspiciously high, overfitting is one of the first hypotheses to check.
Common Misunderstandings
"More data always prevents overfitting." More data helps, but it is not a guarantee. A very complex model can still overfit even on large datasets, especially if the data has limited variety.
"Overfitting means the model is broken." Overfitting is a predictable training failure mode, not a bug in the code. It is something to measure for, diagnose, and correct through standard techniques.
"If training accuracy is high, the model is good." Training accuracy is the least interesting metric. What matters is how the model performs on data it has never seen.
What to Explore Next
/posts/cross-validation-and-model-selection- the standard technique for measuring generalization across multiple splits of your data/posts/what-is-training-data- understanding your data source is inseparable from understanding overfitting/posts/regularization-explained- a deeper look at L1, L2, dropout, and when each applies
Stay in the loop
Get new ML/AI lessons in your inbox.
No account needed. We will send curriculum updates, launch notes, and practical learning resources.
Related Posts
More postsAI Agents: What They Are, What They Can Do, and How They Go Wrong
An agent is an AI that takes actions, not just answers questions. That changes what safe use looks like. Learn in plain English what agents are, how they connect to your tools, why they can be tricked by what they read, and the one question to ask before letting one act for you.
Capstone: Build, Document, and Present an AI-Powered Project
The capstone brings everything together. You will build a real AI-powered project, evaluate it systematically, document it clearly, and present it to a non-technical audience.
Career Paths Into AI (Technical and Non-Technical)
Map the AI-related roles, what each one expects, and which next step fits your current background.