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.
SupervisedFuzzyClassifieris run withn_clustersrules; 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 exceedsmerge_thresholdare 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
ofshape(n_samples,n_features) - yarray_like
ofshape(n_samples,) Class labels.
- n_clusters
int, 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_threshold
float, default=0.8 Similarity threshold \(\theta\) of the set merging;
1.0disables merging.- m
float, default=2.0 - random_state
int,RandomStateinstanceorNone, default=None - **clusterer_params
Passed to
SupervisedFuzzyClassifier.
- Xarray_like
- Returns:
- partitions
listofdict,oneperfeature Keys
"centers","sigmas","weights"(arrays sorted by center),"groups"(which rules were merged into each set),"range"(min, max of the feature) and"shape".- classifier
fittedSupervisedFuzzyClassifier
- partitions
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])