Skip to content

Cluster Analysis (Advanced)

This chapter covers density-based, model-based, grid-based, spectral, and high-dimensional clustering, plus how to validate clusters.

1. Density-Based: DBSCAN

DBSCAN (Density-Based Spatial Clustering of Applications with Noise) finds arbitrarily shaped clusters separated by low-density regions; also labels noise/outliers.

Definitions

  • ϵ-neighborhood: Nϵ(p)={qdist(p,q)ϵ}.
  • Core point: |Nϵ(p)|MinPts (density-reachable interior).
  • Border point: not core, but within ϵ of a core point.
  • Noise point (outlier): neither core nor border.
  • Directly density-reachable: qNϵ(p) and p is core.
  • Density-reachable: chain of direct reachable via core points.
  • Density-connected: both reachable from a common core point.

Algorithm

label all points as unvisited;
for each p:
   if visited: continue;
   mark visited; N = Nε(p);
   if |N| < MinPts: mark p as NOISE (may later become border);
   else:
      start new cluster C; add p to C; seed set S = N;
      for each q in S:
         mark q visited; Nq = Nε(q);
         if |Nq| ≥ MinPts: add Nq to S;       // expand
         if q not yet in any cluster: add q to C;
  • Clusters grow by chaining core points; border points attach to one cluster.
ProsCons
arbitrary shape clustersneeds ϵ, MinPts tuning
finds noise automaticallystruggles with varying densities
only 2 params, no k neededdistance-based ⇒ curse of dimensionality

2. OPTICS (Ordering Points To Identify Clustering Structure)

  • Generalizes DBSCAN for data with varying densities.
  • Produces an ordering of points with two values: core-distance and reachability-distance, visualized as a reachability plot (valleys = clusters).
  • core-distance(p) = distance to the MinPts-th neighbor.
  • reachability-distance(p,q) = max(core-dist(p),dist(p,q)).
  • Lets users extract clusters at multiple ϵ thresholds after one pass; no single global ϵ.
  • Extensions: OPTICS-XI, HiSC (hierarchical subspace clustering).

3. Grid-Based: STING, CLIQUE

  • STING: partition space into rectangular grid cells; compute statistical info per cell; query answers computed bottom-up by cell densities (fast, O(n) build, query O(cells)).
  • CLIQUE: automatic subspace clustering — finds dense grids in subspaces (handles high-dimensional data; combines density + grid).

4. Model-Based: Expectation-Maximization (EM)

Mixture of Gaussians

  • Assume data generated by a mixture of k Gaussian components:p(x)=l=1kπlN(xμl,Σl)with mixing weights πl0, πl=1.

EM Algorithm (two steps, iterated)

initialize π_l, μ_l, Σ_l;
repeat:
  E-step: compute responsibilities (soft assignment)
     γ(z_{il}) = P(component l | x_i) =
        π_l N(x_i|μ_l,Σ_l) / Σ_{j} π_j N(x_i|μ_j,Σ_j)
  M-step: re-estimate parameters by weighted MLE:
     μ_l = (Σ_i γ_{il} x_i) / (Σ_i γ_{il})
     Σ_l = (Σ_i γ_{il}(x_i-μ_l)(x_i-μ_l)^T) / (Σ_i γ_{il})
     π_l = (Σ_i γ_{il}) / n
until log-likelihood converges;

Properties

  • Soft assignment (probabilities) vs k-means hard assignment — k-means is a limiting case of EM for spherical equal covariances.
  • Converges to local optimum (log-likelihood non-decreasing).
  • ✅ gives probabilities & component models; ❌ assumes Gaussian shape, needs k, slow.
EM (soft)k-means (hard)
probabilistic, soft membershiphard assignment
arbitrary covariance (ellipses)spherical (equal var)
likelihood-basedSSE-based

Other model-based

  • COBWEB / CLASSIT: conceptual clustering of categorical data (incrementally builds a taxonomy).
  • SOM (Self-Organizing Map): neural net that produces a topology-preserving 2-D map.

5. Spectral Clustering

  • Uses the similarity graph of points: build affinity matrix W (e.g., Wij=exp(xixj2/2σ2)), degree matrix D (Dii=jWij), Laplacian L=DW (or normalized Lsym=D1/2LD1/2).
  • Compute the first k eigenvectors of L, form matrix U (n×k), normalize rows, then run k-means on rows.
  • Excellent for non-convex / concentric clusters that k-means fails on.
build similarity graph W; D = diag(row sums); L = D - W;
eigendecompose L → k smallest eigenvectors (or normalized);
stack as rows → normalize each row; run k-means on these embeddings;

6. High-Dimensional & Subspace Clustering

  • In high-D, distances concentrate (curse of dimensionality) ⇒ clusters exist only in subspaces.
  • Subspace clustering: CLIQUE, PROCLUS (find relevant subspaces per cluster), FIRES.
  • Projected clustering: each cluster defined on a subset of dimensions.

7. Cluster Validation

External Indices (vs known labels)

  • Rand Index / Adjusted Rand Index (ARI): fraction of agreeing point pairs, corrected for chance (1 = perfect, 0 = random).
  • Mutual Information / NMI, Fowlkes-Mallows.

Internal Indices (no labels)

  • Sum of Squares: SSB (between), SSW (within); higher SSB/SSW ⇒ better separation.
  • Silhouette coefficient (for point i in cluster Ci):a(i)=avg distance to others in same clusterb(i)=minCCiavg distance to points in Cs(i)=b(i)a(i)max(a(i),b(i))[1,1]s1 well-clustered, s0 on boundary, s<0 likely wrong cluster. Overall silhouette = mean s(i); higher = better.
  • Davies-Bouldin, Calinski-Harabasz, Xie-Beni indices.

Relative Criteria

  • Compare clusterings from the same algorithm under different k (e.g., silhouette vs k, elbow of SSE).

Stability

  • Perturb data / subsample; measure consistency of clustering.

DBSCAN — Worked Example

Points in 1-D for clarity: {1,2,3,8,9,30}, ϵ=2, MinPts=3.

  • 1,2,3: each has ≥3 points within ϵ=2 (e.g., around 2: {1,2,3}) ⇒ core points forming cluster C1={1,2,3}.
  • 8,9: within 2 of each other but not enough neighbors (only 2) ⇒ with MinPts=3 they are border/noise unless connected to a core. Here they are isolated ⇒ noise.
  • 30: far from all ⇒ noise (outlier). DBSCAN thus finds one dense cluster and flags 8,9,30 as noise/outliers — something k-means (forced to make k groups) cannot do. Lower MinPts would let {8,9} form a second cluster.

EM — Worked Sketch (1-D, k=2)

Two Gaussians: red N(2,1), blue N(8,1). Initialize μr=3,μb=7,π=0.5 each.

  • E-step: for each point compute γred,γblue (responsibilities) from current params. A point at 2 gets γred0.88,γblue0.12.
  • M-step: new μr = responsibility-weighted mean of all points (shifts toward 2), μb toward 8; update variances & π.
  • Iterate; log-likelihood rises each step; converges to recovered components. Unlike k-means, points get soft memberships (e.g., a midpoint point belongs 50/50).

Spectral — Intuition

Two concentric rings are not linearly separable in original space, so k-means fails. The graph Laplacian's eigenvectors separate the rings into two clean bands; k-means on the embeddings recovers both rings. Spectral clustering excels when clusters are defined by connectivity, not centroid proximity.

Validation — Worked Silhouette

Point i in cluster A with a(i)=2 (avg intra dist); nearest other cluster has b(i)=6. s(i)=(62)/max(2,6)=4/6=0.67 ⇒ well clustered. If instead a(i)=5,b(i)=6, s(i)=0.17 ⇒ borderline. Mean silhouette over all points ≈ overall quality; compare across k to pick the best.

Index Comparison

IndexRangeHigher = better?Needs labels?
ARI / NMI[0,1] (ARI can be <0)yesyes
Silhouette[−1,1]yesno
Davies-Bouldin[0,∞)no (lower)no
Calinski-Harabasz[0,∞)yesno

Self-Organizing Map (SOM)

  • A neural-net grid (usually 2-D) where each neuron holds a weight vector; training moves neurons toward nearby input points (competitive learning + neighborhood updating). Result: a topology-preserving map where similar inputs land in adjacent neurons — a soft, visualizable cluster structure.

COBWEB (Conceptual / Categorical)

  • Incremental hierarchical clustering for categorical data; splits/merges nodes to maximize category utility (a heuristic combining intra-cluster similarity and inter-cluster dissimilarity). Produces a concept tree rather than numeric clusters.

Choosing a Clustering Method (Guide)

DataRecommended
spherical, similar size, known kk-means / k-medoids
arbitrary shape, noise, unknown kDBSCAN / OPTICS
non-convex / concentricspectral
probabilistic, need soft membershipEM
very large / streamingBIRCH / CLARA / STING
high-D, clusters in subspacesCLIQUE / PROCLUS / subspace

Summary

Advanced clustering handles shapes, densities, models, and high dimensions that basic methods miss. DBSCAN finds arbitrary shapes and noise via density (core/border/noise, ϵ, MinPts); OPTICS extends it to varying densities via a reachability plot. Grid/CLIQUE methods quantize space for speed and subspace discovery. EM fits Gaussian mixtures with soft assignments (eigendecomposition-free, likelihood-based). Spectral clustering embeds points via the graph Laplacian then k-means — great for non-convex clusters. Validate with external (ARI, NMI) and internal indices (silhouette, Davies-Bouldin, Calinski-Harabasz), and choose k by relative criteria.