Skip to main content
MahiDev — Learn. Build. Become AI-ready.

Lesson 42

Gaussian Mixture Model

Describe clusters as overlapping bell curves and assign each point a probability for every cluster. One example is on this page.

Intermediate12 min
Gaussian Mixture Model MahiDev

What You Will Learn

  • Idea
  • Example
  • When to use it

Idea

A Gaussian mixture treats the data as several normal distributions added together. Each cluster has a center, a spread, and a weight. A point can belong partly to two clusters. The printed label is the cluster with the highest probability.

Example

python
import numpy as np
from sklearn.mixture import GaussianMixture

X = np.array([[1, 1], [1.2, 0.9], [1.1, 1.3], [6, 6], [6.4, 5.8], [5.7, 6.2]], dtype=float)
labels = GaussianMixture(n_components=2, random_state=0).fit_predict(X)
print(labels.tolist())

Output:

text
[1, 1, 1, 0, 0, 0]

When to use it

  • Use it when a point near the edge should carry a probability, not a hard label.
  • Elliptical clusters fit naturally. Very odd shapes do not.
  • You still choose how many components to fit.

Loading playground…