Model-Based Clustering

Model-based methods assume that the data is generated by a mixture of probability distributions and try to fit the model to the data. Each cluster corresponds to one component of the mixture.

Expectation-Maximisation (EM)

EM is an extension of K-Means that gives each object a probability of belonging to every cluster (soft clustering). For a mixture of Gaussians with weights wk, means μk and standard deviations σk:

  1. Initialise the parameters.
  2. E-step (expectation): for every object compute the responsibility of each cluster, the probability that the object came from it: rk = wk N(x | μk, σk) / Σ wj N(x | μj, σj).
  3. M-step (maximisation): re-estimate wk, μk and σk using the responsibilities as weights.
  4. Repeat until the log-likelihood stops improving.

EM may stop at a local optimum and can be slow, but it handles clusters of different sizes.

COBWEB

COBWEB is a conceptual clustering method that builds a classification tree incrementally. Each node holds probabilities of attribute values. A new object is placed where it gives the highest category utility, and the tree may merge or split nodes. It works with categorical attributes and does not need k.

Self-Organising Map (SOM)

A SOM is a neural network with an input layer and a grid of output nodes. It is trained without labels: for each input the winning node (the closest weight vector) and its neighbours move closer to the input. After training, similar objects fall on nearby nodes of the map, which gives clusters and a low-dimensional view of the data.

Definition: Responsibility. In EM, the probability that a data object was generated by a particular cluster, given the current model parameters.

Table 4.4: Model-based methods

Method Basis Output
EM Gaussian mixture Soft memberships
COBWEB Category utility Classification tree
SOM Neural network 2-D map of clusters

Example 4.4: An E-step for two Gaussian clusters

Problem: Two clusters have equal weights 0.5, means 2 and 8 and standard deviation 1. For the point x = 4 find the responsibility of each cluster.

Solution:

  1. The normal density is N(x) = exp(-(x - μ)² / 2) / √(2π).
  2. Cluster 1: (x - μ) = 2, so N = exp(-2) x 0.3989 = 0.0540.
  3. Cluster 2: (x - μ) = -4, so N = exp(-8) x 0.3989 = 0.000134.
  4. With equal weights, responsibility of cluster 1 = 0.0540 / (0.0540 + 0.000134) = 0.9975.

Result: The point 4 belongs to cluster 1 with probability 0.9975 and to cluster 2 with 0.0025.

from math import exp, pi, sqrt
def normal(x, mu, sd):
    return exp(-((x - mu) ** 2) / (2 * sd * sd)) / (sd * sqrt(2 * pi))
w = [0.5, 0.5]
mu = [2, 8]
x = 4
dens = [wk * normal(x, m, 1) for wk, m in zip(w, mu)]
resp = [d / sum(dens) for d in dens]
print("Densities     :", [round(d / 0.5, 6) for d in dens])
print("Responsibility:", [round(r, 4) for r in resp])

Output

Densities     : [0.053991, 0.000134]
Responsibility: [0.9975, 0.0025]

Common mistakes

  • Treating EM as giving a single hard cluster; it gives probabilities.
  • Starting EM from a poor initial guess and accepting a local optimum.
  • Assuming Gaussian shapes when the data is clearly not Gaussian.
  • Reading a SOM map as if distances on the grid were exact distances in the data.

Key takeaways

  • Model-based clustering fits a mixture of distributions.
  • EM alternates the E-step and the M-step until convergence.
  • COBWEB builds a classification tree using category utility.
  • SOM maps data onto a grid of neurons.

Practice questions

  1. What does the E-step of EM compute?
  2. What is COBWEB?
  3. What is the output of a SOM?

Answers to the practice questions

  1. The responsibility, the probability that each object belongs to each cluster.
  2. An incremental conceptual clustering method that builds a classification tree.
  3. A low-dimensional map in which similar objects lie on nearby nodes.

Sources

  • Official BCA syllabus Data Warehousing and Mining, course code 25BCA406DS03, Unit IV