fuzzyclust.extensions.PFCM#

class fuzzyclust.extensions.PFCM(n_clusters=3, m=2.0, eta=2.0, a=1.0, b=1.0, gamma=None, gamma_scale=1.0, tol=0.0001, max_iter=300, init='fcm', n_init=1, random_state=None, verbose=0)[source]#

Bases: BaseFuzzyClusterer

Possibilistic fuzzy c-means clustering (Pal, Pal, Keller and Bezdek).

PFCM combines the two views of cluster membership. Every sample gets a probabilistic membership \(\mu_{ik}\) as in FCM (rows sum to one; a relative quantity that says which cluster the sample belongs to more) and a typicality \(t_{ik}\) as in PCM (an absolute quantity that says how representative the sample is of the cluster). The memberships keep the prototypes apart and so avoid the coincident clusters of PCM, the typicalities make the prototypes insensitive to outliers. The weights \(a\) and \(b\) set the relative influence of the two in the prototype update.

Parameters:
n_clustersint, default=3

Number of clusters \(c\).

mfloat, default=2.0

Exponent of the probabilistic memberships, \(m>1\).

etafloat, default=2.0

Exponent \(\eta>1\) of the typicalities (the paper’s \(\eta\); it plays the role of \(m\) in PCM).

afloat, default=1.0

Weight of the memberships in the objective (\(a\ge0\)).

bfloat, default=1.0

Weight of the typicalities (\(b\ge0\), not both zero). With b > a the prototypes follow the typicalities and become more robust to outliers; the paper recommends \(b>a\) for noisy data and warns that a very large \(b\) brings back the coincident clusters of PCM.

gammaNone, float or array_like of shape (n_clusters,), default=None

Possibilistic scales \(\gamma_i\). None estimates them from the initial FCM partition, see Notes.

gamma_scalefloat, default=1.0

Multiplier \(K\) of the estimated scales.

tolfloat, default=1e-4
max_iterint, default=300
init{“fcm”, “random”, “kmeans++”} or ndarray, default=”fcm”

As in PCM: an FCM run (or an explicit membership matrix) provides the initial partition and the scales.

n_initint, default=1

Number of restarts; the run with the lowest objective is kept.

random_stateint, RandomState instance or None, default=None
verboseint, default=0
Attributes:
cluster_centers_ndarray of shape (n_clusters, n_features)
membership_ndarray of shape (n_samples, n_clusters)

Probabilistic memberships \(\mu_{ik}\) (rows sum to one).

typicality_ndarray of shape (n_samples, n_clusters)

Typicalities \(t_{ik}\) (rows do not sum to one).

labels_ndarray of shape (n_samples,)

membership_.argmax(axis=1).

gamma_ndarray of shape (n_clusters,)

Scales \(\gamma_i\) used.

distances_, objective_, objective_history_, n_iter_

See BaseFuzzyClusterer.

Notes

PFCM minimizes

\[J = \sum_{i=1}^{c}\sum_{k=1}^{N}\left(a\,\mu_{ik}^m + b\,t_{ik}^{\eta}\right)D^2_{ik} + \sum_{i=1}^{c}\gamma_i\sum_{k=1}^{N}(1-t_{ik})^{\eta}\]

subject to \(\sum_i\mu_{ik}=1\) (no constraint on the typicalities), which gives the FCM membership formula for \(\mu_{ik}\), the PCM typicality formula with the scale \(\gamma_i/b\), and a prototype update weighted by both:

\[t_{ik} = \frac{1}{1+\left(b\,D^2_{ik}/\gamma_i\right)^{1/(\eta-1)}},\qquad \mathbf{v}_i = \frac{\sum_k\left(a\mu_{ik}^m+b\,t_{ik}^{\eta}\right)\mathbf{x}_k} {\sum_k\left(a\mu_{ik}^m+b\,t_{ik}^{\eta}\right)} .\]

The scales are set from the FCM partition as in PCM, \(\gamma_i = K\sum_k\mu_{ik}^m D^2_{ik}/\sum_k\mu_{ik}^m\). With \(b=0\) PFCM reduces to FCM, with \(a=0\) to PCM. predict_proba() returns the probabilistic memberships, predict_typicality() the typicalities of new samples.

References

[1]

N. R. Pal, K. Pal, J. M. Keller, J. C. Bezdek, “A possibilistic fuzzy c-means clustering algorithm”, IEEE Trans. Fuzzy Systems 13(4), 517–530, 2005.

Examples

>>> from fuzzyclust.extensions import PFCM
>>> from fuzzyclust.datasets import make_noisy_blobs
>>> X, _ = make_noisy_blobs(random_state=0)
>>> pfcm = PFCM(n_clusters=3, a=1.0, b=2.0, random_state=0).fit(X)
>>> pfcm.typicality_.shape
(330, 3)
>>> bool(abs(pfcm.membership_.sum(axis=1) - 1).max() < 1e-9)
True
predict_typicality(X)[source]#

Typicalities \(t_{ik}\) of (new) samples, shape (n_samples, n_clusters).

Examples using fuzzyclust.extensions.PFCM#

Possibilistic fuzzy c-means: memberships and typicalities together

Possibilistic fuzzy c-means: memberships and typicalities together