The whole point of machine learning is to do well on data you have not seen yet. A model that scores perfectly on its training examples has proven almost nothing, because storing answers is trivial for a computer. The interesting quantity is not training performance, it is the drop between training performance and performance on fresh data. Keeping that drop small is what “learning” actually means.

The idea

Learning is the ability to generalize from labeled examples to unseen inputs. Memorization, storing the training answers verbatim, is trivial and worthless on its own. The generalization gap, the difference between training error and test error, is the real measure of whether a model learned anything.

Why memorization is not learning

Scott’s course makes the point with a toddler and a cat. A toddler who has seen a fire truck and a toy truck should call a never-seen garbage truck a truck. A cat that recognizes its owner should still recognize them in a photo it has never encountered. In both cases the test is transfer to new instances, not recall of old ones. A lookup table that returns the stored label for a training input and shrugs at everything else has memorized without learning.

For a computer this matters more, not less, because memorizing is so easy. A model with enough capacity can drive its training error to zero by fitting every point, including the noise, which is the failure mode called overfitting.

The generalization gap

Formally, training error is measured on the data the model fit, and generalization error is the expected error on new samples drawn from the same distribution. The gap between them is the generalization gap. A useful model keeps both low; a memorizing model has near-zero training error and a large gap.

You cannot see generalization error directly

True generalization error is over the whole data distribution, which you never fully observe. You estimate it with a held-out test set the model never trained on. The moment the test set leaks into training, the estimate is worthless, because you are back to measuring memorization.

What controls the gap

The gap is governed by the bias-variance tradeoff. Too little model capacity underfits, high error everywhere. Too much capacity overfits, low training error and a wide gap. The sweet spot has enough capacity to capture the real pattern and enough restraint to ignore the noise. Every regularization technique, from weight penalties to dropout and early stopping, exists to push a model back toward that sweet spot when it starts to memorize.

The tell

Training accuracy 99 percent, test accuracy 71 percent is the signature of memorization: the model learned the training set, including its quirks, and did not learn the underlying pattern. Training accuracy 88 percent, test accuracy 85 percent is worse on paper but better in truth, because it generalized.

Sources