beginneradvanced-ml

Naive Bayes

A fast, surprisingly effective classifier built on one bold, 'naive' assumption.

Key Points

What it is

Naive Bayes is a probabilistic classifier based on Bayes' Theorem that assumes every feature is independent of every other feature given the class — an assumption that's almost never fully true in reality, hence 'naive.' Despite this, it works remarkably well, especially for text classification.

Why it exists

Computing the true joint probability of many correlated features given a class is often computationally intractable. Naive Bayes exists as a pragmatic shortcut: assume independence, multiply individual feature probabilities together, and accept the approximation — in practice this trade-off pays off far more often than the 'naive' name suggests.

Intuition

To guess if an email is spam, Naive Bayes doesn't try to understand the whole sentence structure. It just asks: 'Given this is spam, how likely is the word free to appear? How likely is win? How likely is click here?' It multiplies those individual likelihoods together, ignoring that these words often appear together for a reason — and yet the shortcut works well enough to flag spam reliably.

Formulas

Bayes' Theorem for Classification

P(y∣x1,...,xn)∝P(y)∏i=1nP(xi∣y)P(y|x_1,...,x_n) \propto P(y)\prod_{i=1}^{n}P(x_i|y)
  • P(y) — Prior probability of the class before seeing any features
  • P(x_i|y) — Probability of feature i occurring given the class — assumed independent across features
  • P(y|x_1,...,x_n) — Posterior probability of the class given all observed features

When to use

When not to use

Common mistakes

In practice

A long-standing baseline for spam detection, sentiment analysis, and document classification — valued for being fast to train, easy to update online, and surprisingly competitive despite its simplicity.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

logistic-regressionconfusion-matrix
Chirp at me!