fuzzyclust.extensions.NoiseClustering#

class fuzzyclust.extensions.NoiseClustering(n_clusters=3, m=2.0, delta=None, delta_scale=0.5, tol=0.0001, max_iter=300, init='random', n_init=1, random_state=None, verbose=0)[source]#

Bases: BaseFuzzyClusterer

Noise clustering: fuzzy c-means with a virtual noise cluster (Davé).

A fictitious noise prototype is added to the \(c\) real clusters. It has no position: it is defined to be at the same distance \(\delta\) from every sample. A sample far from all real prototypes is closer to the noise prototype than to any real one and therefore receives most of its membership in the noise cluster, so that it no longer influences the real prototypes. The memberships in the real clusters sum to less than one; the remainder is the noise membership. Compared with PCM the real clusters still interact through the probabilistic constraint, so coincident clusters do not occur; Davé and Krishnapuram [2] show that PCM is in fact noise clustering with one noise cluster per real cluster and \(\delta_i^2=\eta_i\), and relate both to robust M-estimators.

Parameters:
n_clustersint, default=3

Number of real clusters \(c\) (the noise cluster is extra).

mfloat, default=2.0

Fuzziness exponent \(m>1\).

deltafloat or None, default=None

Noise distance \(\delta\). None estimates it from the data at every iteration as \(\delta^2 = \lambda\,\overline{D^2}\), the scaled mean squared distance of all samples to all current prototypes (Davé’s rule, see Notes).

delta_scalefloat, default=0.5

Davé’s multiplier \(\lambda\) of the mean squared distance (used when delta=None). Smaller values declare more samples noise.

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

Number of random 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)

Prototypes of the real clusters.

membership_ndarray of shape (n_samples, n_clusters)

Memberships in the real clusters; rows sum to \(1-\mu_{*k}\).

noise_membership_ndarray of shape (n_samples,)

Membership \(\mu_{*k}\) in the noise cluster.

labels_ndarray of shape (n_samples,)

argmax over the real clusters, or -1 where the noise membership exceeds every real membership.

delta_float

Noise distance actually used (at the last iteration).

distances_, objective_, objective_history_, n_iter_

See BaseFuzzyClusterer.

Notes

Noise clustering minimizes the FCM functional with a \((c+1)\)-th cluster at constant distance \(\delta\),

\[J = \sum_{i=1}^{c}\sum_{k=1}^{N}\mu_{ik}^m D^2_{ik} + \sum_{k=1}^{N}\mu_{*k}^m\,\delta^2, \qquad \mu_{*k} = 1-\sum_{i=1}^{c}\mu_{ik}.\]

The memberships follow from the FCM formula extended by the noise term,

\[\mu_{ik} = \frac{1}{\sum_{j=1}^{c}\left(D^2_{ik}/D^2_{jk}\right)^{1/(m-1)} + \left(D^2_{ik}/\delta^2\right)^{1/(m-1)}},\]

and the prototypes are the usual weighted means of the real clusters: only the membership formula changes with respect to FCM. Davé proposed to tie \(\delta\) to the scale of the data,

\[\delta^2 = \lambda\,\frac{1}{Nc}\sum_{i=1}^{c}\sum_{k=1}^{N}D^2_{ik},\]

with a user-chosen \(\lambda\); \(\delta\) acts as a radius beyond which a sample is “more noise than member”. When delta is estimated the functional changes slightly from iteration to iteration, so the objective history need not be monotone. predict_proba() returns the memberships in the real clusters (rows sum to \(1-\mu_{*k}\)), predict_noise_membership() the noise membership, and predict() labels noise-dominated samples -1.

References

[1]

R. N. Davé, “Characterization and detection of noise in clustering”, Pattern Recognition Letters 12(11), 657–664, 1991.

[2]

R. N. Davé, R. Krishnapuram, “Robust clustering methods: a unified view”, IEEE Trans. Fuzzy Systems 5(2), 270–293, 1997.

Examples

>>> from fuzzyclust.extensions import NoiseClustering
>>> from fuzzyclust.datasets import make_noisy_blobs
>>> X, y = make_noisy_blobs(random_state=0)
>>> nc = NoiseClustering(n_clusters=3, delta_scale=0.2, random_state=0).fit(X)
>>> nc.membership_.shape, nc.noise_membership_.shape
((330, 3), (330,))
>>> bool((nc.labels_ == -1).sum() > 0)
True
predict(X)[source]#

Hard labels of (new) samples; -1 marks noise-dominated samples.

predict_noise_membership(X)[source]#

Noise membership \(\mu_{*k}\) of (new) samples, shape (n_samples,).

Examples using fuzzyclust.extensions.NoiseClustering#

Noise clustering: a virtual cluster at constant distance δ

Noise clustering: a virtual cluster at constant distance δ