Skip to main content
Open In Colab

title: Maximum Likelihood Estimation of a marginal model sidebar: sidebar-foundations

Most of the models in supervised machine learning are estimated using the ML principle. In this section we introduce the principle and outline the objective function of the ML estimator that has wide applicability in many learning tasks. Assume that we have mm examples drawn from a data generator that generates the vectors x∈X\mathbf{x} \in \mathcal{X} independently and identically distributed (i.i.d.) according to some unknown (but fixed) probability distribution function pdata(x)p_{data}(\mathbf{x}). X={x1,…,xm}\mathbb{X} = \{ \mathbf{x}_1, \dots, \mathbf{x}_m \} Let pmodel(x,w)p_{model}(\mathbf x, \mathbf w) a parametric family of probability distributions (our hypothesis set) over the same space that attempts to approximate (model) pdata(x)p_{data}(\mathbf{x}) as closely as possible using a suitable estimate of the parameter vector w\mathbf w. The ML estimator for w\mathbf w is defined as: wML=arg⁡max⁡wpmodel(X;w)\mathbf w_{ML} = \arg\max_{\mathbf w} p_{model}(\mathbb X; \mathbf w) =arg⁡max⁡w∏i=1mpmodel(x(i);w) = \arg\max_{\mathbf w} \prod_{i=1}^m p_{model}(\mathbf x^{(i)}; \mathbf w) =arg⁡max⁡w∑i=1mlog⁡pmodel(x(i);w) = \arg\max_{\mathbf w} \sum_{i=1}^m \log p_{model}(\mathbf x^{(i)}; \mathbf w) =arg⁡max⁡w1m∑i=1mlog⁡pmodel(x(i);w) = \arg\max_{\mathbf w} \frac{1}{m} \sum_{i=1}^m \log p_{model}(\mathbf x^{(i)}; \mathbf w) =arg⁡max⁡wEx∼p^datalog⁡pmodel(x;w) = \arg\max_{\mathbf w} \mathbb{E}_{\mathbf{x} \sim \hat p_{data}} \log p_{model}(\mathbf x; \mathbf w) From the last expression it is evident that in ML estimation two distributions are involved: p^data\hat p_{data} and pmodelp_{model}. We can also make use of our intuition that a good estimator would minimize the distance between the two empirical distributions therefore the KL divergence: KL(p^data∣∣pmodel)=Ex∼p^data[log⁡p^data(x)−log⁡pmodel(x,w)]KL( \hat p_{data} || p_{model} ) = \mathbb{E}_{\mathbf x \sim \hat p_{data}} [\log \hat p_{data}(\mathbf x) - \log p_{model}(\mathbf x, \mathbf w) ] The 1st term is independent of the model and therefore we see that the KL and the ML estimator expressions are identical except from the sign. Therefore we conclude that minimizing KL divergence, maximizes the likelihood function. From information theory we know that the KL divergence and the cross entropy (CE) are related via the expression CE=H(p^data,pmodel)=KL(p^data∣∣pmodel)+H(p^data)CE = H(\hat p_{data}, p_{model}) = KL( \hat p_{data} || p_{model} ) + H(\hat p_{data}) Given that p^data\hat p_{data} is given in supervised learning, H(p^data)H(\hat p_{data}) is constant and therefore we can conclude that in this case, CE is equivalent to the KL i.e. minimizing the KL divergence, is equivalent in minimizing cross-entropy (CE). Therefore the expression the only need to minimize which we will call the CE cost function (also known as log loss) is: L(w)=CE=−Ex∼p^datalog⁡pmodel(x,w) L(\mathbf w) = CE = - \mathbb{E_{\mathbf x \sim \hat p_{data}}} \log p_{model}(\mathbf x, \mathbf w) Cross entropy is a very generic objective (loss) function that is applicable to any supervised learning problem that uses maximum likelihood to estimate a model. To visualize the above, lets start with a simple Gaussian distribution.
Output from cell 1 We can retrieve the probability of events happening, e.g. x=3.0
We can also easily calculate the joint probability of iid (indepenent and identically distributed) events
Assume now that someone is giving us an array of values and ask us to estimate a pmodelp_{model} that is a ‘good fit’ to the gievn data. How we can go about solving this problem with Maximum Likelihood Estimation (MLE)? Notice that as addressed in [3], probability and likelihood have a reverse relationship. Probability attaches to possible results; likelihood attaches to hypotheses. The likelihood function gives the relative likelihoods of different values for the parameter(s) of the distribution from which the data are assumed to have been drawn, given those data. Lets plot a couple of pmodelp_{model} hypotheses - the data are shown below in the same plot. Both hypotheses are plausible.
Output from cell 4 As detailed in Ref [2], its important to safeguard against underflow that may well result from multiplying many numbers (for large datasets) that are less than 1.0 (probabilities). So we do the calculations in the log domain using the identity log(a×b)=log(a)+log(b)log(a \times b)=log(a) + log(b) Lets look at a function that calculates the log-likelihood for the two hypotheses above given the data denoted by xx.
We can readily compate the two hypotheses according to the maximum likelihood criterion. Note that because the loglog is a monotonic function, the conclusion as to which hypothesis makes the data more likely is the same in the natural or the loglog domain.
It seems that the second hypothesis pmodel(x∣w)=N(x∣[μ2,σ22])p_{model}(x|\mathbf{w}) = N(x | [\mu_2, \sigma_2^2]) is preferred compared to the first. We can now start searching the hypothesis space (parameter space) for the best parameter set w\mathbf w.
Output from cell 7 But there is a better method than exhaustively searching in the parameter space. We developed a method that incrementally minimizes a loss function that is ultimately linked to the concept of entropy - the cross entropy (CE) that for the supervided learning problem as shown in the notes has a lot to do with minimizing the KL divergence - a type of probabilistic ‘distance’ between p^data\hat p_{data} and pmodelp_{model}. This method is the Stochastic Gradient Descent as described in another section.

References

  1. Maximum Likelihood Estimation of Gaussian Parameters - The math are not renferred properly so you can find this important reference in a notebook in the course site.
  2. Section 4.1 - Numerical computation
  3. Bayes for beginners - probability and likelihood

Found an error on this page? Report an issue.