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:
BaseFuzzyClustererNoise 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_clusters
int, default=3 Number of real clusters \(c\) (the noise cluster is extra).
- m
float, default=2.0 Fuzziness exponent \(m>1\).
- delta
floatorNone, default=None Noise distance \(\delta\).
Noneestimates 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_scale
float, default=0.5 Davé’s multiplier \(\lambda\) of the mean squared distance (used when
delta=None). Smaller values declare more samples noise.- tol
float, default=1e-4 - max_iter
int, default=300 - init{“random”, “kmeans++”}
orndarray, default=”random” - n_init
int, default=1 Number of random restarts; the run with the lowest objective is kept.
- random_state
int,RandomStateinstanceorNone, default=None - verbose
int, default=0
- n_clusters
- Attributes:
- cluster_centers_
ndarrayofshape(n_clusters,n_features) Prototypes of the real clusters.
- membership_
ndarrayofshape(n_samples,n_clusters) Memberships in the real clusters; rows sum to \(1-\mu_{*k}\).
- noise_membership_
ndarrayofshape(n_samples,) Membership \(\mu_{*k}\) in the noise cluster.
- labels_
ndarrayofshape(n_samples,) argmaxover the real clusters, or-1where 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.
- cluster_centers_
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
deltais 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, andpredict()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
Examples using fuzzyclust.extensions.NoiseClustering#
Noise clustering: a virtual cluster at constant distance δ