What is Spectral Clustering?
Spectral Clustering is a graph-based method that embeds samples with eigenvectors of a similarity-graph Laplacian and partitions the resulting low-dimensional rows.
Quick Facts
| Specification | Official Specification |
|---|
How It Works
Treat the affinity graph as the primary model
Ng, Jordan, and Weiss construct an RBF affinity matrix, normalize it by node degrees, take the leading eigenvectors, normalize rows, and cluster them. A nearest-neighbor graph is another common choice. Distances are not affinities: larger graph values must represent stronger similarity, and isolated nodes require an explicit policy.
Interpret subspaces and eigengaps, not individual axes
Eigenvectors within a repeated or nearly repeated eigenspace can rotate or change sign without changing the represented subspace. Therefore, individual coordinates do not carry stable semantic labels. The eigengap can indicate separation between the selected subspace and the next direction, but it does not prove the graph or target cluster count is correct.
Budget graph construction, eigensolving, and inference
Current scikit-learn documentation supports RBF, nearest-neighbor, and precomputed affinities plus several final label-assignment methods. Dense affinity matrices require quadratic storage, eigensolvers can dominate runtime, and the standard result is transductive. New samples need a Nyström-style extension, a separate classifier, or a versioned refit.
Key Characteristics
- Represents samples as nodes in a weighted similarity graph
- Uses eigenvectors of a normalized adjacency or graph Laplacian
- Can expose non-convex groups connected through local affinities
- Requires a separate rule to partition the spectral embedding
- Depends strongly on graph construction and eigensolver choices
- Is commonly transductive and can require quadratic graph storage
Common Use Cases
- Separating nested or manifold-shaped groups
- Partitioning weighted graphs and similarity networks
- Clustering images or documents from a sparse neighbor graph
- Comparing graph-based structure with centroid and density baselines
- Exploring small to medium datasets with meaningful affinities
Example
Loading code...Frequently Asked Questions
How does Spectral Clustering work?
Build a similarity graph, normalize its adjacency or Laplacian, extract a selected eigenvector subspace, normalize the sample rows when required, and partition those rows. Each graph and normalization convention defines a different model.
Why can Spectral Clustering find non-convex clusters?
It groups samples by connectivity in a similarity graph rather than distance to one centroid in the original space. The eigenvector embedding can turn nested or curved connected regions into groups that are easier to separate.
How should an affinity graph be constructed?
Use a nonnegative symmetric similarity whose scale reflects the task, such as an RBF kernel or symmetrized neighbor graph. Tune kernel width or neighbor count on validation evidence and define policies for disconnected components, duplicate edges, and isolated nodes.
Does the eigengap determine the true number of clusters?
No. It can indicate a stable spectral subspace under one graph construction, but graph hyperparameters can create or erase gaps. Combine it with perturbation stability, candidate partitions, domain review, and downstream results.
Can Spectral Clustering assign unseen samples?
The standard algorithm is transductive because its eigenvectors are defined on the fitted graph. New records require an explicit extension such as Nyström approximation, a classifier trained on spectral labels, or a versioned graph rebuild.