ElemedexA pocket encyclopedia of AI architectures

Glossary (TM) › Minimal mathematics

TM034

Bayes' theorem

Also: Bayes' rule

In Spanish: Teorema de Bayes

A rule that inverts a conditional probability: it computes P(hypothesis | evidence) from P(evidence | hypothesis) and the prior probability of the hypothesis.

The theorem says: P(H | E) = P(E | H) · P(H) / P(E). P(H) is the prior probability of the hypothesis; P(E | H), the likelihood of the evidence if the hypothesis were true; P(H | E), the posterior probability, what one should believe after seeing E. It follows in one line from conditional probability: since P(E | H) · P(H) = P(H | E) · P(E), just rearrange (Witten et al., 2017, pp. 98, 337).

Tiny example. 20% of emails are spam; the word “free” appears in half of the spam and in 5% of the rest. Then P(free) = 0.5 · 0.2 + 0.05 · 0.8 = 0.14, and P(spam | free) = (0.5 · 0.2) / 0.14 ≈ 0.71. The evidence raised the probability from 0.20 to 0.71, but not to 1: the prior still carries weight.

The Naive Bayes classifier applies this rule to many cues at once. It assumes, “naively”, that the cues are independent given the class, so it can simply multiply their probabilities; the assumption is almost never true and yet the method works surprisingly well on real data (Witten et al., 2017, pp. 96–99). It was among the first techniques applied to classifying documents by their content (Maron, 1961). The same framework justifies smoothing techniques: treating parameters as if they had prior distributions that the data update prevents, for instance, a never-seen word from wiping out the whole calculation with a zero (Witten et al., 2017, pp. 99–100).

For epistemology it is the core of Bayesianism, a theory of how to update graded beliefs in light of evidence; and a well-documented human error is precisely to ignore the base rate, the prior. It pays not to conflate levels: a machine-learning system that uses Bayes' rule is not thereby a Bayesian agent, and a neural network behaving as if it updated beliefs does not show that it computes with them.

Sources