What is Bayes' theorem?
Bayes' theorem is a rule for updating the probability of a hypothesis after seeing evidence. It states P(H|E) = P(E|H) × P(H) / P(E): the posterior equals the likelihood of the evidence under the hypothesis, times the prior, divided by the overall probability of the evidence. It follows in one line from the definition of conditional probability.
In machine learning, Bayes' theorem is the basis of Naive Bayes classifiers for spam filtering and text classification, of MAP estimation, where a prior on the weights acts as a regularizer, and of Bayesian optimization for hyperparameter search. A classifier that outputs calibrated class probabilities is estimating the posterior P(class | input) that the theorem describes.
Key ideas
- The posterior is proportional to likelihood × prior; P(E) only rescales it so the probabilities sum to 1.
- A prior of exactly 0 or 1 cannot be moved by any evidence.
- The likelihood ratio P(E|H) / P(E|¬H) measures how strongly evidence favors H over ¬H.
- In odds form, posterior odds = prior odds × likelihood ratio.
- Updates chain: each posterior becomes the prior for the next piece of evidence.
- A Naive Bayes classifier picks the class with the largest likelihood × prior.
Common questions
How is Bayes' theorem derived?
Write the joint probability of H and E in two ways: P(H and E) = P(H|E) × P(E) = P(E|H) × P(H). Dividing both sides by P(E) gives Bayes' theorem. Nothing beyond the definition of conditional probability is needed.
What is a conjugate prior?
A conjugate prior is one that gives a posterior from the same family of distributions, so the update reduces to changing a few numbers. The standard example is a Beta(a, b) prior on a coin's heads probability: after k heads in n flips, the posterior is Beta(a + k, b + n − k). Conjugate pairs let you do exact Bayesian updates without numerical integration.
How is Bayes' theorem used in machine learning?
Naive Bayes classifiers apply it directly to pick a class from word counts or other features. MAP estimation maximizes likelihood × prior over a model's parameters, and a Gaussian prior on the weights gives L2 regularization. Bayesian neural networks and Bayesian optimization keep a full posterior over parameters or over an unknown function and use it to measure uncertainty.
Who discovered Bayes' theorem?
Thomas Bayes, an English minister, worked out a special case. Richard Price edited his notes and published them in 1763, two years after Bayes died. Pierre-Simon Laplace reached the result independently in 1774 and developed it into the general form used today.
Related explainers
- Probability & Distributions — Spam, densities, and the math of uncertainty
- Naive Bayes Classifier — Probabilistic classification with Bayes' rule
- MLE & MAP Estimation — Maximum likelihood and maximum a posteriori — why training works
- Statistics Essentials — Mean, variance, standard deviation, and the Central Limit Theorem
- Hypothesis Testing — Make principled decisions from data using null hypotheses, p-values, and significance levels
- Entropy & Cross-Entropy — Measuring surprise, uncertainty, and prediction quality
References
- Bayes & Price (1763), "An Essay towards Solving a Problem in the Doctrine of Chances", Philosophical Transactions of the Royal Society
- Bishop (2006), "Pattern Recognition and Machine Learning", chapters 1–2
- Goodfellow, Bengio & Courville (2016), "Deep Learning", chapter 3: Probability and Information Theory
Last updated