fuzzyclust.models.supervised_fuzzy_partition#

fuzzyclust.models.supervised_fuzzy_partition(X, y, n_clusters=3, shape='trapezoid', merge_threshold=0.8, m=2.0, random_state=None, **clusterer_params)[source]#

Per-feature fuzzy partitions derived from supervised fuzzy clustering.

SupervisedFuzzyClassifier is run with n_clusters rules; the Gaussian antecedent sets of the rules, projected on every feature (center \(v_{ij}\), width \(\sigma_{ij}\)), form an initial partition of \(R\) sets per feature. Sets whose similarity exceeds merge_threshold are merged (weighted by the rule priors) so that every feature ends with as many sets as the class structure requires; a feature left with a single set is a “don’t care” variable [1].

Parameters:
Xarray_like of shape (n_samples, n_features)
yarray_like of shape (n_samples,)

Class labels.

n_clustersint, default=3

Number of rules = initial number of sets per feature.

shape{“gaussian”, “trapezoid”, “triangle”}, default=”trapezoid”

Shape used to evaluate the sets (see membership_1d()).

merge_thresholdfloat, default=0.8

Similarity threshold \(\theta\) of the set merging; 1.0 disables merging.

mfloat, default=2.0
random_stateint, RandomState instance or None, default=None
**clusterer_params

Passed to SupervisedFuzzyClassifier.

Returns:
partitionslist of dict, one per feature

Keys "centers", "sigmas", "weights" (arrays sorted by center), "groups" (which rules were merged into each set), "range" (min, max of the feature) and "shape".

classifierfitted SupervisedFuzzyClassifier

References

[1]

J. Abonyi, “Supervised fuzzy clustering based initialization of fuzzy partitions for decision tree induction”, in: Soft Computing in Industrial Applications, AISC 75, Springer, 31–39, 2010.

Examples

>>> from fuzzyclust.datasets import load_iris
>>> from fuzzyclust.models import supervised_fuzzy_partition
>>> iris = load_iris()
>>> parts, clf = supervised_fuzzy_partition(iris.data, iris.target, n_clusters=3, random_state=0)
>>> len(parts), [len(p["centers"]) <= 3 for p in parts]
(4, [True, True, True, True])