SpectralCoclustering
- class sklearn.cluster.SpectralCoclustering(n_clusters=3, *, svd_method='randomized', n_svd_vecs=None, mini_batch=False, init='k-means++', n_init,
Spectral Co-Clustering algorithm (Dhillon, 2001) [1].
Clusters rows and columns of an array X to solve the relaxed
normalized cut of the bipartite graph created from X as follows:
the edge between row vertex i and column vertex j has weight
X[i, j].
The resulting bicluster structure is block-diagonal, since each row and each column belongs to exactly one bicluster.
Supports sparse matrices, as long as they are nonnegative.
Read more in the User Guide.
The number of biclusters to find.
Selects the algorithm for finding singular vectors. May be
‘randomized’ or ‘arpack’. If ‘randomized’, use
sklearn.utils.extmath.randomized_svd, which may be faster
for large matrices. If ‘arpack’, use
scipy.sparse.linalg.svds, which is more accurate, but
possibly slower in some cases.
Number of vectors to use in calculating the SVD. Corresponds
to ncv when svd_method=arpack and n_oversamples when
svd_method is ‘randomized`.
Whether to use mini-batch k-means, which is faster but may get different results.
Method for initialization of k-means algorithm; defaults to ‘k-means++’.
Number of random initializations that are tried with the k-means algorithm.
If mini-batch k-means is used, the best initialization is chosen and the algorithm runs once. Otherwise, the algorithm is run for each initialization and the best solution chosen.
Used for randomizing the singular value decomposition and the k-means initialization. Use an int to make the randomness deterministic. See Glossary.
Results of the clustering. rows[i, r] is True if
cluster i contains row r. Available only after calling fit.
Results of the clustering, like rows.
The bicluster label of each row.
>>> from sklearn.cluster import SpectralCoclustering
>>> import numpy as np
>>> X = np.array([[1, 1], [2, 1], [1, 0],
... [
For a more detailed example, see the following: A demo of the Spectral Co-Clustering algorithm.
Create a biclustering for X.
Training data.
Not used, present for API consistency by convention.
Row and column indices of the i’th bicluster.
Only works if rows_ and columns_ attributes exist.
The index of the cluster.
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
A MetadataRequest encapsulating
routing information.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Shape of the i’th bicluster.
The index of the cluster.
Number of rows in the bicluster.
Number of columns in the bicluster.
Return the submatrix corresponding to bicluster i.
The index of the cluster.
The data.
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects
(such as Pipeline). The latter have
parameters of the form <component>__<parameter> so that it’s
possible to update each component of a nested object.
Estimator parameters.
Biclustering documents with the Spectral Co-clustering algorithm
The bicluster label of each column.
biclusters_ : tuple of two ndarraysConvenient way to get row and column indicators together.
Number of features seen during fit.
n_features_in_,)Names of features seen during fit. Defined only when X
has feature names that are all strings.
SpectralBiclustering instance.
Indices of rows in the dataset that belong to the bicluster.
Indices of columns in the dataset that belong to the bicluster.
The submatrix corresponding to bicluster i.
Works with sparse matrices. Only works if rows_ and
columns_ attributes exist.
Estimator instance.