# 谱聚类

谱聚类是一种基于图的聚类方法，它利用由相似图构建的[拉普拉斯矩阵](https://www.edgepedia.org/zh/laplacian-matrix)的特征向量来划分数据点。它适用于具有高度非凸结构的簇，例如嵌套圆环或螺旋，这些情况下簇中心和散布无法描述该组。<sup>[1](https://proceedings.neurips.cc/paper/2001/file/801272ee79cfde7fa5960571fee36b9b-Paper.pdf)</sup><sup> • </sup><sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup> 它使用标准线性代数软件即可简单实现，并且常常优于k均值等传统算法。<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup>

| 关键事实 | 详情 |
|---|---|
| 输入 | n个数据点上的相似（亲和）矩阵或图<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup> |
| 核心计算 | 未归一化或归一化图拉普拉斯的特征向量<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup> |
| 输出 | 划分为k个簇，通过对特征向量行进行k均值（或直接标签分配）获得<sup>[1](https://proceedings.neurips.cc/paper/2001/file/801272ee79cfde7fa5960571fee36b9b-Paper.pdf)</sup> |
| 松弛的目标 | 归一化割（施–马利克）或比率割；两者的精确最小化都是NP难的<sup>[3](https://www.math.ucdavis.edu/~saito/data/clustering/shi-malik.pdf)</sup><sup> • </sup><sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup> |
| 代价概况 | 最坏情况时间\( O(n^{3}) \)，亲和矩阵内存\( O(n^{2}) \)<sup>[4](https://link.springer.com/article/10.1007/s44163-024-00102-x)</sup> |
| 最著名的用例 | 图像分割和低维数据中的非凸簇<sup>[3](https://www.math.ucdavis.edu/~saito/data/clustering/shi-malik.pdf)</sup><sup> • </sup><sup>[5](http://web.stanford.edu/~lmackey/stats306b/doc/stats306b-spring14-lecture7_scribed.pdf)</sup> |
| 实践警告 | 相似图应只包含一个连通分量，否则结果意义不大<sup>[6](https://sklearn.org/stable/modules/generated/sklearn.cluster.spectral_clustering.html)</sup> |

## 工作原理

首先将数据转化为加权相似图。聚类于是变成图划分：寻找内部相似性强、集合之间连接弱的顶点集合。关键对象是图拉普拉斯。设权重矩阵为W，度矩阵为D（W的行和），未归一化拉普拉斯为\( L = D - W \)，两种归一化形式为\( L_{\mathrm{sym}} = D^{-1/2} \cdot L \cdot D^{-1/2} \)和\( L_{\mathrm{rw}} = D^{-1} \cdot L \)。<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup>

L的特征值0的重数等于图的连通分量数：若图恰好有k个分量，则\( 0 = \lambda_1 = \dots = \lambda_k < \lambda_{k+1} \)。<sup>[7](https://snap.stanford.edu/class/cs224w-2018/handouts/spectral_clustering-handout.pdf)</sup> 在这种理想情况下，每个分量的指示向量是\( L_{\mathrm{rw}} \)对应于特征值0的特征向量，因此最小的几个特征值所对应的特征向量就是精确的簇指示向量。<sup>[5](http://web.stanford.edu/~lmackey/stats306b/doc/stats306b-spring14-lecture7_scribed.pdf)</sup>

特征向量也求解松弛的割问题。精确最小化归一化割是NP完全的，即使对于网格上的图也是如此<sup>[3](https://www.math.ucdavis.edu/~saito/data/clustering/shi-malik.pdf)</sup>；将离散分配松弛为实值，使得第二小特征值的特征向量——[菲德勒向量](https://www.edgepedia.org/zh/fiedler-vector)——成为解。<sup>[7](https://snap.stanford.edu/class/cs224w-2018/handouts/spectral_clustering-handout.pdf)</sup> 松弛Ncut得到归一化谱聚类，而松弛RatioCut得到未归一化变体。<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup> 还有一种概率解读：将相似性视为马尔可夫随机游走中的边流量，转移概率为\( p_{ij} = w_{ij}/d_i \)，Ncut特征问题等价于随机矩阵\( P = D^{-1} \cdot S \)的特征系统。<sup>[8](https://proceedings.neurips.cc/paper_files/paper/2000/file/069654d5ce089c13f642d19f09a3d1c0-Paper.pdf)</sup> 因此，谱聚类找到的划分使得随机游走在簇内停留时间长，很少在簇间跳跃。<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup> 在大样本极限下，两种变体都充当分割数据空间的扩散算子<sup>[9](https://papers.neurips.cc/paper_files/paper/2004/file/d790c9e6c0b5e02c87b375e782ac01bc-Paper.pdf)</sup>，图拉普拉斯逼近底层流形上的[拉普拉斯–贝尔特拉米算子](https://www.edgepedia.org/zh/laplace-beltrami-operator)。<sup>[10](https://proceedings.neurips.cc/paper_files/paper/2001/file/f106b7f99d2cb30c3db1c3cc0fde9ccb-Paper.pdf)</sup>

## 如何实施

标准流程有四个步骤<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup>：

1. **构建相似图。** 常见构造有ε邻域图、k近邻图、互k近邻图和全连接图，最后一种在相似性快速衰减（如高斯核）时有用。<sup>[5](http://web.stanford.edu/~lmackey/stats306b/doc/stats306b-spring14-lecture7_scribed.pdf)</sup> 高斯亲和度为\( s(x_i, x_j) = \exp(-\|x_i - x_j\|^2/(2\sigma^2)) \)，其中σ的作用类似于ε。<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup> 在NJW算法中，对于\( i \neq j \)，\( A_{ij} = \exp(-\|s_i - s_j\|^2/2\sigma^2) \)，且\( A_{ii} = 0 \)；σ可以通过搜索取值并选择在最后一步之后给出最紧簇的值来确定。<sup>[1](https://proceedings.neurips.cc/paper/2001/file/801272ee79cfde7fa5960571fee36b9b-Paper.pdf)</sup>
2. **计算拉普拉斯**（未归一化L、\( L_{\mathrm{rw}} \)或\( L_{\mathrm{sym}} \)）。
3. **取k个特征向量**，它们对应于所选拉普拉斯的最小的k个特征值（等价地，在NJW约定下，取归一化亲和矩阵\( D^{-1/2} \cdot W \cdot D^{-1/2} \)的最大的k个特征值对应的特征向量），并将它们堆叠为矩阵U的列。对于\( L_{\mathrm{sym}} \)，对U进行行归一化，使每行具有单位长度。<sup>[1](https://proceedings.neurips.cc/paper/2001/file/801272ee79cfde7fa5960571fee36b9b-Paper.pdf)</sup><sup> • </sup><sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup>
4. **对特征向量矩阵的行进行聚类**，用k均值分为k组。<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup>

簇数k通常由特征间隙启发式选择：在理想情况下，前k个特征值为0，第(k+1)个为正，戴维斯–卡汉定理将间隙\( |\lambda_{k+1} - \lambda_k| \)的大小与特征空间的稳定性联系起来。<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup>

## 起源

使用拉普拉斯特征向量进行图划分可追溯到切格、多纳特和霍夫曼，以及菲德勒，后者1973年的论文引入了图的[代数连通度](https://www.edgepedia.org/zh/algebraic-connectivity)；\( D - W \)的第二小特征值被称为菲德勒值。<sup>[3](https://www.math.ucdavis.edu/~saito/data/clustering/shi-malik.pdf)</sup><sup> • </sup><sup>[11](https://doi.org/10.21136/cmj.1973.101168)</sup> 哈根和康于1992年在《IEEE集成电路与系统的计算机辅助设计汇刊》上引入了谱比率割划分<sup>[12](https://doi.org/10.1109/43.159993)</sup>，后来提出了谱k路比率割划分。<sup>[13](https://www.cs.yale.edu/homes/spielman/462/2010/lect19-10.pdf)</sup> 这些早期未归一化拉普拉斯算法主要用于并行计算、稀疏矩阵划分和超大规模集成电路芯片设计。<sup>[4](https://link.springer.com/article/10.1007/s44163-024-00102-x)</sup>

施和马利克2000年发表在《[IEEE模式分析与机器智能汇刊](https://www.edgepedia.org/zh/ieee-transactions-on-pattern-analysis-and-machine-intelligence)》上的归一化割论文——作者称这是谱划分首次应用于计算机视觉或图像分析——将该方法引入机器学习。<sup>[3](https://www.math.ucdavis.edu/~saito/data/clustering/shi-malik.pdf)</sup><sup> • </sup><sup>[14](https://doi.org/10.1109/34.868688)</sup> 随后，梅拉和施在2001年给出了随机游走视角<sup>[8](https://proceedings.neurips.cc/paper_files/paper/2000/file/069654d5ce089c13f642d19f09a3d1c0-Paper.pdf)</sup>，吴、乔丹和韦斯在2001年提出了他们经过分析的算法。<sup>[1](https://proceedings.neurips.cc/paper/2001/file/801272ee79cfde7fa5960571fee36b9b-Paper.pdf)</sup> 后来的理论包括迪隆、关和库利斯2004年关于加权核k均值与归一化割之间等价性的工作<sup>[15](https://dl.acm.org/doi/pdf/10.1145/1014052.1014118)</sup>，冯·卢克斯堡2007年的教程<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup>，以及罗赫、查特吉和余2011年关于高维随机块模型的一致性结果。<sup>[16](https://doi.org/10.1214/11-aos887)</sup>

## 变体

存在三种经典算法：使用L的前k个特征向量的未归一化谱聚类；施–马利克归一化方法，使用\( L_{\mathrm{rw}} \)的特征向量，求解广义问题\( (D - W) \cdot x = \lambda \cdot D \cdot x \)，并用第二特征向量递归二分<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup><sup> • </sup><sup>[3](https://www.math.ucdavis.edu/~saito/data/clustering/shi-malik.pdf)</sup>；以及使用\( L_{\mathrm{sym}} \)并附加行归一化步骤的NJW方法。<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup> 与梅拉和施的方法（将A的行归一化为和为1，但不重新归一化特征向量行）相比，NJW的行归一化避免了在簇间连通性变化很大时容易产生不良聚类结果的问题。<sup>[1](https://proceedings.neurips.cc/paper/2001/file/801272ee79cfde7fa5960571fee36b9b-Paper.pdf)</sup> 当相似矩阵完美时，多割和NJW可证明是等价的，尽管它们使用不同的谱映射。<sup>[17](https://sites.stat.washington.edu/spectral/papers/nips03-comparison.pdf)</sup> 相关的嵌入方法包括贝尔金和尼约吉的拉普拉斯特征映射，它在邻域图上求解\( L \cdot y = \lambda \cdot D \cdot y \)。<sup>[10](https://proceedings.neurips.cc/paper_files/paper/2001/file/f106b7f99d2cb30c3db1c3cc0fde9ccb-Paper.pdf)</sup><sup> • </sup><sup>[18](https://doi.org/10.7551/mitpress/1120.003.0080)</sup>

## 应用

谱聚类广泛用于图像分割，归一化割最初就是为此开发的。<sup>[3](https://www.math.ucdavis.edu/~saito/data/clustering/shi-malik.pdf)</sup><sup> • </sup><sup>[5](http://web.stanford.edu/~lmackey/stats306b/doc/stats306b-spring14-lecture7_scribed.pdf)</sup> 其主要缺点是代价：特征分解的最坏情况时间为\( O(n^{3}) \)，亲和矩阵的内存为\( O(n^{2}) \)。<sup>[4](https://link.springer.com/article/10.1007/s44163-024-00102-x)</sup> 有几种途径可以降低代价：

- **尼斯特伦扩展。** 福尔克斯、贝隆吉、钟和马利克在小的随机样本上求解分组问题并进行外推；大约100个随机选择的样本就足以捕捉典型自然图像中的显著组。<sup>[19](https://doi.org/10.1109/tpami.2004.1262185)</sup><sup> • </sup><sup>[20](https://people.cs.umass.edu/~mahadeva/cs791bb/reading/fowlkes-nystrom.pdf)</sup>
- **地标与锚点。** n个点与m ≪ n个地标之间的二分图产生扩散坐标\( V(\alpha) = [\lambda_1^{\alpha} \cdot v_1 \mid \dots \mid \lambda_p^{\alpha} \cdot v_p] \)用于可扩展聚类<sup>[21](https://aclanthology.org/W18-1705.pdf)</sup>；平衡层次k均值锚点同样可以降低图构造的代价。<sup>[22](https://www.sciencedirect.com/science/article/abs/pii/S003132032400147X)</sup>
- **更快的特征求解器。** 当特征间隙\( \gamma_k = |\lambda_k - \lambda_{k+1}| \)较大时，稀疏克里洛夫方法收敛更快<sup>[2](https://link.springer.com/article/10.1007/s11222-007-9033-z)</sup>；LOBPCG<sup>[23](https://doi.org/10.1137/s1064827500366124)</sup>和无正交化梯度方法在并行环境下扩展性更好。<sup>[24](https://arxiv.org/pdf/2305.10356v2.pdf)</sup>

## 局限与替代方法

谱聚类不是黑箱：结果严重依赖于相似图及其尺度参数。图应只包含一个连通分量，否则结果意义不大。<sup>[6](https://sklearn.org/stable/modules/generated/sklearn.cluster.spectral_clustering.html)</sup> 在理论方面，切格不等式保证谱割是最优等周问题的\( 1/\Phi \)近似，但\( 1/\Phi \)在大型几何图上（如n点直线或\( \sqrt{n} \times \sqrt{n} \)网格）会发散，因此基于切格的论证在大型数据集上失效。<sup>[25](https://ar5iv.labs.arxiv.org/html/2305.06541)</sup> 更新的分析证明谱聚类在与n和k无关的元图条件下有效。<sup>[26](https://ar5iv.labs.arxiv.org/html/2208.01724)</sup> 在收敛性方面，归一化谱聚类在一般假设下几乎必然收敛到合理的极限划分，而未归一化变体仅在强附加假设下收敛，这些假设无法在有限样本上验证；因此冯·卢克斯堡、布斯凯和贝尔金在实践中推荐归一化版本。<sup>[9](https://papers.neurips.cc/paper_files/paper/2004/file/d790c9e6c0b5e02c87b375e782ac01bc-Paper.pdf)</sup>

与替代方法相比：直接运行k均值在非凸簇（如同心圆环）上失败，而谱聚类能恢复其结构。<sup>[1](https://proceedings.neurips.cc/paper/2001/file/801272ee79cfde7fa5960571fee36b9b-Paper.pdf)</sup><sup> • </sup><sup>[5](http://web.stanford.edu/~lmackey/stats306b/doc/stats306b-spring14-lecture7_scribed.pdf)</sup> k均值、DBSCAN和凝聚聚类等传统算法在高维数据上表现不佳，因为仅靠[欧几里得距离](https://www.edgepedia.org/zh/euclidean-distance)无法刻画相对位置，而谱聚类通过图拉普拉斯的特征向量解决了这个问题。<sup>[4](https://link.springer.com/article/10.1007/s44163-024-00102-x)</sup> 在谱变体本身之间，对多割、NJW、施–马利克和坎南–文帕拉–维塔的经验比较在真实数据上没有发现明确的赢家；当噪声不太高时，多路方法表现更好，递归算法更稳定，而当k超过真实簇数时，多路方法退化更严重。<sup>[17](https://sites.stat.washington.edu/spectral/papers/nips03-comparison.pdf)</sup>

## References

1. [On Spectral Clustering: Analysis and an Algorithm (Ng, Jordan, Weiss, NIPS 2001)](https://proceedings.neurips.cc/paper/2001/file/801272ee79cfde7fa5960571fee36b9b-Paper.pdf)
2. [A tutorial on spectral clustering (von Luxburg, Statistics and Computing 2007)](https://link.springer.com/article/10.1007/s11222-007-9033-z)
3. [Normalized Cuts and Image Segmentation (Shi & Malik, IEEE TPAMI 22(8), 2000)](https://www.math.ucdavis.edu/~saito/data/clustering/shi-malik.pdf)
4. [Clustering graph data: the roadmap to spectral techniques (Discover Artificial Intelligence, 2024)](https://link.springer.com/article/10.1007/s44163-024-00102-x)
5. [STATS 306B Lecture 7: Spectral Clustering (Stanford, scribed notes)](http://web.stanford.edu/~lmackey/stats306b/doc/stats306b-spring14-lecture7_scribed.pdf)
6. [spectral_clustering, scikit-learn documentation](https://sklearn.org/stable/modules/generated/sklearn.cluster.spectral_clustering.html)
7. [Spectral clustering handout (Stanford CS224W)](https://snap.stanford.edu/class/cs224w-2018/handouts/spectral_clustering-handout.pdf)
8. [Learning Segmentation by Random Walks (Meila & Shi, NIPS 2000)](https://proceedings.neurips.cc/paper_files/paper/2000/file/069654d5ce089c13f642d19f09a3d1c0-Paper.pdf)
9. [Limits of Spectral Clustering (von Luxburg, Bousquet, Belkin, NeurIPS 2004)](https://papers.neurips.cc/paper_files/paper/2004/file/d790c9e6c0b5e02c87b375e782ac01bc-Paper.pdf)
10. [Laplacian Eigenmaps and Spectral Techniques for Embedding and Clustering (Belkin & Niyogi, NIPS 2001)](https://proceedings.neurips.cc/paper_files/paper/2001/file/f106b7f99d2cb30c3db1c3cc0fde9ccb-Paper.pdf)
11. [Miroslav Fiedler (1973). Algebraic connectivity of graphs. Czechoslovak Mathematical Journal.](https://doi.org/10.21136/cmj.1973.101168)
12. [L. Hagen, A.B. Kahng (1992). New spectral methods for ratio cut partitioning and clustering. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems.](https://doi.org/10.1109/43.159993)
13. [Yale Spielman Lecture 19: spectral graph clustering](https://www.cs.yale.edu/homes/spielman/462/2010/lect19-10.pdf)
14. [Jianbo Shi, J. Malik (2000). Normalized cuts and image segmentation. IEEE Transactions on Pattern Analysis and Machine Intelligence.](https://doi.org/10.1109/34.868688)
15. [Kernel k-means, Spectral Clustering and Normalized Cuts (Dhillon, Guan, Kulis, KDD 2004)](https://dl.acm.org/doi/pdf/10.1145/1014052.1014118)
16. [Karl Rohe, Sourav Chatterjee, Bin Yu (2011). Spectral clustering and the high-dimensional stochastic blockmodel. The Annals of Statistics.](https://doi.org/10.1214/11-aos887)
17. [Comparison of Spectral Clustering Methods (NIPS 2003)](https://sites.stat.washington.edu/spectral/papers/nips03-comparison.pdf)
18. [Mikhail Belkin, Partha Niyogi (2002). Laplacian Eigenmaps and Spectral Techniques for Embedding and Clustering. The MIT Press eBooks.](https://doi.org/10.7551/mitpress/1120.003.0080)
19. [C. Fowlkes and colleagues (2004). Spectral grouping using the nystrom method. IEEE Transactions on Pattern Analysis and Machine Intelligence.](https://doi.org/10.1109/tpami.2004.1262185)
20. [Spectral grouping using the Nyström method (Fowlkes et al., IEEE TPAMI)](https://people.cs.umass.edu/~mahadeva/cs791bb/reading/fowlkes-nystrom.pdf)
21. [Large-scale spectral clustering using diffusion coordinates on landmark-based bipartite graphs](https://aclanthology.org/W18-1705.pdf)
22. [Spectral clustering with linear embedding: A discrete clustering method for large-scale data (SCLE, Pattern Recognition 2024)](https://www.sciencedirect.com/science/article/abs/pii/S003132032400147X)
23. [Andrew V. Knyazev (2001). Toward the Optimal Preconditioned Eigensolver: Locally Optimal Block Preconditioned Conjugate Gradient Method. SIAM Journal on Scientific Computing.](https://doi.org/10.1137/s1064827500366124)
24. [Spectral clustering via orthogonalization-free methods (OFM/TriOFM, arXiv 2305.10356)](https://arxiv.org/pdf/2305.10356v2.pdf)
25. [Spectral Clustering on Large Datasets: When Does it Work? (arXiv 2305.06541, 2023)](https://ar5iv.labs.arxiv.org/html/2305.06541)
26. [A Tighter Analysis of Spectral Clustering, and Beyond (ICML 2022 / arXiv 2208.01724)](https://ar5iv.labs.arxiv.org/html/2208.01724)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods › Supervised, unsupervised, and semi-supervised learning › Clustering algorithms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/spectral-clustering

English original: https://www.edgepedia.org/spectral-clustering
