Gaussian mixture model
Problem type
Unsupervised soft clustering and density estimation.
Input
Scaled numeric features.
Output
Per-point membership probabilities for each component; a likelihood for any point.
Mental model
The data comes from K overlapping bell-shaped clouds, each with its own center, spread, and orientation; every point gets a probability of belonging to each cloud.
Core objective
Maximize the log-likelihood .
Training process
Expectation-maximization: compute responsibilities (E-step), re-estimate weights, means, and covariances (M-step), repeat to convergence; multiple initializations.
Preprocessing
Standardize features; reduce dimensionality if is large relative to .
Assumptions
Each cluster is approximately Gaussian (elliptical).
Key hyperparameters
Number of components (choose by BIC/AIC and domain review); covariance type (full, tied, diag, spherical); regularization of covariances.
Good use cases
Soft cluster assignments; elliptical clusters; anomaly scoring via low likelihood; generative sampling.
Poor use cases
Strongly non-Gaussian shapes; very high dimensions with few points.
Strengths
Soft memberships; models covariance; provides likelihoods.
Weaknesses
Local optima; sensitive to initialization; must pick K; components can collapse without regularization.
Computational cost
per iteration with full covariances.
Evaluation metrics
BIC/AIC, held-out log-likelihood, silhouette, stability.
Failure modes
Collapsing components; wrong covariance type; overconfident memberships far from data.
Minimal implementation
from sklearn.mixture import GaussianMixture
gmm = GaussianMixture(n_components=3, covariance_type="full", random_state=0).fit(X_scaled)
probs = gmm.predict_proba(X_scaled); scores = gmm.score_samples(X_scaled)Compared with neighbors
- K-means: the hard-assignment, spherical special case.
- DBSCAN: arbitrary shapes, no probabilities.