SklearnPartitioner#

class SklearnPartitioner(clusterer)[исходный код]#

Базовые классы: Partitioner

Partitions a sample by a scikit-learn clusterer with an n_clusters parameter.

Every partition is computed by an unfitted copy of the clusterer. The copy receives n_clusters=k and, if the clusterer has a random_state parameter, an integer seed drawn from the generator of the call. The object passed by the user is neither changed nor fitted. scikit-learn is an optional dependency and is required to create this partitioner (pip install pysatl-mpest[sklearn]).

Параметры:

clusterer (ClusterMixin) – Clusterer inheriting ClusterMixin and taking the number of clusters as its n_clusters parameter. Its values of n_clusters and random_state are replaced for every partition.

Переменные:

clusterer (ClusterMixin) – The clusterer passed by the user, unchanged.

Исключение:
  • ImportError – scikit-learn is not installed.

  • TypeError – clusterer is not an instance of ClusterMixin, or it cannot label the points of a sample (it has no fit_predict, as FeatureAgglomeration, which clusters features).

  • ValueError – clusterer has no n_clusters parameter.

Предупрждения:

UserWarning – The value of n_clusters or random_state differs from the default of the clusterer constructor. The value is ignored because the partitioner sets its own value for every partition.

Заметки

Clusterers that choose the number of clusters themselves, such as DBSCAN, are not supported. A deterministic clusterer, such as AgglomerativeClustering, gives the same partition for any generator.

Methods

partition(X, k, rng)

Divide the sample into k clusters by the scikit-learn clusterer.