The Real Test of Learning
Here is a question that changes everything: what are we actually trying to do?
In the last note, our line fit the house data nicely. But think about it, we already know the prices of the houses we trained on. Predicting those is pointless. The whole reason we built the model is to price houses we have never seen.
The goal was never to do well on the training data. It is to do well on new data. That is called generalization, and it is the only thing that actually matters.
Three Students
Picture three students prepping for an exam with a single practice test.
- The lazy one barely studied. Their rule is far too simple: “when in doubt, guess C.” They bomb the practice test and the real exam. This is underfitting (the model is too simple to capture the pattern).
- The crammer memorized the practice test’s answer key word for word, typos and all. They score 100% on the practice test, then fall apart on the real exam because the questions changed. This is overfitting (the model memorized the training data instead of learning the pattern).
- The good student actually understood the material. They do well on both. This is the sweet spot.
Overfitting is the sneaky one. It looks exactly like success, a perfect score, right up until it meets new data.
Where Complexity Comes From
How does a model “memorize”? It needs enough flexibility to do so.
Our straight line couldn’t memorize anything, it can only be straight. But if we let the model bend, by adding curves (, , and so on), it grows more and more flexible. Push that far enough and the curve can thread its way through every single training point exactly.
That flexibility is called model capacity, and it behaves like a dial:
Turning the dial gives three very different outcomes:
- Too little (a straight line when the data actually curves) → underfitting. It misses the real trend.
- Just right (a gentle curve) → it captures the pattern.
- Too much (a wild, wiggly curve) → overfitting. It nails every training point but swings crazily between them, treating random noise as if it were signal.
The Tell: Training Error vs Test Error
So how do you actually catch overfitting before it embarrasses you? Track two numbers as you turn up the dial.
| Complexity | Training error | Test error (new data) |
|---|---|---|
| Too simple | high | high |
| Just right | low | lowest |
| Too complex | near zero | high again |
- Training error just keeps falling. A wiggly enough curve can hit every training point, all the way down to zero.
- Test error traces a U-shape: it drops as you move from too-simple to good, then climbs back up as you start to overfit.
The bottom of that U is the model you want. Watching training and test error split apart is the core diagnostic in all of machine learning.
Seeing It Fail on New Data
Here is the whole point, side by side. Two models that both fit the training dots, tested on fresh points they’ve never seen:
The overfit model aced the training data. But on new points it lurches all over the place, because it learned the noise, not the trend. The simpler, smoother model, which never scored perfectly on training, quietly wins where it counts.
A perfect training score is not a trophy. It is often a warning.
The Names (We Go Deeper Next Time)
Two bits of vocabulary, worth seeding now:
- Underfitting is also called high bias (the model is too rigid, its built-in assumptions are wrong).
- Overfitting is also called high variance (the model is too twitchy, it swings wildly with the exact training points it happened to see).
Balancing these two is the bias-variance tradeoff, and it earns its own note next.
Why This Is Everywhere
This is not a beginner’s footnote. It is the central struggle of all machine learning, frontier models included. A model with billions of parameters can absolutely memorize its training data. The entire art is forcing it to generalize instead.
Nearly every technique you will meet later, gathering more data, regularization, dropout, exists for one reason: to fight overfitting. Keep this picture close. You will see it again at every scale, from a straight line to a trillion-parameter model.