fuzzyclust.cluster.SubtractiveClustering#

class fuzzyclust.cluster.SubtractiveClustering(radii=0.5, squash=1.25, accept_ratio=0.5, reject_ratio=0.15, max_clusters=None)[source]#

Bases: _DensityPeaks

Subtractive clustering (Chiu, 1994): cluster centers from the potential of the data points.

Every data point is a candidate center. Its potential is the sum of Gaussian influences of all other points within a neighborhood radius \(r_a\); the point of highest potential becomes the first center, its influence (with a somewhat larger radius \(r_b\)) is subtracted from the potential of all points, and the next highest potential is examined. A candidate is accepted when its remaining potential is still a large fraction of the first one, rejected—and the procedure stopped—when it is a small fraction, and in between accepted only if it is far enough from the existing centers. The method is the data-point version of the mountain method (MountainClustering), which it frees from the exponential cost of a grid, and it is the classical estimator of the number of rules of a Takagi–Sugeno model identified in the product space of inputs and output. The data are scaled to the unit hypercube internally, so the radii are fractions of the data range.

Parameters:
radiifloat or array_like of shape (n_features,), default=0.5

Neighborhood radius \(r_a\) of a center as a fraction of the range of every feature (one value per feature allowed). Smaller radii give more clusters. Chiu recommends \(0.2\)–\(0.5\) for his examples; \(0.5\) is the usual default.

squashfloat, default=1.25

Squash factor \(\eta\): the potentials are revised with the radius \(r_b=\eta\,r_a>r_a\) so that no center is placed close to an existing one.

accept_ratiofloat, default=0.5

Acceptance ratio \(\bar\varepsilon\): a candidate with potential above \(\bar\varepsilon P^*_1\) is accepted outright.

reject_ratiofloat, default=0.15

Rejection ratio \(\underline\varepsilon\): a candidate with potential below \(\underline\varepsilon P^*_1\) is rejected and the search ends.

max_clustersint or None, default=None

Upper bound on the number of centers (None: no bound).

Attributes:
cluster_centers_ndarray of shape (n_clusters_, n_features)

The selected data points, in the original units.

center_indices_ndarray of shape (n_clusters_,)

Row indices of the centers in the training data.

n_clusters_int

Number of centers found.

potentials_ndarray of shape (n_clusters_,)

Potential \(P^*_i\) of every center at the moment of its selection, relative to the first (\(P^*_1=1\)).

initial_potentials_ndarray of shape (n_samples,)

Potential of every training sample before any subtraction (a density estimate).

membership_ndarray of shape (n_samples, n_clusters_)

Normalized Gaussian memberships of the training samples (predict_proba).

labels_ndarray of shape (n_samples,)

Nearest center of every training sample.

radii_ndarray of shape (n_features,)

Radii actually used (in the unit hypercube).

n_features_in_, feature_names_in_

Notes

With the data scaled to \([0,1]^n\) and \(\alpha=4/r_a^2\), \(\beta=4/r_b^2\), the potential of sample \(k\) is

\[P_k=\sum_{l=1}^{N}\exp\bigl(-\alpha\,\|\mathbf{x}_k-\mathbf{x}_l\|^2\bigr),\]

(with a per-feature radius the squared distance is \(\sum_j(x_{kj}-x_{lj})^2/r_j^2\) and \(\alpha=4\)). After the selection of the center \(\mathbf{x}^*_i\) with potential \(P^*_i\), the potentials are revised,

\[P_k\leftarrow P_k-P^*_i\exp\bigl(-\beta\,\|\mathbf{x}_k-\mathbf{x}^*_i\|^2\bigr),\]

and the candidate with the largest remaining potential is accepted if \(P^*>\bar\varepsilon P^*_1\), rejected (end) if \(P^*<\underline\varepsilon P^*_1\), and otherwise accepted only if \(d_{\min}/r_a+P^*/P^*_1\ge1\), where \(d_{\min}\) is its distance to the nearest existing center; a candidate that fails this test has its potential set to zero and the next one is examined. The returned centers can be passed as init to FCM or GK together with n_clusters_, and n_clusters_ of a run on the product-space data [X, y] is a rule-number estimate for TakagiSugeno.

References

[1]

S. L. Chiu, “Fuzzy model identification based on cluster estimation”, Journal of Intelligent and Fuzzy Systems 2(3), 267–278, 1994.

[2]

R. R. Yager, D. P. Filev, “Approximate clustering via the mountain method”, IEEE Transactions on Systems, Man, and Cybernetics 24(8), 1279–1284, 1994.

Examples

>>> from fuzzyclust.cluster import SubtractiveClustering, FCM
>>> from fuzzyclust.datasets import make_fuzzy_blobs
>>> X, _ = make_fuzzy_blobs(n_clusters=4, random_state=0)
>>> sub = SubtractiveClustering(radii=0.3).fit(X)
>>> int(sub.n_clusters_)
4
>>> fcm = FCM(n_clusters=sub.n_clusters_, init=sub.cluster_centers_).fit(X)
>>> fcm.n_iter_ < 20
True
fit(X, y=None)[source]#

Estimate the cluster centers.

Parameters:
Xarray_like of shape (n_samples, n_features)
yIgnored
Returns:
selfobject

Examples using fuzzyclust.cluster.SubtractiveClustering#

Subtractive clustering: the number and location of clusters from density

Subtractive clustering: the number and location of clusters from density