11.1 Gaussian Mixture Models

DATA 442/642 · Week 11 · PDF · Slides

Soft clusters as a mixture of Gaussians.

These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.

Figures and notes follow Géron, Hands-On Machine Learning; Deisenroth, Faisal, and Ong, Mathematics for Machine Learning; and Theodoridis.

1. Gaussian mixture models

A GMM says each row was drawn from a mixture of Gaussians whose parameters you do not know.

One Gaussian → one cluster. Clusters look like ellipsoids. They may differ in shape, size, density, and orientation.

Data from a mixture of Gaussians

You see an instance. You do not see which Gaussian wrote it, and you do not know the parameters.


2. The generative story

For each xi, pick a cluster zi among k clusters. The probability of cluster j is its weight ϕj:

P(zi=j)=ϕj.

If zi=j, draw the location from that Gaussian:

xi~𝒩(μj,Σj).

So 𝐗 comes from k Gaussians, each with a weight ϕj, a mean μj, and a covariance Σj. Collect those as θ. The job is to estimate θ from the observed 𝐗.


3. Log-likelihood

The log-likelihood is the log probability of the data and the latent cluster ids under θ:

logp(𝐗,𝐙∣θ)=∑i=1nlogp(xi,zi∣θ)=∑i=1nlog(∑j=1kϕj𝒩(xi∣μj,Σj)).

Maximize this in θ. Expectation-maximization (EM) does it by alternating an E-step and an M-step until the likelihood stops moving.


4. Expectation-maximization

E-step. Soft assignment: probability that point i came from cluster j, given the current θ(t):

γ(t)(zij)=ϕj(t)𝒩(xi∣μj(t),Σj(t))∑j=1kϕj(t)𝒩(xi∣μj(t),Σj(t)).

M-step. Update means, covariances, and weights to fit those responsibilities.

Means:

μj(t+1)=∑i=1nγ(t)(zij)xi∑i=1nγ(t)(zij).

Covariances:

Σj(t+1)=∑i=1nγ(t)(zij)(xi−μj(t+1))(xi−μj(t+1))⊤∑i=1nγ(t)(zij).

Weights:

ϕj(t+1)=∑i=1nγ(t)(zij)n.

Repeat. Each pair of steps raises the likelihood a little. Stop when θ barely changes.

EM iterating on a Gaussian mixture


5. Applications

Image segmentation. Color or texture. Soft membership helps on ambiguous pixels. Lighting and texture can vary; a mixture of Gaussians can still fit the intensities.

Anomaly detection. Model ordinary behavior as a mixture of Gaussians. Deviations are anomalies. Network traffic, transactions, sensors.

Speech. Model features such as Mel-frequency cepstral coefficients (MFCCs). The mixture captures how speech sounds vary; that is a classic acoustic model.


6. Practical notes

Initialization. Random, k-means then covariances, or hierarchical. Try more than one; the start matters.

Singular covariances. High dimension, or too few points per cluster. Add a small constant to the diagonal, or PCA the features first.

How many components. BIC or cross-validation. Score with log-likelihood, silhouette, or clustering purity, as appropriate.

Speed. Training is heavy on large or high-dimensional matrices. Use a solid implementation (scikit-learn, TensorFlow). Mini-batches or parallel work if the matrix is huge.


Practice

  1. A GMM is a soft clustering. What is being mixed?

  2. In the E-step, what is γ(t)(zij)?

  3. Why can two GMM fits on the same data disagree?