MoonSay /Tutorials/Machine Learning Interview #5
Contents
  1. 01Introduction
  2. 02Maximum likelihood
  3. 03Where maximum likelihood fails
  4. 04Bayes’ theorem and the MAP estimate
  5. 05The seesaw
  6. 06A prior is a regularizer
  7. 07Side by side
  8. 08Interview questions and model answers
  9. 09Summary
  10. References

07Side by side: maximum likelihood versus maximum a posteriori

7.1The comparison

Table 2 collects the main facts.

Maximum likelihood (MLE)Maximum a posteriori (MAP)
Maximizesp(D\mid\theta)p(D\mid\theta)\,p(\theta), the posterior mode
Objective\sum_i\log p(x_i\mid\theta)\sum_i\log p(x_i\mid\theta)+\log p(\theta)
Priornone (a flat prior)a choice that must be justified
Small dataoverfits (3 heads in 3: \hat\theta=1)stable, pulled toward the prior (0.8)
Lots of datathe two agreethe two agree
Coinh/n(h+\alpha-1)/(n+\alpha+\beta-2)
Gaussian mean\bar x(m\mu_0+n\bar x)/(m+n)
In practiceleast squares, cross-entropyridge, lasso, add-one smoothing
Reparameterizationinvariantnot invariant
Table 2. Maximum likelihood and MAP compared. Sources: Sections 2–6; Bishop (2006); Murphy (2012).

7.2What MAP still misses

MAP fixes the small-data problem of maximum likelihood, but it is still a single point, and that has three consequences (Murphy, 2012, §5.2.1).

No uncertainty. Three heads in three flips and 300 heads in 375 flips both give MAP 0.8 with a \mathrm{Beta}(2,2) prior, but we are far more certain in the second case. Only the whole posterior shows that.

The mode can be untypical. For skewed posteriors the peak may be far from where most of the probability is. In Example 4 the posterior \mathrm{Beta}(5,2) has its mode at 0.8 but its mean at 5/7=0.714.

It depends on the parameterization. The likelihood is a function of \theta, but the prior and the posterior are densities, and a density changes when we change variables. With a flat prior on \theta and 7 heads in 10 flips, MAP is 0.7. Describe the same coin by its log-odds \phi=\log\frac{\theta}{1-\theta} instead: the same prior has density p(\phi)=\theta(1-\theta) in \phi (the Jacobian d\theta/d\phi), the posterior in \phi is proportional to \theta^8(1-\theta)^4, and its mode corresponds to \theta=8/12=0.667. The maximum likelihood estimate is 0.7 in either description.

A fully Bayesian analysis keeps the whole posterior and averages over it, for example to predict a new observation with p(x_{\mathrm{new}}\mid D)=\int p(x_{\mathrm{new}}\mid\theta)\,p(\theta\mid D)\,d\theta; for the coin with a flat prior this gives Laplace’s rule (11).

7.3Common misconceptions

  • “The likelihood is the probability that the parameter is right.” It is the probability of the data given the parameter, read as a function of the parameter, and it does not integrate to one over \theta (Section 2).
  • “MAP is Bayesian inference.” It uses Bayes’ theorem but reports only the posterior mode; it carries no uncertainty.
  • “A flat prior is uninformative, so MAP with a flat prior is objective.” A prior that is flat in \theta is not flat in \log\frac{\theta}{1-\theta}, and MAP changes with it.
  • “Maximum likelihood estimates are unbiased.” The Gaussian variance estimate is biased by the factor (n-1)/n (Example 2); maximum likelihood is consistent, not unbiased in general.
  • “The MAP estimate is the posterior mean.” Only for symmetric unimodal posteriors such as the Gaussian of Section 5; for \mathrm{Beta}(5,2) they are 0.8 and 0.714.
  • “Priors are subjective, so serious machine learning avoids them.” Every ridge, lasso or smoothing parameter is a prior, and in practice its strength is chosen from data, by cross-validation.