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: . - Core point:
(density-reachable interior). - Border point: not core, but within
of a core point. - Noise point (outlier): neither core nor border.
- Directly density-reachable:
and 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.
| Pros | Cons |
|---|---|
| arbitrary shape clusters | needs |
| finds noise automatically | struggles with varying densities |
| only 2 params, no k needed | distance-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
-th neighbor. - reachability-distance(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,
build, query ). - 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
Gaussian components: with mixing weights , .
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
, slow.
| EM (soft) | k-means (hard) |
|---|---|
| probabilistic, soft membership | hard assignment |
| arbitrary covariance (ellipses) | spherical (equal var) |
| likelihood-based | SSE-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
(e.g., ), degree matrix ( ), Laplacian (or normalized ). - Compute the first
eigenvectors of , form matrix ( ), 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:
(between), (within); higher ⇒ better separation. - Silhouette coefficient (for point
in cluster ): well-clustered, on boundary, likely wrong cluster. Overall silhouette = mean ; higher = better. - Davies-Bouldin, Calinski-Harabasz, Xie-Beni indices.
Relative Criteria
- Compare clusterings from the same algorithm under different
(e.g., silhouette vs , elbow of SSE).
Stability
- Perturb data / subsample; measure consistency of clustering.
DBSCAN — Worked Example
Points in 1-D for clarity:
: each has ≥3 points within (e.g., around 2: {1,2,3}) ⇒ core points forming cluster . : within 2 of each other but not enough neighbors (only 2) ⇒ with they are border/noise unless connected to a core. Here they are isolated ⇒ noise. : 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 groups) cannot do. Lower would let {8,9} form a second cluster.
EM — Worked Sketch (1-D, k=2)
Two Gaussians: red
- E-step: for each point compute
(responsibilities) from current params. A point at 2 gets . - M-step: new
= responsibility-weighted mean of all points (shifts toward 2), 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
Index Comparison
| Index | Range | Higher = better? | Needs labels? |
|---|---|---|---|
| ARI / NMI | [0,1] (ARI can be <0) | yes | yes |
| Silhouette | [−1,1] | yes | no |
| Davies-Bouldin | [0,∞) | no (lower) | no |
| Calinski-Harabasz | [0,∞) | yes | no |
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)
| Data | Recommended |
|---|---|
| spherical, similar size, known | k-means / k-medoids |
| arbitrary shape, noise, unknown | DBSCAN / OPTICS |
| non-convex / concentric | spectral |
| probabilistic, need soft membership | EM |
| very large / streaming | BIRCH / CLARA / STING |
| high-D, clusters in subspaces | CLIQUE / 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,