ML Systems Lab Open interactive version →
Intermediate 26 min read MLEMAPregularisationBayesian

MLE vs MAP Estimation

Likelihood, log-likelihood, MAP as regularised MLE

You flip a coin 10 times and get 7 heads. What is your best estimate for the probability of heads? The most obvious approach: count. $\hat{p} = 7/10 = 0.7$. This is maximum likelihood estimation — find the parameter $θ$ that makes the observed data most probable. Formally: $\hat{θ}_{MLE} = \argmax_θ P(data|θ) = \argmax_θ θ^7(1-θ)^3$. Take the log, differentiate, set to zero: $\hat{θ}_{MLE} = 0.7$.

Now flip the same coin only 3 times and get 3 heads. MLE gives $\hat{p} = 3/3 = 1.0$ — the coin always lands heads. Obviously wrong. MLE with tiny data is overconfident. The problem is that MLE has no memory of what coins are usually like. It treats every dataset as if the parameters could be anything.

MAP (Maximum A Posteriori) fixes this by adding a prior. Put a $\text{Beta}(2, 2)$ prior over $θ$ — this encodes "probably close to 0.5, but I am not certain." The posterior is $P(θ | data) \propto P(data|θ) \cdot P(θ)$. MAP finds the mode of this posterior. With 3 heads out of 3 flips, MAP gives $\hat{θ}_{MAP} \approx 0.8$ rather than 1.0. The prior pulled the estimate toward sanity.

The prior is not just a Bayesian abstraction. Adding $\log P(θ)$ to the log-likelihood is identical to adding a regularisation term to your loss function. A Gaussian prior $θ sim N(0, τ^2 I)$, combined with a Gaussian-noise likelihood of variance $σ^2$, produces L2 regularisation (Ridge) with $λ = σ^2/τ^2$. A Laplace prior produces L1 regularisation (Lasso). Every time you tuned a regularisation coefficient, you were implicitly choosing a prior distribution over weights.

NOT this. Most people think "MLE is just fitting the data." MLE assumes a specific probabilistic model — a particular likelihood function — and finds the parameters that make the observed data most probable under that model. If your model is wrong (fitting a Gaussian to bimodal data), MLE finds the "best" wrong answer with complete confidence. The model is always right in MLE`s eyes; MLE has no mechanism to doubt the model family. MAP at least has a prior that can pull estimates back from absurdity when data is scarce.

As $n → ∞$, the likelihood dominates and MAP converges to MLE — the data eventually overwhelms any reasonable prior. This means regularisation should shrink as your dataset grows.

Key points

Takeaway

Every regularised model is a MAP estimate. Choosing L2 or L1 is not a numerical trick — it is a statement about what you believe the solution looks like before seeing any data.

Recap

Check your understanding

Q1. For a Gaussian likelihood with unknown mean μ and fixed variance σ², derive the MLE estimate for μ given data {x₁,...,xₙ}.

Q2. MLE for a Bernoulli distribution gives P̂(X=1) = (number of 1s)/(total samples). Now add a Beta(α,β) prior. Which two of the following are correct?

Q3. A linear regression model's MSE loss is equivalent to maximum likelihood under what distributional assumption? What assumption does L1 loss correspond to?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →