Interactive Lab ยท Classification

Where do you draw the line?

Your spam filter scores every email from 0 to 1, how spammy it looks. But a score isn't a decision. You pick a cutoff: flag everything at or above it. Set it low and you catch all the spam but bury real email in the junk folder. Set it high and your inbox stays clean but spam sneaks through. Drag the line and watch the tradeoff.

๐ŸŽฌ Watch the 90-second explainer, then draw the line yourself below โ†“

โ–ถ The playground, drag the threshold

Each dot is one email, placed by its spam score. Red = really spam ยท grey = real email. Everything right of the line is flagged as spam. Drag the line, or the slider below.

0.00 ยท flag everythingflag nothing ยท 1.00
Predicted spamPredicted ham
Actually spam / ham
True Pos
0
spam, caught โœ“
False Neg
0
spam, missed โœ—
False Pos
0
real, junked โœ—
True Neg
0
real, delivered โœ“
Precision
Recall
Accuracy
F1 score
flagged 0 of them real 0 spam missed 0
really spam (8 of 16) real email (8 of 16)

๐Ÿงญ Where this fits

Threshold selection is where ML meets the business: the same model ships with different cutoffs for cancer screening (recall-first) vs fraud blocking (precision-first) vs content moderation (human-review queues in between). The precision/recall trade you just steered is presented on a slide in essentially every model-launch review.

The code that's actually running



  

๐Ÿ”ฎ Predict, then test

You run a hospital's cancer-screening model instead of a spam filter, a miss (false negative) is deadly, a false alarm just means one more test. Which way do you push the threshold, and which metric do you optimize? Now flip it: a bank auto-blocking credit cards on a fraud score, where a false alarm strands a real customer at the checkout. Drag the line to 0.15 and then 0.85 here and read precision vs recall at each, which business would live at which end?

The takeaway

Your new mental model of the threshold