ChoralSoft Learn

Bayes’ rule you can play with

Why a filter that is 95% accurate can still be wrong most of the time it raises an alarm.

Bayes’ rule with a spam filter

A filter flags an email as spam. How likely is it that the email really is spam? The answer depends on how common spam is to begin with, not just on how accurate the filter is. Move the sliders and watch the 1,000 emails below.

Spam, flagged (95)Good mail, flagged (45)Spam, missed (5)Good mail, passed (855)

Of the 140 flagged emails, only 95 are really spam. So when an email is flagged, the chance it is spam is 68%, compared with a prior of 10%.

Bayes’ rule in one line: P(spam | flagged) = P(flagged | spam) × P(spam) ÷ P(flagged), here 95% × 10% ÷ 14% = 68%.

Try a rare prior (1%) with a decent filter: even a 95% sensitive filter with 5% false positives is wrong about most of its flags. This is why base rates matter.

Go deeper

More explainers: Learn hub · Printable cheat sheets · Learning paths