Spectral clustering

In multivariate statistics and the clustering of data, spectral clustering techniques make use of the spectrum (eigenvalues) of the similarity matrix of the data to perform dimensionality reduction before clustering in fewer dimensions. The similarity matrix is provided as an input and consists of a quantitative assessment of the relative similarity of each pair of points in the dataset.

In application to image segmentation, spectral clustering is known as segmentation-based object categorization.

Definitions

Given an enumerated set of data points, the similarity matrix may be defined as a symmetric matrix $A$ , where $A_{ij}\geq 0$ represents a measure of the similarity between data points with indices $i$ and $j$ . The general approach to spectral clustering is to use a standard clustering method (there are many such methods, k-means is discussed below) on relevant eigenvectors of a Laplacian matrix of $A$ . There are many different ways to define a Laplacian which have different mathematical interpretations, and so the clustering will also have different interpretations. The eigenvectors that are relevant are the ones that correspond to smallest several eigenvalues of the Laplacian except for the smallest eigenvalue which will have a value of 0. For computational efficiency, these eigenvectors are often computed as the eigenvectors corresponding to the largest several eigenvalues of a function of the Laplacian.

Spectral clustering is well known to relate to partitioning of a mass-spring system, where each mass is associated with a data point and each spring stiffness corresponds to a weight of an edge describing a similarity of the two related data points. Specifically, the classical reference  explains that the eigenvalue problem describing transversal vibration modes of a mass-spring system is exactly the same as the eigenvalue problem for the graph Laplacian matrix defined as

$L:=D-A$ ,

where $D$ is the diagonal matrix

$D_{ii}=\sum _{j}A_{ij}.$ The masses that are tightly connected by the springs in the mass-spring system evidently move together from the equilibrium position in low-frequency vibration modes, so that the components of the eigenvectors corresponding to the smallest eigenvalues of the graph Laplacian can be used for meaningful clustering of the masses.

A popular related spectral clustering technique is the normalized cuts algorithm or Shi–Malik algorithm introduced by Jianbo Shi and Jitendra Malik, commonly used for image segmentation. It partitions points into two sets $(B_{1},B_{2})$ based on the eigenvector $v$ corresponding to the second-smallest eigenvalue of the symmetric normalized Laplacian defined as

$L^{\text{norm}}:=I-D^{-1/2}AD^{-1/2}.$ A mathematically equivalent algorithm  takes the eigenvector corresponding to the largest eigenvalue of the random walk normalized adjacency matrix $P=D^{-1}A$ .

Knowing the eigenvectors, partitioning may be done in various ways, such as by computing the median $m$ of the components of the second smallest eigenvector $v$ , and placing all points whose component in $v$ is greater than $m$ in $B_{1}$ , and the rest in $B_{2}$ . The algorithm can be used for hierarchical clustering by repeatedly partitioning the subsets in this fashion.

Algorithms

If the similarity matrix $A$ has not already been explicitly constructed, the efficiency of spectral clustering may be improved if the solution to the corresponding eigenvalue problem is performed in a matrix-free fashion (without explicitly manipulating or even computing the similarity matrix), as in the Lanczos algorithm.

For large-sized graphs, the second eigenvalue of the (normalized) graph Laplacian matrix is often ill-conditioned, leading to slow convergence of iterative eigenvalue solvers. Preconditioning is a key technology accelerating the convergence, e.g., in the matrix-free LOBPCG method. Spectral clustering has been successfully applied on large graphs by first identifying their community structure, and then clustering communities.

Spectral clustering is closely related to nonlinear dimensionality reduction, and dimension reduction techniques such as locally-linear embedding can be used to reduce errors from noise or outliers.

Free software to implement spectral clustering is available in large open source projects like Scikit-learn  using LOBPCG with multigrid preconditioning, or ARPACK, MLlib for pseudo-eigenvector clustering using the power iteration method, and R.

Relationship with k-means

The kernel k-means problem is an extension of the k-means problem where the input data points are mapped non-linearly into a higher-dimensional feature space via a kernel function $k(x_{i},x_{j})=\varphi ^{T}(x_{i})\varphi (x_{j})$ . The weighted kernel k-means problem further extends this problem by defining a weight $w_{r}$ for each cluster as the reciprocal of the number of elements in the cluster,

$\max _{\{C_{s}\}}\sum _{r=1}^{k}w_{r}\sum _{x_{i},x_{j}\in C_{r}}k(x_{i},x_{j}).$ Suppose $F$ is a matrix of the normalizing coefficients for each point for each cluster $F_{ij}=w_{r}$ if $i,j\in C_{r}$ and zero otherwise. Suppose $K$ is the kernel matrix for all points. The weighted kernel k-means problem with n points and k clusters is given as,

$\max _{F}\operatorname {trace} (KF)$ such that

$F=G_{n\times k}G_{k\times n}^{T}$ $G^{T}G=I$ such that $\operatorname {rank} (G)=k$ . In addition, there are identity constrains on $F$ given by,

$F\cdot \mathbb {I} =\mathbb {I}$ where $\mathbb {I}$ represents a vector of ones.

$F^{T}\mathbb {I} =\mathbb {I}$ This problem can be recast as,

$\max _{G}\operatorname {trace} (G^{T}G).$ This problem is equivalent to the spectral clustering problem when the identity constraints on $F$ are relaxed. In particular, the weighted kernel k-means problem can be reformulated as a spectral clustering (graph partitioning) problem and vice versa. The output of the algorithms are eigenvectors which do not satisfy the identity requirements for indicator variables defined by $F$ . Hence, post-processing of the eigenvectors is required for the equivalence between the problems. Transforming the spectral clustering problem into a weighted kernel k-means problem greatly reduces the computational burden.

Relationship to DBSCAN

Spectral clustering is also related to DBSCAN clustering, that finds density-connected components. Connected components correspond to optimal spectral clusters (no edges cut); and DBSCAN uses an asymmetric neighbor graph with edges removed when source points are not dense. Thus, DBSCAN is a special case of spectral clustering, but one which allows more efficient algorithms (worst case $O(n^{2})$ , in many practical cases much faster with indexes).

Measures to compare clusterings

Ravi Kannan, Santosh Vempala and Adrian Vetta proposed a bicriteria measure to define the quality of a given clustering. They said that a clustering was an (α, ε)-clustering if the conductance of each cluster (in the clustering) was at least α and the weight of the inter-cluster edges was at most ε fraction of the total weight of all the edges in the graph. They also look at two approximation algorithms in the same paper.

Approximate Solutions

Spectral clustering is computationally expensive unless the graph is sparse and the similarity matrix can be efficiently constructed. If the similarity matrix is an RBF kernel matrix, spectral clustering is expensive. There are approximate algorithms for making spectral clustering more efficient: power method, Nystrom method, etc. However, recent research pointed out the problems with spectral clustering with Nystrom method; in particular, the similarity matrix with Nystrom approximation is not elementwisely positive, which can be problematic.

History

Spectral clustering has a long history. Spectral clustering as a machine learning method was popularized by Shi & Malik and Ng, Jordan, & Weiss.