onion_clustering.onion_uni.ClusterMixin

class onion_clustering.onion_uni.ClusterMixin[source]

Mixin class for all cluster estimators in scikit-learn.

  • _estimator_type class attribute defaulting to “clusterer”;

  • fit_predict method returning the cluster labels associated to each sample.

Examples

>>> 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])

Methods

fit_predict

Perform clustering on X and returns cluster labels.

fit_predict(X, y=None, **kwargs)[source]

Perform clustering on X and returns cluster labels.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Input data.

  • y (Ignored) – Not used, present for API consistency by convention.

  • **kwargs (dict) –

    Arguments to be passed to fit.

    Added in version 1.4.

Returns:

labels – Cluster labels.

Return type:

ndarray of shape (n_samples,), dtype=np.int64