Bayes' rule plus a deliberately naive independence assumption: start from each class's prior, multiply in each clue's likelihood, pick the highest posterior.
Naive Bayes is a fast probabilistic classifier — the classic spam filter — built on Bayes' rule. It starts from how common each class is, multiplies in how telltale each clue (each word) is for that class, and picks the class with the highest result. The 'naive' part is assuming the clues are independent, which is rarely true but works surprisingly well.
We want the posterior P(class | clues) — the probability of a class given the evidence. Bayes' rule rewrites it using things we can count from training data: the prior P(class) (how common the class is) and the likelihood P(clue | class) (how telltale each clue is).
P(class | clues) ∝ P(class) · P(clue1|class) · P(clue2|class) · ...
[ prior ] [ ------ likelihoods ------ ]Suppose 40% of mail is spam: prior P(spam) = 0.4, P(ham) = 0.6. From training, the word 'free' appears in 30% of spam but only 2% of ham. An email containing 'free':
spam score = P(spam)*P('free'|spam) = 0.4 * 0.30 = 0.120
ham score = P(ham )*P('free'|ham ) = 0.6 * 0.02 = 0.012
0.120 > 0.012 => classify as SPAM
(normalized: P(spam|'free') = 0.120 / 0.132 = 0.91)log P(class) + sum of log P(clue|class). Sums are numerically stable, and the class with the largest log-score is still the winner.