Same model, same messages, and the score moves by a point and a half.
Nothing changed except which slice of the data was held out. On close comparisons that wobble is bigger than the gap you are trying to measure, so the single number in the report picks the wrong winner. You get one slice. Call it anyway.
- Score
- 0
- Right
- 0
- Streak
- ×0
- Round
- 1/5
Two spam filters, one slice neither trained on. Call which comes out ahead before the numbers land.Two spam filters are being marked on one slice of the corpus that neither of them trained on. Call which one comes out ahead on this slice, before either number lands.
Slice 3 of 10 · about 558 messages held out
Right. The same model, on five hundred examples is better on average, by 0.72 points. And the slice you were shown pointed the other way.
1 of the 10 slices disagree with the average on this pair. A gap of 0.72 points is smaller than the slice-to-slice wobble, which is what makes a single number useless here.
Hold out one block of messages, train on the other nine, and score. That is the number everybody reports, and this is what it looks like: one dot.
Loading the folds…
A single score has a wobble, and nobody prints it.
NextFrom a line to a probability+What is actually going onWhy ten folds, and not two, or a hundred?Because it is the cheapest count that keeps both kinds of error small, which is roughly what Kohavi found.
Two folds means every model trains on only half the data, so the scores come out pessimistic. A hundred folds means a hundred trainings for very little extra steadiness, and each held-out block is so small that individual scores are wild even though their average is fine.
Kohavi tested this directly and ten came out as the practical answer for datasets of ordinary size. It is a convention with a reason behind it rather than a law, and for very small datasets people go further and hold out one example at a time.
The cost is real: ten folds means training ten times. That is nothing here and it is a serious decision when a training run takes a week, which is why large models are usually judged on a single held-out set and quoted with more caution than they deserve.
+What is actually going onCan I use cross-validation to choose the model and then report its score?Not the same score. Choosing with a number spends it, and what you have left is an optimistic estimate.
If you try twenty models and keep the one with the best cross-validated accuracy, that best score is partly a measure of which model got lucky across those folds. Report it and you are quoting a maximum of twenty draws as though it were a typical one.
The standard fix is a third slice that is never used for choosing: train, tune against a validation set or by cross-validation, and only at the very end score once on a test set that has been untouched. Hastie and colleagues are blunt about how often this is got wrong in practice.
The same trap in a smaller form is on this page: the folds here are reused across seven models, which is fine for showing the spread and would not be fine for declaring a winner and quoting its number.
+Go and try this for realAsk for the error bar
Go and try this
Ask for the error bar
Next time somebody shows you a model comparison, ask two questions. How many times was each of these measured, and how much did the number move between runs?
If the answer is once, ask what it would take to run it five times. Usually it is an afternoon.
What to watch for: Whether the gap between the option somebody is recommending and the one they rejected is bigger than the wobble. Very often nobody has checked, and the recommendation rests on noise.
+Check yourselfIt marks itself, and nothing is sent anywhere.
Model A scores 97.3% and model B scores 97.1%, each on its own single split. What follows?
Which of these make a measured accuracy shakier?
Tap an item, then tap where it belongs. Dragging works too.
Sources
- SMS Spam Collection v.1
Almeida, Gómez Hidalgo & Yamakami
The 5,574 messages, cut into ten blocks. Every accuracy on this page is a separate training run scored on the block it did not see.
Free to use with attribution to the authors' 2011 paper
- A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection
Ron Kohavi (IJCAI 1995)
The paper that settled ten folds as the usual answer, and the reasoning about the trade between bias and variance in the estimate itself.
- The Elements of Statistical Learning, second edition
Hastie, Tibshirani & Friedman (Springer, 2009)
Chapter 7 on cross-validation, and the warning about selecting a model with the same data you then quote a score from.