revisiting statistical learning: maximum likelihood and Bayesian estimation
5 min read
·…
tl;dr:reviewing the differences between the two.
Recently, while revisiting statistical machine learning, I found that many concepts had become blurry. I no longer remembered some derivations and principles, so I decided to organize them again, starting with the two major statistical schools: frequentist and Bayesian.
Maximum likelihood estimation (MLE)
The basic idea of maximum likelihood is to find the model parameters that make the observed data most probable.
Principle
- Assume data comes from probability distribution , where is the parameter to estimate.
- Given observations , define the likelihood as .
- Assuming the data is independent and identically distributed (i.i.d.), the joint probability becomes .
- Taking logs simplifies the calculation: .
- Find the parameter that maximizes log likelihood: .
MLE represents the traditional frequentist position: it relies only on data and no prior distribution. With enough samples, its expectation equals the true parameter. With insufficient samples or too many parameters, it can overfit.
Bayesian estimation
Bayesian estimation combines prior knowledge and observed data through Bayes’ theorem to obtain a posterior distribution over parameters.
- is the prior distribution, representing knowledge of before observing data.
- is the likelihood of observing under .
- is the normalizing constant, which is usually not directly important.
- is the posterior distribution after combining the prior and observations.
The posterior can be used in two common ways:
- Maximum a posteriori (MAP): .
- Posterior mean: .
Because it incorporates prior information, Bayesian estimation can perform better than MLE when samples are scarce.
Differences between MLE and Bayesian estimation
| Feature | Maximum likelihood estimation | Bayesian estimation |
|---|---|---|
| Theoretical basis | Frequentist; focuses on observed data | Bayesian; combines prior and data |
| Input | Observed data only | Observed data and prior distribution |
| Objective | Maximize likelihood | Maximize posterior |
| Suitable setting | Large samples; no reliable prior | Small samples; reliable prior available |
| Computational cost | Lower; analytic solutions are often possible | Higher; may need numerical integration or approximation |
| Result | Point estimate | Posterior distribution or point estimate |
A more concrete explanation
Consider tuning a machine-learning model. MLE treats the model parameter as a fixed value and finds the value that maximizes data likelihood. Bayesian estimation treats it as random: it begins with a prior distribution, then uses the data to calculate a posterior.
- In MLE, maximize the log-likelihood directly to find the parameter.
- In Bayesian estimation, suppose weights are centered at zero and normally distributed. That becomes the prior: .
- Bayes’ rule then yields a posterior proportional to the product of the prior and likelihood. Maximizing it gives:
Compared with MLE, MAP differs only by the prior term .
A personal question: do previous batches become priors?
I wondered whether, when training with multiple batches, each batch’s model carries prior knowledge from the previous batch, including its model and data.
The answer is no for MLE. MLE has no prior-probability concept. Parameters are fixed but unknown, and the goal is to maximize likelihood. In mini-batch training, each batch contributes locally to the full-data log likelihood:
Each batch changes the current parameters to improve their fit to observed data, but it does not change any prior assumption about . The model state after one batch is an optimization state, not a dynamically updated prior.
Bayesian estimation explicitly distinguishes prior knowledge from data. After observing a batch, its posterior is:
That posterior can become the prior for the next batch. This sequential posterior-to-prior update is a defining Bayesian property.
An analogy: MLE mini-batch training is like adding numbers in pieces to calculate one total; every batch contributes to the total likelihood. Bayesian learning is a step-by-step belief update, where each batch changes the belief used as the starting point for the next batch.
Empirical risk and structural risk
Introductory statistical learning distinguishes empirical and structural risk. In MLE, empirical risk is the likelihood-based loss minimized on observed data. Structural risk is the regularization term. When a model is a conditional probability distribution, its loss is log loss, and model complexity is represented by the prior probability, maximizing the posterior is structural risk minimization—exactly the MAP formula.
January 24, 2025, Suzhou