Gaussian Mixture Models

Clusters as overlapping distributions rather than hard groups, fitted by alternating between guessing and re-estimating.

Gaussian Mixture Models

This module needs JavaScript: the numbers are computed in the page rather than recorded.

Worth knowing

A GMM assumes the data came from several Gaussians mixed together, and fits their means, widths and weights.
Each point gets a probability of belonging to each component, not a single label.
EM alternates: given the current parameters, compute responsibilities; given responsibilities, re-estimate the parameters.
K-means is the special case where every component is spherical, equally sized, and every responsibility is 0 or 1.

Overview

K-means assigns each point to one cluster. A Gaussian mixture model (GMM) instead estimates how likely each component is to have generated each point. This soft assignment preserves uncertainty, but assumes the data can be represented by a mixture of Gaussian distributions.

In this guide
  1. The mixture model
  2. How EM fits the model
  3. Where GMMs differ from K-means
  4. Limits and common mistakes

The mixture model

A GMM with K components has a mean μₖ, covariance Σₖ and mixture weight πₖ for each component. The weights are non-negative and sum to one. Its density is:

p(x) = Σₖ πₖ 𝒩(x | μₖ, Σₖ)

The covariance controls each component’s shape and orientation. A full covariance can describe an ellipse; a spherical covariance restricts the component to a circle or sphere. The point’s responsibility rₖ is the posterior probability that component k generated it.

How EM fits the model

Expectation–Maximisation alternates two steps. In the E-step, compute each point’s responsibility under the current component parameters. In the M-step, update the means, covariances and weights using those responsibilities. Repeat until the log-likelihood stops improving meaningfully.

For two one-dimensional components, N(0, 1) with weight 0.6 and N(3, 1) with weight 0.4, the responsibility for component one is about 0.97 at x = 0.5 and 0.60 at x = 1.5. The midpoint remains uncertain rather than being forced into a hard cluster. The visualiser shows the same pattern as you change Overlap of the two groups and step through EM iterations.

EM does not promise the global best fit. It can converge to a local optimum that depends on its initial parameters, so fit from multiple starts and compare the resulting likelihood or information criterion.

Where GMMs differ from K-means

A GMM can represent components with different sizes and elliptical shapes, and it returns soft memberships. K-means uses hard assignments and prefers roughly spherical groups of similar scale. A GMM is useful when probabilistic membership or an elliptical model matches the data; K-means is simpler when compact, roughly spherical clusters are adequate.

Fit several component counts and compare criteria such as BIC or AIC, along with held-out fit and whether the resulting groups make sense for the task. These criteria balance fit against model complexity; they do not guarantee that the selected groups are meaningful.

Limits and common mistakes

  • Wrong shape assumption. Gaussian components may fit ellipses, but not arbitrary structures such as crescents without using many components.
  • Local optima. Use several initialisations and check stability across runs.
  • Too many components. A complex mixture can fit noise as well as structure. Compare criteria and validate the use of the clusters.
  • Near-singular covariance. A component can collapse around a few points. Covariance regularisation can help, but does not remove the need to inspect the fit.

For implementation details and covariance options, see scikit-learn’s Gaussian mixture documentation. Compare with K-means and hierarchical clustering when choosing a clustering method.

Check yourself

0 of 3

Answer without scrolling back up.

  1. What does a GMM report for each point?

  2. What do the two steps of EM do?

  3. K-means is the special case of a GMM where:

Cheat sheet

Gaussian Mixture Models

Fit a Gaussian mixture and watch each point split its membership across clusters. Step through EM iteration by iteration and compare to hard k-means.

MACHINE LEARNING · vizlearn.in/machine_learning/gaussian_mixture_models.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.

Teaching a course with this? Individual teachers can use it freely; for a whole department or programme, see institutional licences.