The two models that scored a perfect hundred are the two that learned nothing.
One keeps a list of every message it was shown. The other copies whichever message looks most like the new one. Both are flawless on their own training data, and one of them collapses by eleven points the moment it meets a message it has not seen. You are shown only the training scores. Call it.
- Score
- 0
- Right
- 0
- Streak
- ×0
- Pair
- 1/5
Two models, and the only question that counts is how they do on messages neither of them has ever seen. Call the winner first, then both get marked.
Which does better on messages neither has ever seen?
Here is every message you have, in one heap. Hand all of it to a model and you have lost the ability to find out what it knows, because every question you could ask it, it has already been given the answer to.
Loading the results…
A perfect training score is the signature of memorising.
NextAccuracy is a liar+What is actually going onWhy is the training score always flattering?Because the model was allowed to adjust itself until it fitted that particular data, including its accidents.
Any dataset contains the pattern you want plus a great deal of accident: a word that happens to appear in three spam messages and nowhere else, a length that happens to correlate. A model with enough capacity will fit both, because nothing in the training tells them apart.
Hastie and colleagues put this precisely: training error is an optimistic estimate of error on new data, and the gap grows with how much freedom the model had. The lookup table on this page is the extreme case, with enough freedom to fit every accident and no ability to do anything else.
Which is why the locked room has to be locked before you start. A test set you have peeked at, tuned against and re-run twenty times is a training set wearing a different hat.
+What is actually going onWhy eighty and twenty, and does it matter?Because the test set has to be big enough to trust and small enough that you still have data to learn from.
The split here is 80/20, which puts 1,115 messages in the locked room. That is enough that an accuracy measured on it is not mostly noise, and it still leaves 4,459 to learn from.
Make the test set too small and the score swings wildly depending on which messages happened to land in it. Make it too big and the model is starved. There is no correct answer, only a trade, and the next module measures how much the answer moves when you change where the wall goes.
One thing that is not a trade: the split has to be random. Sorting by date, or by anything correlated with the label, and putting the tail in the test set gives you a number about a different problem than the one you have.
+Go and try this for realAsk where the number came from
Go and try this
Ask where the number came from
Find a model somebody in your organisation actually relies on, or a vendor claim about one. Ask two questions: what data was the headline accuracy measured on, and had the model been trained on any of it.
Then ask when that test data was last replaced.
What to watch for: Whether anybody can tell you how many examples the reported score was measured on. If the answer is vague, or the test set was used repeatedly to pick between versions, the number is closer to a training score than anyone involved thinks.
+Check yourselfIt marks itself, and nothing is sent anywhere.
Match each pair of scores to what it tells you.
Tap one from the pool, then tap the row it belongs to.
- 100% studying, 89% locked room
- 99% studying, 99% locked room
- 89% studying, 89% locked room
A colleague reports 100% accuracy on a new model. What is the first thing to ask?
Sources
- SMS Spam Collection v.1
Almeida, Gómez Hidalgo & Yamakami
The 5,574 real messages every model on this page is trained and scored on, split 80/20 with the same seed the rest of the site uses.
Free to use with attribution to the authors' 2011 paper
- Rules of Machine Learning: Best Practices for ML Engineering
Martin Zinkevich, Google
A practitioner's account of measuring models on data they have not seen, and of how easily a team fools itself when it does not.
- The Elements of Statistical Learning, second edition
Hastie, Tibshirani & Friedman (Springer, 2009)
Chapter 7 on model assessment: why training error is an optimistic estimate of what happens next, and how much more optimistic it gets as a model gains capacity to memorise.