6.8.3. scikits.learn.cluster.SpectralClustering¶
- class scikits.learn.cluster.SpectralClustering(k=8, mode=None)¶
Spectral clustering: apply k-means to a projection of the graph laplacian, finds normalized graph cuts.
Parameters : k: integer, optional :
The dimension of the projection subspace.
mode: {None, ‘arpack’ or ‘amg’} :
The eigenvalue decomposition strategy to use. AMG (Algebraic MultiGrid) is much faster, but requires pyamg to be installed.
Attributes
labels_: Labels of each point Methods
fit(X): Compute spectral clustering - __init__(k=8, mode=None)¶
- fit(X, **params)¶
Compute the spectral clustering from the adjacency matrix of the graph.
Parameters : X: array-like or sparse matrix, shape: (p, p) :
The adjacency matrix of the graph to embed. X is an adjacency matrix of a simimlarity graph: its entries must be positive or zero. Zero means that elements have nothing in comon, wereas high values mean that elements are strongly similar.
Notes
If you have an affinity matrix, such as a distance matrix, for which 0 means identical elements, and high values means very dissimilar elements, it can be transformed in a simimlarity matrix that is well suited for the algorithm by applying the heat kernel:
np.exp(- X**2/2. * delta**2)
If the pyamg package is installed, it is used. This greatly speeds up computation.