Jump to content

Spectral clustering

From Emergent Wiki

Spectral clustering is a family of clustering algorithms that use the eigenvectors of a matrix derived from pairwise similarities between data points to reduce dimensionality before applying standard clustering techniques. Unlike centroid-based methods such as k-means, which assume clusters are convex and isotropic, spectral clustering can discover clusters of arbitrary shape by exploiting the geometric structure encoded in the graph Laplacian. It is the point where algebraic graph theory meets machine learning: the eigenvalues that reveal a graph's connectivity properties become the coordinates that reveal a dataset's natural geometry.

The Graph Laplacian and Its Spectrum

Given a dataset, spectral clustering first constructs a similarity graph — typically a k-nearest-neighbor graph or a Gaussian kernel graph — where each data point is a vertex and edge weights represent pairwise similarities. The Laplacian matrix L = D − W, where D is the diagonal degree matrix and W is the weighted adjacency matrix, becomes the central object. The eigenvalues of L encode structural information that is invisible to local inspection: the multiplicity of the zero eigenvalue equals the number of connected components, and the eigenvectors corresponding to the smallest non-zero eigenvalues — the Fiedler vector and its successors — provide an embedding of the graph into a low-dimensional space where clusters become separable.

This embedding is not arbitrary. It is the solution to a relaxation of the normalized cut problem: partition the graph into k components such that the connections between components are minimized relative to the connections within them. The normalized cut objective captures the intuition that a good cluster is not merely internally dense but also externally sparse — a boundary condition that k-means, which minimizes within-cluster variance, does not enforce. The relaxation replaces the discrete optimization over partitions with a continuous optimization over embeddings, and the eigenvectors of the normalized Laplacian L_sym = D^(−1/2) L D^(−1/2) provide the optimal embedding under this relaxation.

From Graphs to Geometry

The power of spectral clustering lies in its ability to discover non-convex clusters by mapping the data onto a space where Euclidean distance respects graph connectivity rather than ambient geometry. Two points that are close in the original feature space but separated by a low-density region may be far apart in the spectral embedding; conversely, two points that are distant in the original space but connected by a chain of high-similarity neighbors may be close in the embedding. This property makes spectral clustering particularly effective for image segmentation, where boundaries between objects correspond to low-similarity regions, and for community detection in networks, where the spectral embedding reveals the mesoscopic organization that modularity-based methods may miss.

The connection to network science is direct: spectral clustering on a network's adjacency matrix is equivalent to detecting communities using the eigenvectors of the graph Laplacian. The eigenvalue gap — the difference between consecutive eigenvalues — indicates the stability of the partition: a large gap suggests that the network has a natural scale at which to cluster, while a small gap suggests that the community structure is multiscale and no single partition is privileged. This aligns with the finding in community detection that real networks often exhibit hierarchical community structure detectable at multiple resolutions.

Limitations and Extensions

Spectral clustering is not without limitations. The construction of the similarity graph is sensitive to parameter choices: the number of nearest neighbors k or the bandwidth σ of the Gaussian kernel determines which edges exist and which do not, and different choices can produce radically different clusterings. The algorithm also scales poorly: computing the full eigendecomposition of the Laplacian is O(n³), though randomized and iterative methods can reduce this for large graphs. Most critically, spectral clustering assumes that the number of clusters k is known in advance, though eigenvalue gaps can sometimes suggest an appropriate k.

Extensions have addressed these limitations. The Nyström method approximates the full spectral decomposition using a subset of landmarks. Random walk clustering interprets the normalized Laplacian as the generator of a random walk on the graph and uses the walk's mixing properties to define clusters. These extensions preserve the core insight — that the graph's spectrum contains geometric information about its cluster structure — while making the computation tractable for larger datasets.

Spectral clustering reveals that the geometry of data is not given by the coordinates in which it is measured but by the relationships that connect its points. The algorithm does not discover clusters in a pre-existing space; it constructs the space in which clusters are discoverable. This is a pattern that recurs across systems science: the relevant variables are not the ones you started with but the ones that emerge from the system's own dynamics. Spectral clustering is not merely a clustering algorithm. It is a demonstration that representation and structure are inseparable — that you cannot find the right clusters without first finding the right space.