← 10. Patterns & segmentation
Gaussian mixture model
Try this analysis →

Gaussian Mixture Models (GMM)

Cluster boundaries expressed as probabilities, not lines.

Mixing proportionsMembership probabilitiesEM algorithmBIC

Acidity →Body →Cluster 1Cluster 2Cluster 3Bean BBean B membershipCluster 10.43Cluster 20.40Cluster 30.17

Suppose we want to classify coffee beans by flavor. We could divide them into a few types: beans with pronounced acidity, beans with a balance of sweetness and body, and beans with a rich, heavy flavor.

But not every bean fits neatly into a single type. Some beans have strong acidity and strong sweetness, showing the features of two types at once.

Methods like K-Means, which assign each observation to one cluster, struggle to capture such in-between characteristics. A Gaussian mixture model (GMM) represents each cluster as a probability distribution and estimates the relative probability that an observation belongs to each cluster. That makes it useful for data in which the boundaries between clusters aren’t sharp.

In this lesson we’ll look at the basic structure of GMM, membership probabilities and the EM algorithm, covariance settings, choosing the number of clusters, interpreting an actual results table, how it differs from K-Means and what to watch out for in the analysis.

SECTION 1

What is a Gaussian mixture model?

A GMM is a probability model that assumes the data were generated from a mixture of several normal (Gaussian) distributions.

Each normal distribution represents one latent cluster, and each cluster can have its own center, spread and relationships between variables.

002.52.5557.57.51010Acidity →BodyAcidic typeFull-bodied typeCould be either
Two overlapping flavor clusters

For example, if we plot beans on two axes, acidity and body, one cluster may be spread around high acidity and low body and another around low acidity and high body. A bean in the region where the two distributions overlap could belong to either cluster.

A GMM estimates each cluster’s distribution and then computes membership probabilities for each bean. You can designate the cluster with the highest probability as the bean’s main cluster, but a key feature is that the possibility of belonging to other clusters is kept as well.

SECTION 2

How is it different from K-Means?

K-Means generally assigns each observation to a single cluster based on the distance between the observation and the cluster centers.

A GMM, in contrast, computes the likelihood of membership using each cluster’s probability distribution.

K-MeansGMMAssigned to one clusterAssigned by membership probability
How K-Means and GMM assign observations
AspectK-MeansGMM
Cluster representationCentroidProbability distribution with a mean and covariance
MembershipAssigned to one clusterMembership probability estimated for each cluster
Cluster shapeDistance-based partition, mostly near-sphericalCan represent various elliptical distributions depending on the covariance setting
Main settingsNumber of clusters, initial centroidsNumber of components, covariance type, initialization
Typical evaluationSilhouette coefficient, within-cluster sum of squares, etc.Log-likelihood, AIC, BIC, etc.

Note, though, that if you pick only the cluster with the highest membership probability in a GMM, you can end up with a single cluster label after all. And a GMM doesn’t find every irregularly shaped cluster well. For long, curved shapes or clusters connected in complex ways, density-based methods may be more appropriate.

SECTION 3

Worked example: flavor data on 360 coffee beans

Suppose a roastery’s research team analyzes the sensory evaluation results for 360 coffee beans.

Trained tasters rated four flavor attributes on a 0–10 scale using the same criteria. The team wants to find clusters that summarize the beans’ characteristics and see how similar a new bean is to the existing types.

VariableMeaningScale
AcidityIntensity of acidity0–10
SweetnessIntensity of sweetness0–10
BodyTexture and weight felt in the mouth0–10
Roast aromaIntensity of aroma produced by roasting0–10

We assume every bean has values for all four variables and check the variables’ distributions and correlations before the analysis. In reality a bean’s flavor is influenced by its variety, origin, roasting method and so on, but here we explore types using the flavor scores alone. So we don’t interpret the clusters as a definitive classification by origin or variety.

The research question is: ‘How many types do beans with similar flavor profiles fall into, and how likely is each bean to belong to each cluster?’

SECTION 4

What probability model does a GMM use?

A GMM expresses the probability density of the whole dataset as a weighted sum of several normal distributions.

p(xi) = Σk πk · N(xi | μk, Σk)

Here K is the number of mixture components, πk is the mixing proportion of component k, μk is its mean vector, and Σk is its covariance matrix. The mixing proportions are non-negative and sum to 1.

0246810π₁ 0.40π₂ 0.35π₃ 0.25Acidity score →
A mixture of three normal distributions

For example, if the mixing proportions of three components are 0.40, 0.35 and 0.25, the overall distribution is explained as a mixture of three normal distributions. The mixing proportions themselves aren’t necessarily equal to the shares of observations finally assigned in the actual sample.

In particular, if you assign each observation to its most probable cluster, the count per component can differ from the expected count calculated from the mixing proportions.

SECTION 5

How are membership probabilities calculated?

A GMM computes the posterior probability that each observation was generated by a particular component.

This is called the responsibility, or membership probability. For example, suppose bean A’s membership probabilities came out as follows.

ClusterMembership probability
Cluster 10.68
Cluster 20.27
Cluster 30.05
Total1.00
Cluster 10.68Cluster 20.27Cluster 30.05Total 1.00
Bean A’s membership probabilities

Bean A is most likely to belong to cluster 1, but it can be seen as sharing some of cluster 2’s characteristics too. Even if its main cluster is shown as cluster 1, giving the membership probability of 0.68 alongside lets you see how clear-cut the classification is.

But this probability is a model-based probability, conditional on the chosen GMM and its estimated parameters being appropriate. It shouldn’t be taken to mean that we are 68% sure of the bean’s true type.

SECTION 6

How does the EM algorithm work?

The parameters of a GMM are usually found by maximum likelihood estimation, and the standard computational procedure is the EM (Expectation–Maximization) algorithm.

EM alternates between estimating the latent component memberships of the observations and updating the parameters of each component.

E-stepCompute membershipsM-stepRe-estimate parametersProbsParamsInitial values →
EM algorithm

First, initial means, covariances and mixing proportions are set. In the E-step (Expectation), the current parameters are used to compute every observation’s membership probability for each component. In the M-step (Maximization), those probabilities are used as weights to re-estimate each component’s mean, covariance and mixing proportion.

These two steps are repeated until a convergence criterion is met, such as the increase in log-likelihood becoming small enough. However, because EM can converge to different local optima depending on the starting values, it’s good to run it from several initial values and check that the results are stable.

SECTION 7

Why do covariance settings matter?

In a GMM, the shapes of cluster it can represent depend on how the covariance matrix of each component is set.

sphericalCirculardiagAxis-aligned ellipsetiedShared shapefullFree shapeSimple · few parametersFlexible · many parameters
Cluster shapes by covariance setting
SettingMeaningCharacteristics
sphericalOne variance value per componentAssumes spherical distributions
diagDiagonal covariance matrix for each componentVariances differ by variable, but covariances within a component are assumed to be 0
tiedAll components use the same full covariance matrixMeans differ by component, but the shape of the spread is shared
fullFull covariance matrix for each componentAllows covariances between variables and various elliptical shapes

For example, if the relationship between acidity and sweetness differs from cluster to cluster, the full setting can represent this more flexibly. But it has many more parameters to estimate, so it can be unstable when the sample is small.

So rather than always choosing full, consider the size of the data and number of variables, the stability of the covariance matrices, information criteria and interpretability together.

SECTION 8

Do you need to standardize before the analysis?

The flavor attributes in this example are all on a 0–10 scale, but the actual range of variation can differ from variable to variable.

And with other data, the units of measurement themselves may differ, for example acidity on a 0–10 scale and an aroma-related measure on a 0–100 scale.

Because the estimated means, covariances and membership probabilities of a GMM can change with the scales of the variables, check the scales and distributions before the analysis. If needed, you can standardize the variables to mean 0 and standard deviation 1.

Standardizing isn’t always the right answer, though. If a particular variable genuinely carries more important information, or the unit of measurement itself is meaningful, it may be better to keep that structure. So decide whether to standardize based on the purpose of the analysis, and report it.

SECTION 9

How do you decide the number of components?

In a GMM you have to set K, the number of components, which corresponds to the number of clusters.

Commonly, candidate models from 1 up to several components are fitted and information criteria such as AIC or BIC are compared. Information criteria take both the model’s fit and its complexity into account. With the same data and comparable likelihood definitions, lower values are generally preferred.

Number of components (K)BIC
14,250
23,980
33,820
43,855
53,890
3,8003,9004,0004,1004,2004,3004,250K=13,980K=23,820K=33,855K=43,890K=5BIC
BIC by number of components

In these results the three-component model has the lowest BIC, so it is a strong candidate. But the lowest BIC alone doesn’t prove that three real groups exist. You also need to review stability across initializations, the size and interpretability of each component, the prediction goal and so on.

SECTION 10

How do you interpret the characteristics of each cluster?

Suppose we chose the three-component model and assigned each bean to the cluster with its highest membership probability.

ClusterAssigned countAciditySweetnessBodyRoast aroma
Cluster 1144 beans8.16.23.43.1
Cluster 2126 beans5.68.05.75.0
Cluster 390 beans3.24.88.28.5
Total360 beans
AciditySweetnessBodyRoast aromaCluster 1144 beans8.16.23.43.1Cluster 2126 beans5.68.05.75.0Cluster 390 beans3.24.88.28.5
Mean flavor scores by cluster

Assigned counts are based on labels set by the maximum membership probability.

Cluster 1 can be interpreted as a type with high acidity and weak body and roast aroma, and cluster 2 as a type with high sweetness and fairly balanced characteristics. Cluster 3 is a type with strong body and roast aroma.

These names aren’t objective diagnoses the model assigned automatically. They are interpretive labels the analyst gave after reading the variables’ characteristics. Also, the means in this table are calculated from the beans finally assigned to each cluster, so they may not match the model’s component mean vectors exactly.

SECTION 11

How do you check beans with ambiguous membership?

A GMM is useful for finding observations that lie on the boundaries between clusters.

For example, one bean may have a clear highest membership probability of 0.95, while another shows similar probabilities for two components, such as 0.43 and 0.40.

BeanCluster 1Cluster 2Cluster 3Main cluster
A0.950.040.01Cluster 1
B0.430.400.17Cluster 1
C0.080.120.80Cluster 3
Cluster 1Cluster 2Cluster 3Bean A0.95Main 1 · clearBean B0.430.400.17Main 1 · borderlineBean C0.80Main 3 · clear
Beans with ambiguous membership

Bean B’s main cluster is 1, but its chance of belonging to cluster 2 is about as high. In cases like this, presenting only a single label loses the information that it shares the features of two types.

So in a results report or an actual classification system, it’s good to provide the maximum membership probability, or all membership probabilities, along with the main cluster. However, you shouldn’t conclude that an observation is a data error or an outlier just because its membership probability is low.

SECTION 12

Things to watch out for in a GMM analysis

Check whether the normality assumption fits the actual data.

Because a GMM assumes a mixture of normal distributions, it can be inappropriate for complex curved structures or highly non-normal clusters. Review each cluster’s distribution, residual-type goodness-of-fit diagnostics and visualizations together.

Watch out for initial values and local optima.

The EM algorithm can converge to different results depending on the starting values. It’s good to estimate from several initial values and check how stable the log-likelihood and cluster composition are.

Don’t assume the number of components equals the number of real groups.

Sometimes a single complex group is approximated by several normal components. So mixture components are units of statistical description and don’t always correspond to clearly defined real groups.

Check the stability of the covariance matrix estimates.

If very few observations belong to a component or there are too many variables, covariance estimation can become unstable. You can consider regularization options, reducing the number of variables, adjusting the number of components and so on.

Don’t interpret clustering results as causal relationships or official quality grades.

Forming clusters by flavor doesn’t prove that a particular roasting method caused that flavor. And cluster labels are interpretive names given according to the research goal.

SECTION 13

How do you report GMM results?

When reporting GMM results, it’s good to present the variables and preprocessing, sample size, how the number of components was decided, the covariance setting, initialization and convergence, the characteristics of each component and the interpretation of membership probabilities together.

Example results write-up

A Gaussian mixture model (GMM) was applied to classify the flavor profiles of 360 coffee beans. Four variables were used in the analysis: acidity, sweetness, body and roast aroma. Comparing the BIC of candidate models with 1 to 5 components, the three-component model had the lowest value (BIC = 3,820).

When each bean was classified by its maximum membership probability, cluster 1 contained 144 beans, cluster 2 126 beans and cluster 3 90 beans. Cluster 1 was characterized by high acidity, cluster 2 by high sweetness and cluster 3 by strong body and roast aroma. Some beans showed similar membership probabilities for two components, indicating that the boundaries between clusters were not sharp. These results help summarize the beans’ flavor characteristics as three probabilistic types, but the components cannot be interpreted as directly representing actual bean varieties or origins.

In actual research you should also present the covariance type used, the number of initializations and whether the model converged, the mixing proportions, the parameters of each component and the results of stability checks.

✓Wrap-up

A GMM expresses cluster boundaries as probabilities

A Gaussian mixture model explains data as a mixture of several normal distributions and estimates each observation’s membership probability for each cluster.


Its distinctive feature is that, beyond assigning an observation to one cluster, it lets you see how far the observation straddles two or more clusters.

In a GMM, the EM algorithm estimates the mixing proportions, means and covariances, and the model is chosen considering AIC and BIC, stability across initializations, interpretability of each cluster and so on. Because the results depend on the normality assumption, the number of components and the covariance setting, the analysis settings and limitations should be reported too.

KEY TAKEAWAY

The heart of a GMM isn’t just splitting data into a few clusters; it’s describing in probabilistic terms how much each observation shares the characteristics of several clusters.