Naive Bayes Explained: 1 Wrong Assumption That Works

⚡ TL;DR: Naive Bayes multiplies together the probability of each feature given each class, and picks the class that wins. It assumes features are independent — which is almost always false — and works remarkably well regardless.

Naive Bayes is the fastest useful classifier you will meet, trains in a single pass over the data, and remains a genuinely strong baseline for text. It is also the one whose central assumption is openly wrong, which makes it interesting.

How Naive Bayes decides

Naive Bayes diagram comparing word probabilities for spam and non-spam, with the multiplied likelihoods favouring spam
Each word contributes a probability. Multiply them, compare the totals, take the larger.

Bayes’ theorem, in the form the classifier uses:

$$P(\text{class} \mid \text{features}) \propto P(\text{class}) \times \prod_i P(\text{feature}_i \mid \text{class})$$

✅ In words: start with how common the class is at all (the prior), then multiply in how likely each observed feature would be if that class were true (the likelihoods). Do this for every class and pick the largest. Training is just counting frequencies — which is why it is so fast.

What “naive” means

The naivety is one specific assumption: every feature is independent of every other, given the class.

For text, that says the word “New” tells you nothing about whether “York” follows. Obviously false. Words are deeply dependent on each other.

🧪 Why a false assumption still classifies well

Because you only need the ranking to be right, not the probabilities.

Correlated features get double-counted, so the winning class often ends up with a probability like 0.9999 when the truth is nearer 0.75. The number is badly wrong — but it is still the largest number, so the prediction is still correct.

The practical consequence: trust Naive Bayes for the class it picks, never for the confidence it reports. If you need calibrated probabilities, use logistic regression instead.

The zero-frequency problem

Multiplication has a brutal failure mode. If a word never appeared in the spam training examples, its likelihood is zero — and zero times anything is zero. One unseen word vetoes the entire class, no matter how damning everything else was.

The fix is Laplace smoothing: add 1 to every count. Nothing is ever exactly zero, so no single feature can veto a class. It is one line, and it is essential rather than optional.

Which variant to use

VariantForExample
MultinomialCountsText classification — the usual choice
BernoulliPresent / absentShort documents where occurrence matters more than count
GaussianContinuous numbersMeasurements — assumes each is bell-shaped per class

Where it genuinely shines

Text, above all: spam filtering, sentiment, topic labelling. High-dimensional sparse data is exactly where the independence assumption does least damage, and where the speed matters most.

Small datasets, because estimating a few frequencies needs far less data than fitting a flexible model.

As a baseline. It trains in seconds. If your elaborate model cannot beat Naive Bayes, that is worth knowing early.

Where it fails

⚠️ Three real limits

  • Probabilities are not trustworthy. Correlated features inflate confidence badly.
  • Strongly dependent features hurt it. Duplicate a column and that evidence counts twice.
  • It cannot learn interactions. “A only matters when B is also present” is unrepresentable — features vote separately by construction. Trees and boosting handle that; Naive Bayes cannot.

It also needs no feature scaling, since it works with probabilities rather than distances — a small convenience worth knowing.

🔑 Key Takeaways

  • Naive Bayes multiplies the prior by each feature’s likelihood and picks the biggest result.
  • Training is counting frequencies, so it is extremely fast and works on small data.
  • The independence assumption is false but usually harmless — the ranking survives.
  • Its probabilities are unreliable; trust the class, not the confidence.
  • Always use Laplace smoothing, or one unseen feature zeroes out a whole class.

Further reading

scikit-learn’s Naive Bayes guide documents all three variants and the smoothing parameter, and Wikipedia’s article works through the spam-filtering derivation in full.

Where to go next

Scroll to Top