Part I's Bayes' rule updated a belief given one piece of evidence. What happens with several pieces of evidence at once — and what's the cheapest possible assumption that makes combining them tractable?
Six training messages, three spam, three not. Toggle smoothing on a new message containing "free" and "money" — both toggles predict spam, but look at how confident each one is. One of them is lying about how sure it should be.
Naive Bayes multiplies Bayes' rule across every feature, assuming they're independent given the class — the "naive" part:
- class — the category being predicted, such as spam or not-spam.
- — the individual pieces of evidence, such as which words are present.
- — the prior probability of the class, before looking at any evidence.
- — the likelihood of feature : how often it shows up in training examples of that class.
- — the number of features being combined.
- Each likelihood is just a frequency
is how often word showed up in training messages of that class — a simple count, nothing more elaborate.
- Independence turns a hard problem into easy ones
Multiplying independent probabilities together is exactly what "assume independence" means — it's the one assumption that turns a hard joint-probability problem into a handful of easy word-counting ones.
Build a message by toggling which words are present. "Meeting" alone should pull hard toward not-spam; "free" alone pulls the other way. Watch how the posterior shifts as you add or remove one piece of evidence at a time — each word's presence (or absence) multiplies in independently.
"Free" never appears in any of the three not-spam training messages:
- The zero-frequency problem
exactly. For a message containing "free," this makes the entire not-spam probability collapse to precisely — not small, not unlikely, but mathematically impossible — purely because of one gap in a tiny training set.
- Laplace smoothing patches it
Add one fake "seen" and one fake "not seen" example to every count: . Never exactly zero again, no matter how sparse the training data.
- Same prediction, honest confidence
For "free, money" (meeting absent), each class's unnormalized score is its prior times :
Unsmoothed:
- Spam:
- Not spam: — the zero-frequency word forces the whole product to
Normalizing: spam , not spam — absolute certainty from one missing example.
Smoothed:
- Spam:
- Not spam:
Normalizing: spam , not spam — the same correct prediction, but at a far more reasonable confidence.
Find the setting where the model claims more than 99% certainty — from a single missing training example, not real evidence.
The independence assumption is almost always technically false — whether an email says "free" and whether it says "money" are not really independent — and naive Bayes works remarkably well anyway, because getting the relative ranking between classes right matters far more than getting the exact probabilities right. Laplace smoothing isn't a minor implementation detail; without it, any word that happens to be missing from one class's tiny training set can make an entire prediction mathematically impossible, forever.