Probabilistic Models for Machine Learning
modeling data distributions, inference techniques, and generative learning frameworks
Core Concepts Covered
- MLE, MAP, conjugate Beta priors, and posterior summaries
- Bayesian networks, conditional inference, latent variables, KL divergence, and the ELBO
- GMM soft assignments, EM parameter updates, covariance structures, and BIC
1. MLE, MAP, and Prior Information
A probabilistic model assigns a likelihood to observed data under parameters . For independent observations, the likelihood is a product, and the log-likelihood turns that product into a sum:
Maximum Likelihood Estimation (MLE) chooses the parameter that best explains the observed data: For heads and tails from a Bernoulli coin, and .
Maximum A Posteriori (MAP) combines the likelihood with a prior . Bayes' rule gives and the evidence can be ignored when optimizing with respect to :
A Beta prior is conjugate to a Bernoulli likelihood. If , then observing heads and tails gives The posterior mean is , while the interior posterior mode is .
A Gaussian prior centered at zero adds a quadratic penalty to the negative log-posterior. This is the probabilistic reason MAP estimation often looks like regularization: the data term pulls toward a good fit, while the prior shrinks implausibly large parameters.
Update a Coin Probability with a Beta Prior
A coin produces heads and tails. Compare MLE with a prior's posterior mean and MAP estimate.
1.MLE uses only the observations: .
2.The posterior is .
Its mean is , and its MAP estimate is .
The prior pulls both posterior summaries away from the extreme data-only estimate, while the influence of that prior weakens as more observations arrive.
See Gaussian-Prior Shrinkage Directly
Without a prior, minimize . Then add the Gaussian-prior penalty and find the MAP estimate.
1.The data-only derivative is , so the MLE is .
2.The MAP objective is .
Its derivative is . Setting it to zero gives .
The prior contributes a real term to the objective, so MAP trades some data fit for a parameter value closer to the prior center.
2. Bayesian Networks and Conditional Inference
A Bayesian Network is a directed acyclic graph whose nodes are random variables and whose arrows encode direct conditional dependence. The graph factorizes a large joint distribution into smaller local pieces:
The missing arrows carry information too. Once a node's parents are known, the node is conditionally independent of its non-descendants. These independencies reduce how many probabilities the model must store and which terms an inference calculation must inspect.
Inference reverses or fills in parts of the graph. For a hypothesis and evidence , normalize the joint probability over all competing hypotheses:
Interpret a Positive Diagnostic Result
A disease affects of a population. A test has sensitivity and a false-positive rate. What is ?
1.The true-positive joint probability is .
2.The false-positive joint probability is , so .
, or about .
A positive result raises the probability sharply, but the low prior prevalence means false positives still outnumber true positives.
3. Latent Variables and Variational Inference
A latent variable is not observed directly but helps explain an observed variable . To obtain the probability of , sum over a discrete latent state or integrate over a continuous one:
Exact Bayesian inference asks for . The denominator can require an enormous sum or integral, so Variational Inference (VI) chooses a tractable approximation and fits it to the true posterior.
Unit 12 introduced KL divergence as a measure of how one distribution differs from another. Here it becomes an optimization target:
Because the true posterior contains the difficult evidence , VI maximizes the Evidence Lower Bound (ELBO) instead: The identity shows that maximizing the ELBO closes the non-negative KL gap.
Unit 21 applies this machinery to Variational Autoencoders, where an encoder supplies and a decoder supplies . This unit focuses on the inference calculation underneath that architecture.
Marginalize a Two-State Latent Variable
For one observation , suppose and . Find and the posterior probabilities of the two latent states.
1.Marginalize the hidden state: .
2..
.
Posterior probabilities are normalized joint probabilities, and marginalization supplies the normalizing evidence.
Calculate an ELBO and Its KL Gap
Suppose , , and . Find the ELBO and .
1..
2.Using , the gap is .
Thus , and the ELBO sits below the log evidence.
A tighter approximation has a smaller KL gap and an ELBO closer to .
4. Gaussian Mixture Models and Expectation-Maximization
Unit 14 introduced Gaussian Mixture Models (GMMs) as an unsupervised-learning method. K-Means gives each point one hard cluster label. A GMM instead models a probability density and assigns soft membership across Gaussian components:
The unobserved component label is a latent variable. Given current parameters, the E-step computes its posterior probability, called a responsibility:
The M-step treats responsibilities as fractional counts. With , the updates are
The covariance structure controls each component's geometry. full learns a complete covariance matrix per component, tied shares one complete matrix, diag learns one variance per feature without correlations, and spherical learns one variance per component. Flexible choices need more data and can produce nearly singular covariance matrices, so use regularization and inspect component counts.
Each EM iteration does not decrease the observed-data log-likelihood but EM can settle at a local optimum. Multiple initializations, covariance regularization, and checks for nearly empty components reduce common failures.
More components almost always improve training likelihood, so model selection must penalize complexity. The Bayesian Information Criterion is where is the number of fitted parameters. Lower BIC is preferred among models fitted to the same dataset.
Compute a GMM E-Step Responsibility
At , component 1 has , , , and density . Component 2 has , , , and density . Find both responsibilities.
1.The weighted densities are and .
2.Their sum is , so .
, and the responsibilities sum to .
A responsibility combines component fit with the component's prior mixture weight.
Carry Out a One-Component M-Step
For observations , component 1 has responsibilities . Update its effective count, mixture weight, mean, and one-dimensional variance.
1., so with , .
2..
.
Responsibilities act like fractional observations when EM recomputes each component.
Choose Between Two GMMs with BIC
Two models fit observations. Model A has parameters and ; Model B has and . Calculate both BIC values.
1..
2..
Model A is preferred because , even though Model B has the better raw likelihood.
BIC accepts extra parameters only when their likelihood improvement is large enough to offset the complexity penalty.
Interactive Practice Quiz
Test your understanding with instant feedback
What is the primary difference between Maximum Likelihood Estimation (MLE) and Maximum A Posteriori (MAP)?
In a Bayesian Network, how do we factorize the joint probability of variables compactly?
What is a 'Latent Variable' in probabilistic modeling?
Which of the following describes the objective of the 'Expectation' (E-step) inside the EM algorithm?
What is the role of the 'Maximization' (M-step) inside the EM algorithm?
After observing heads and tails with a prior, what is the posterior distribution?
A disease has prevalence . A test has sensitivity and false-positive rate . Approximately what is ?
If and the ELBO is , what is ?
For one GMM observation, the two latent component states have joint probabilities and . After marginalizing , what are their responsibilities?
Model A has and Model B has . Which model does BIC select?
Further Readings
Explore these highly recommended external references to deepen your understanding
