Contents
Maximum Likelihood vs Maximum a PosterioriMLE vs MAP
Bayes’ theorem, imaginary data and why a prior is a regularizer
A tutorial companion to the video Machine Learning Interview #5: Maximum Likelihood vs Maximum a Posteriori (MLE vs MAP) PDF
01Introduction
1.1The question
“What is the difference between MLE and MAP?” is a classic machine learning interview question. Here is a puzzle that contains the whole answer. Restaurant A has one review: five stars. Restaurant B has two thousand reviews, averaging 4.7 stars. Which one is better? Most people pick B, and that instinct is exactly the difference. Maximum likelihood trusts only the data, so A wins with a perfect 5.0. Maximum a posteriori also uses what we knew before: most restaurants are not perfect, and one review is not much evidence. This tutorial turns that instinct into formulas.
1.2Prerequisites and notation
Prerequisites. Derivatives and logarithms; sums and products; basic probability (conditional probability, independence, the normal distribution); vectors and matrices for Section 6.
Notation. The data are D=\{x_1,\dots,x_n\}, assumed independent and identically distributed (i.i.d.) given a parameter \theta. We write p(x\mid\theta) for the model, p(\theta) for the prior, p(\theta\mid D) for the posterior, and \log for the natural logarithm. For a coin, \theta is the probability of heads, and h is the number of heads in n flips.
1.3A short history
The idea of reasoning backwards from data to causes, inverse probability, goes back to Thomas Bayes, whose essay was published after his death by Richard Price (Bayes and Price, 1763), and to Pierre-Simon Laplace, who developed it independently in 1774 (Stigler, 1986) and later used it to ask whether the sun will rise tomorrow (Laplace, 1902). Ronald A. Fisher found the principle of maximum likelihood as a student in 1912, named it in 1922 and built the theory of estimation on it (Fisher, 1922; Aldrich, 1997), deliberately avoiding priors. Today both ideas live side by side in machine learning: most training objectives are likelihoods, and most regularizers are priors (Bishop, 2006, §1.2).