Mixin class for all cluster estimators in scikit-learn.
"clusterer" through the estimator_type tag;fit_predict method returning the cluster labels associated to each sample.>>> import numpy as np >>> from sklearn.base import BaseEstimator, ClusterMixin >>> class MyClusterer(ClusterMixin, BaseEstimator): ... def fit(self, X, y=None): ... self.labels_ = np.ones(shape=(len(X),), dtype=np.int64) ... return self >>> X = [[1, 2], [2, 3], [3, 4]] >>> MyClusterer().fit_predict(X) array([1, 1, 1])
Perform clustering on X and returns cluster labels.
Input data.
Not used, present for API consistency by convention.
Arguments to be passed to fit.
Added in version 1.4.
Cluster labels.
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.base.ClusterMixin.html