The same model, on the same day, catching 99% or 69% of the spam.
Nothing about it changed. One number moved, the one nobody in the room thinks of as a decision, and it is worth 30 points of catch rate and 798 wrongly blocked messages. You are told what each mistake costs. Put the line somewhere.
- Score
- 0
- Nailed
- 0
- Streak
- ×0
- Case
- 1/4
A hospital paging system
A blocked message can be a life. A spam getting through wastes a few seconds.
Here, one missed spam costs 1 and one wrongly blocked message costs 60.
What your line did
Caught 155 of 156 spam, missed 1, and wrongly blocked 798 real messages.
Accuracy 28.3% · precision 16.3% · recall 99.4%
What it cost, in this situation
47881 against 14 for the best line anywhere on the curve
That best line is one a team could tune their way to: it catches 142 with 0 false alarms. You were marked against the five choices you were actually offered.
Every dot is one message the model has never seen, placed at the score it gave. Spam above the line, ordinary below. Notice it never said spam or not spam. It said a number, and almost every number is jammed at one end.
Loading the measurements…
Which mistake would you rather make?
NextOverfitting+What is actually going onPrecision and recall, in one sentence each?Precision: of what you flagged, how much was right. Recall: of what was out there, how much you caught.
They answer different questions and they are both about the flagged pile. Precision looks at what you did and asks how much of it was justified. Recall looks at what existed and asks how much you found. A filter that flags one message and gets it right has perfect precision and hopeless recall.
You cannot raise both by moving the line, only trade one for the other, which is why reporting a single number is always a choice about what to hide. Davis and Goadrich make the sharper point that when one class is rare, a precision and recall pair shows problems that other summaries flatter away.
Raising both at once takes a better model, or better features, and that is the only honest way to get it.
+What is actually going onIs there a right threshold, or is it a matter of taste?There is a right one, and it follows from what each mistake costs. Write those two numbers down and the line puts itself.
Elkan set this out plainly: once you say what a false alarm costs and what a miss costs, the optimal decision rule is fixed. It is arithmetic, not judgement. The judgement is entirely in choosing the two costs, and that belongs to whoever lives with the consequences.
Which is why the default of one half is so quietly dangerous. It is not neutral. It is the assumption that a miss and a false alarm cost exactly the same, which is true of almost nothing anybody does.
One caveat worth carrying from this page: on this data, several quite different cost ratios land on the same line, because past a point there are no false alarms left to remove. Optima are often flat, and a threshold that is roughly right is usually fine.
+Go and try this for realWrite down the two costs
Go and try this
Write down the two costs
Take any automated decision near you: a filter, a flag, an alert, an approval. Write down what one wrong flag costs, and what one missed case costs, in the same unit. Money, minutes, or trust.
Then find out where the line actually sits, and who put it there.
What to watch for: Whether anybody can state the ratio. If a team cannot say whether a miss is worth two false alarms or fifty, then nobody has chosen the threshold, and it is sitting at one half by default.
+Check yourselfIt marks itself, and nothing is sent anywhere.
Match each job to what it should be tuned for.
Tap one from the pool, then tap the row it belongs to.
- Screening for a disease, before a cheap confirming test
- Auto-deleting suspected spam with no folder to check
- Flagging transactions for a human reviewer with a queue
A fraud filter reports 99.9% accuracy. Fraud is one transaction in a thousand. What have you learnt?
Sources
- SMS Spam Collection v.1
Almeida, Gómez Hidalgo & Yamakami
The 1,115 held-out messages every dot, count and percentage on this page comes from.
Free to use with attribution to the authors' 2011 paper
- The Relationship Between Precision-Recall and ROC Curves
Davis & Goadrich (ICML 2006)
Why precision and recall are the pair to look at when one class is much rarer than the other, and how misleading the alternative can be.
- The Foundations of Cost-Sensitive Learning
Charles Elkan (IJCAI 2001)
The result the game is built on: the optimal threshold follows directly from what each kind of mistake costs.