Fuzzy Clustering and Data Analysis in PythonThe fuzzyclust toolbox

Chapter 6
Robust and shape-oriented variants of fuzzy c-means

Fuzzy c-means rests on three assumptions: the memberships of every sample sum to one, every cluster is a point in the data space, and the distance to that point is Euclidean. This chapter relaxes them one at a time, each time by a small change to the FCM template of chapter 3—a different membership formula, distance, or prototype update—and all methods live in fuzzyclust.extensions with the common interface of the toolbox. Possibilistic c-means, possibilistic fuzzy c-means, and noise clustering drop or loosen the sum-to-one constraint, so that outliers are recognized instead of being shared out among the clusters. Kernel fuzzy c-means measures the distance in the feature space of a kernel, where rings and moons become spheres; fuzzy c-varieties and c-shells replace the point by a line or a circle; volume prototypes replace it by a core of zero distance, which removes the bias toward clusters of equal size and, with adaptive merging, finds the number of clusters during the iteration; and feature weights learned with the partition adapt the distance to the features that matter. The graph-based methods of the next chapter take the opposite route and abandon the prototype altogether.

6.1 Problem and idea

Two things can go wrong when fuzzy c-means meets real data. The first is the partition. The constraint ∑ ⁡ iμik = 1 makes every membership a relative quantity: it says to which prototype a sample is closer, not whether it is close to any of them. A sample far from all prototypes still shares a total membership of one among them and, since the prototype update (3.7) weighs every sample by μikm, such an outlier pulls the prototypes toward itself. The second is the prototype. A point prototype with a fixed norm describes spherical clusters (section 3.2.3), one with an adaptive norm ellipsoidal clusters (sections 3.2.4 and 3.2.5); a group of points along a line, a ring, or a curved arc has no useful center, and the algorithm tiles it into spherical or ellipsoidal pieces.

Figure 6.1

Figure 6.1. Three prototypes and the distance each of them induces; the dashed curves are level sets of the distance. A point prototype measures how far a sample is from the center, so it detects compact groups. A linear variety—here a line through vi with unit direction si—measures only the orthogonal distance to the line, so samples anywhere along the line are equally close to it. A shell prototype, a center with a radius ri, measures the radial deviation from the circle, so every point of a hollow ring is at zero distance from it. The membership formula of FCM is used unchanged with each of these distances.

The methods of this chapter attack both problems from inside the FCM template. Figure 6.1 shows the prototype side: a line and a shell are prototypes just as a point is, each with its own distance, and the alternating optimization of section 2.2.5 needs nothing but that distance and a rule to update the prototype from the memberships. A kernel reaches the same end by a different route: it keeps the point prototype but places it in a feature space in which the Euclidean distance is a curved function of the input coordinates, so that one sphere there can enclose a ring.

Figure 6.2

Figure 6.2. Relative versus absolute membership along the line through two prototypes at 0 and 4 (both with m = 2 and, for PCM, ηi = 1). The FCM memberships cross at the midpoint and decay only slowly beyond the prototypes: an outlier at 9 is a member of cluster 2 with membership 0.76 and shifts its prototype. The PCM typicalities are bumps of width η i around the prototypes and decay to zero on both sides, so the outlier is atypical of both clusters and has almost no weight in either prototype.

Figure 6.2 shows the partition side. Along the line through two prototypes, the FCM membership of either cluster crosses 1∕2 at the midpoint and, on the far side of its own prototype, stays above 1∕2 however far away the sample lies, because out there that prototype is always the closer one. A membership that expresses how typical a sample is of a cluster must instead decay with the distance to that cluster alone. This is the possibilistic membership of Krishnapuram and Keller [14], introduced in section 2.2.3 as the partition space Mpc. Decoupling the clusters has a price—they may coincide—and two further designs keep the coupling: the possibilistic fuzzy c-means [63] carries both kinds of membership, and Davé’s noise clustering [64] keeps the sum-to-one constraint but adds one more cluster to share with, a noise cluster at the same distance δ from every sample (fig. 6.3). A sample farther than about δ from all real prototypes gives most of its membership to the noise cluster, and the real clusters receive only what is left.

Figure 6.3

Figure 6.3. Noise clustering adds a fictitious prototype v∗ that has no position but is at the same distance δ from every sample. The real memberships keep the FCM form and, together with the noise membership μ∗k, still sum to one; the dashed circles of radius δ mark where a sample is as close to the noise prototype as to a real one. The outlier is farther than δ from both real prototypes, so most of its membership goes to the noise cluster and it no longer moves v1 or v2, while the real clusters still compete for every sample near the groups.

6.2 Theory

The notation is that of the book: X ∈ ℝN×n with rows xk, memberships μik in U ∈ ℝc×N (stored transposed in the code), prototypes vi with index i or j, samples with index k, squared distances Dik2. The reference point throughout is fuzzy c-means (section 3.2.3): the functional J = ∑ ⁡ i ∑ kμikmDik2 (3.3), the membership formula (3.6), and the prototype update (3.7). For each method we state which of the three it changes. Sections 6.2.1 to 6.2.3 change the partition, section 6.2.4 the distance, sections 6.2.5 and 6.2.6 the prototype; section 6.2.7 turns the point prototype into a volume and section 6.2.8 learns the distance as a weighting of the features.

6.2.1 Possibilistic c-means

Krishnapuram and Keller [14] drop the constraint ∑ ⁡ iμik = 1. Without it the FCM functional is minimized by the trivial partition μik = 0, so a term is added that rewards memberships close to one, with a cluster-specific weight ηi > 0:

J(X;T,V) = ∑ i=1c ∑ k=1Nt ikmD ik2 + ∑ i=1cη i ∑ k=1N(1 −t ik)m.
(6.1)

The memberships are now called typicalities and written tik; the matrix T replaces U. Setting the derivative with respect to tik to zero gives mtikm−1Dik2 = mηi(1 −tik)m−1, hence

tik = 1 1 + (Dik2∕ηi )1∕(m−1),vi = ∑ ktikmxk ∑ ktikm .
(6.2)

The prototype update is (3.7) with typicalities in place of memberships; the typicality replaces (3.6). Three properties follow directly. First, tik depends on Dik2 and ηi only, not on the distances to the other prototypes: it is an absolute measure, tik = 1∕2 exactly at Dik2 = ηi, and η i is the radius of the zone of influence of cluster i. Second, m no longer controls the fuzziness of a partition but the decay of the typicality: for large distances tik ≈(ηi∕Dik2)1∕(m−1), so an outlier at three times the radius ηi keeps a typicality of about 0.1 with m = 2 and of about 0.01 with m = 1.5. The follow-up paper [65] therefore recommends m around 1.5 for PCM, smaller than the FCM default. Third, (6.1) is a sum of c terms, each involving only the typicalities ti and the prototype vi of one cluster: the clusters are optimized independently, PCM amounts to c separate mode-seeking procedures, and nothing prevents two of them from converging to the same dense region. These coincident clusters are the characteristic failure of PCM [65], and they are the reason the method is best used as a robust refinement of a partition that FCM has already found rather than as a stand-alone clusterer.

The scales ηi govern the result. The original paper estimates them from a probabilistic partition—in practice from an FCM run, which also initializes the typicalities—as the fuzzy intra-cluster mean squared distance,

ηi = K∑ kμikmDik2 ∑ kμikm ,K = 1,
(6.3)

or alternatively as the mean squared distance of the samples whose membership exceeds an α-cut. The factor K widens (K > 1) or narrows (K < 1) the zones of influence: too large a K lets the outliers back in and draws the prototypes together, too small a K leaves the tails of a cluster atypical. The original paper already proposes an optional second phase: after convergence, the scales are re-estimated from the α-cut of the typicalities and PCM is run once more. The 1996 paper recommends keeping the scales fixed during the iterations, since re-estimating them from the typicalities shrinks the clusters. fuzzyclust follows this recommendation: ηi is computed once from the FCM partition with the factor eta_scale and then kept fixed; explicit scales can be passed through eta, which is also the way to run the second phase. Since the rows of T do not sum to one, predict_proba returns typicalities, and the hard label argmax ⁡ itik of a sample that is atypical everywhere means little; the maximal typicality max ⁡ itik is a natural outlier score.

Algorithm

In a nutshell: Possibilistic c-means

  • Drops the sum-to-one constraint: the typicality tik depends only on the distance to prototype i relative to the scale ηi; outliers are atypical of every cluster and do not move the prototypes.
  • Same prototype update as FCM; the typicality formula (6.2) replaces the membership formula. m sets the decay of the typicality (1.5 is a good value), ηi the zone of influence, estimated once from an FCM run with a factor K.
  • The clusters do not interact: two prototypes may coincide when the scales are too wide or the groups are close—initialize with FCM, keep K ≤1, and use PCM as a robust refinement and outlier detector.

6.2.2 Possibilistic fuzzy c-means

Pal, Pal, Keller, and Bezdek [63] keep both descriptions. Every sample has a probabilistic membership μik (constrained, ∑ ⁡ iμik = 1) and a typicality tik (unconstrained), and both enter the functional,

J = ∑ i=1c ∑ k=1N (aμ ikm + bt ikη )D ik2 + ∑ i=1cγ i ∑ k=1N(1 −t ik)η,
(6.4)

with weights a,b ≥0 (not both zero), the FCM exponent m > 1 for the memberships, an exponent η > 1 for the typicalities (the paper’s symbol; it plays the role of m in PCM), and scales γi as in PCM. The necessary conditions separate: the memberships follow the FCM formula (3.6), the typicalities the PCM formula with the scale γi∕b, and the prototypes are weighted by both,

tik = 1 1 + (bDik2∕γi )1∕(η−1),vi = ∑ k (aμikm + btikη )xk ∑ k (aμikm + btikη ) .
(6.5)

With b = 0 the method is FCM, with a = 0 it is PCM. The membership term keeps the prototypes apart: every sample has to be shared, so two prototypes on the same group would each receive half of its membership mass, while the samples of the other group, which must give their membership to one of the two, pull one of them away. The typicality term keeps the outliers out of the prototype update. The ratio b∕a sets the balance, and the paper recommends b > a for noisy data. Two details matter in practice. First, the weight b also appears inside the typicality, so raising b alone tightens the zone of influence to γi∕b instead of reproducing PCM; it is the membership weight a relative to the effective scale that decides whether the prototypes stay separated, and PFCM tolerates scales several times wider than PCM before clusters coincide (section 6.4.2). Second, with tight scales the typicalities of the core samples themselves fall below one, the weight btikη of the robust term shrinks, and the membership term, which the outliers still contaminate, regains influence; the scales should therefore not be made tighter than the clusters. The scales are set as in PCM, γi = K∑ ⁡ kμikmDik2∕∑ kμikm, from the FCM partition that also initializes the method.

Algorithm

In a nutshell: Possibilistic fuzzy c-means

  • Memberships (relative, FCM formula) and typicalities (absolute, PCM formula) side by side; both enter the prototype update, with weights a and b.
  • The memberships keep the prototypes apart, the typicalities keep the outliers out; b∕a ≈2–5 with scales from FCM is a sound choice, and a large a keeps the prototypes separated over a wide range of scales.
  • η sets the decay of the typicality as m does in PCM; b also tightens the effective scale γi∕b. predict_proba returns memberships, predict_typicality typicalities.

6.2.3 Noise clustering

Davé [64] keeps the probabilistic constraint and adds a (c + 1)-th cluster: the noise prototype v∗, which has no position and is defined to be at the same distance δ from every sample. The functional is the FCM functional with this extra cluster,

J = ∑ i=1c ∑ k=1Nμ ikmD ik2 + ∑ k=1Nμ ∗kmδ2,μ ∗k = 1 −∑ i=1cμ ik,
(6.6)

and the Lagrange conditions give the FCM membership formula extended by the noise term in the denominator,

μik = 1 ∑ j=1c (Dik2∕Djk2 )1∕(m−1) + (Dik2∕δ2 )1∕(m−1),
(6.7)

while the prototypes of the real clusters are the FCM weighted means (3.7). Only the membership formula changes. A sample much closer than δ to some prototype hardly notices the extra term; a sample farther than δ from all of them has Dik2∕δ2 > 1 for every i, so its real memberships shrink and the remainder μ∗k goes to the noise cluster (fig. 6.3). The real clusters still compete for every sample through the constraint, so the coincident clusters of PCM do not occur, and the memberships of the real clusters close around the groups instead of tiling the whole plane. The only parameter is δ, which acts as a radius beyond which a sample is more noise than member. Davé tied it to the scale of the data through the mean squared distance of all samples to all current prototypes,

δ2 = λ 1 Nc∑ i=1c ∑ k=1ND ik2,
(6.8)

with a user-chosen multiplier λ. Since that mean is dominated by the distances between the groups, λ has to be well below one to catch outliers near a group, while a very small λ starts to declare the tails of the groups noise; λ ≈0.1–0.5 is the range worth scanning, and a fixed δ can be given when the noise radius is known. When δ is not given, fuzzyclust re-estimates it from the current prototypes at every iteration, so the functional changes slightly between iterations and J need not decrease monotonically. Davé and Krishnapuram [66] later unified the two approaches: PCM is noise clustering with one noise cluster per real cluster and δi2 = ηi, and both are instances of the robust M-estimators of statistics [67], in which the typicality weight tikm and the noise-reduced membership act as redescending weight functions that give far samples a vanishing influence.

Algorithm

In a nutshell: Noise clustering

  • FCM with one extra, position-less prototype at distance δ from every sample; only the membership formula (6.7) changes.
  • Samples farther than δ from all real prototypes migrate to the noise cluster, the real memberships close around the groups, and the prototypes are protected; the clusters keep competing, so they do not coincide.
  • δ2 = λD2¯ with λ ≈0.1–0.5, or a fixed δ; the noise membership μ∗k is an outlier score, and noise-dominated samples are labeled −1. PCM is NC with one noise cluster per real cluster.

6.2.4 Kernel fuzzy c-means

A Mercer kernel K(x,y) = ⟨Φ(x),Φ(y)⟩ is an inner product in a feature space H reached by a map Φ that is never computed [68]; the Gaussian kernel K(x,y) = exp ⁡ (−γ ‖x −y‖2) is the usual choice. Kernel fuzzy c-means runs FCM in H: the functional and the membership formula are those of FCM, and the distance is the feature-space distance ‖Φ(xk) −wi‖ 2 to a prototype wi ∈H. Spheres in H are curved regions in the input space, which is how a ring or a moon can become one cluster. Following the comparative study of Graves and Pedrycz [69], we distinguish two variants by where the prototype lives.

Prototypes in the feature space. The prototype is the weighted mean of the mapped samples, wi = ∑ ⁡ kωikΦ(xk) with ωik = μikm∕∑ ⁡ lμilm—the minimizer of ∑ ⁡ kμikm ‖Φ(xk) −wi‖ 2 over H. Expanding the squared distance and replacing every inner product by a kernel value gives

Dik2 = K(x k,xk) −2∑ l=1Nω ilK(xk,xl) + ∑ l,l′=1Nω ilωil′K(xl,xl′),
(6.9)

the fuzzy counterpart of kernel k-means [70]. The prototype never appears explicitly: it is represented by its weights ωil over the training samples, the N ×N kernel matrix is computed once, and (6.9) with a new sample x in place of xk gives its distances and memberships. Any Mercer (positive semidefinite) kernel can be used; the price is O(N2) memory and prototypes that have no exact pre-image in the input space (fuzzyclust reports the weighted means ∑ ⁡ lωilxl for plotting only). The code also accepts the sigmoid kernel tanh ⁡ (γxTy + c0), which is not positive semidefinite in general: (6.9) can then turn negative, the toolbox clips it at zero, and the result is no longer a distance in any feature space.

Prototypes in the input space. Zhang and Chen [71] keep vi in the input space and use the distance between the mapped sample and the mapped prototype, which for the Gaussian kernel is

Dik2 = ‖Φ(x k) −Φ(vi)‖2 = 2 (1 −K(x k,vi) ),vi = ∑ kμikmK(xk,vi)xk ∑ kμikmK(xk,vi) ,
(6.10)

where the prototype update, obtained by setting the gradient to zero, is a fixed-point iteration in which every sample is additionally weighted by its kernel similarity to the current prototype. The distance saturates at 2 for far samples, so outliers lose their influence: this variant is a robust FCM. The distance is, however, a monotone function of ‖xk −vi‖, so its hard partition boundaries are the same bisecting hyperplanes as those of FCM, and it cannot find rings.

For both variants the decisive parameter is γ, which sets the width of the kernel (a large γ means a narrow kernel). As γ →0 the Gaussian kernel becomes linear in the squared distance and kernel FCM collapses to FCM; as γ →∞ all mapped samples become mutually orthogonal, every sample is equally far from every prototype, and the partition is arbitrary. The usable window, where 1∕γ is about the gap between the structures to be separated, spans less than a decade, and inside it the exponent m must be close to one, because in the nearly orthogonal feature space a fuzzy exponent spreads the memberships out and makes every prototype the mean of all samples. Graves and Pedrycz found over many data sets that kernel FCM is not uniformly better than FCM and that the kernel parameter is hard to set, and the examples of section 6.4.4 agree. Kernel FCM separates rings that no point prototype can, but for data on clear manifolds the geodesic methods of chapter 7 are the more forgiving tool.

Algorithm

In a nutshell: Kernel fuzzy c-means

  • FCM in the feature space of a kernel: same functional and membership formula, the distance is evaluated through kernel values only.
  • Feature-space prototypes (weights over the samples) find rings and moons, at O(N2) memory; input-space prototypes with the Gaussian kernel give a robust FCM whose cells are still convex.
  • 1∕γ must match the gap between the structures, and the usable window is narrow; use a nearly crisp m, several restarts, and a scan over γ.

6.2.5 Fuzzy c-varieties and c-elliptotypes

Bezdek, Coray, Gunderson, and Watson [72, 73] replace the point prototype by an r-dimensional linear variety (affine subspace)

V i = {vi + ∑ j=1rτ jsij : τ ∈ ℝr },s ijTs il = δjl,
(6.11)

which is a point for r = 0 (FCM), a line for r = 1 (fuzzy c-lines, FCL), and a hyperplane for r = n −1. The squared distance of a sample to the cluster is its squared orthogonal distance to the variety, that is, the squared distance to the center minus the squared projections onto the directions,

Dik2 = ‖x k −vi‖ 2 −∑ j=1r ((x k −vi)Ts ij )2,
(6.12)

and the functional is the c-means functional with this distance. Fixing the prototypes gives the FCM membership formula; fixing the memberships, the center is again the fuzzy mean (3.7), and the directions that minimize J are the r unit eigenvectors belonging to the largest eigenvalues of the fuzzy scatter matrix of the cluster,

Si = ∑ k=1Nμ ikm(x k −vi)(xk −vi)T,
(6.13)

because ∑ ⁡ kμikmDik2 = tr ⁡ Si −∑ ⁡ jsijTSisij is minimized by directing the sij along the largest spread. The prototype step is a membership-weighted principal component analysis per cluster; the retained eigenvalues measure the spread along the variety, the discarded ones the scatter around it, and their ratio tells how line-like the cluster is. The ellipsoids of Gustafson–Kessel (section 3.2.4) stretch along a line but still measure the position along it; a line prototype measures only the distance from the line, so it separates lines that cross at a point, which GK and FCM have to cut into pieces (fig. 6.19).

The price of a prototype without extent is that collinear groups merge into one cluster: two segments on the same line, however far apart, lie at zero distance from the same line prototype. Bezdek et al. [73] therefore consider convex combinations ∑ ⁡ rαrJr of the FCV functionals of different dimension, whose prototypes are “elliptotypes” between a point and a line. The two-term combination of r = 0 and r = 1 is the fuzzy c-elliptotypes algorithm (FCE): for the same center and direction its distance is the convex combination of the point and the line distance,

Dik,FCE2 = α ‖x k −vi‖ 2 + (1 −α)D ik,FCL2,α ∈[0,1],
(6.14)

so that the position along the line counts with weight α and collinear groups separate; α = 1 is FCM. The weight should be as small as the data allow. In the example of section 6.4.5, α = 0.05 already separates two collinear segments, whereas three crossing lines lose accuracy at α = 0.1 and are no longer found from α = 0.2 on, because near a crossing the position along a line must not count. Lines through a common point are hard for a random start, since a single run often puts two prototypes on one line, so restarts are advisable.

Algorithm

In a nutshell: Fuzzy c-varieties

  • Prototype = r-dimensional linear variety (line, plane) through the fuzzy mean, spanned by the leading eigenvectors of the fuzzy scatter matrix; distance = squared orthogonal distance to it; membership formula unchanged.
  • Groups samples by the subspace they lie on, not by position: separates crossing lines that FCM and GK cut into pieces; the discarded eigenvalues measure the scatter around the variety.
  • Merges collinear groups—a small elliptotype weight α of the point distance (0.05 in the example) is the remedy, but α ≥0.1 already spoils crossing lines; use restarts for lines through a common point.

6.2.6 Fuzzy c-shells and c-spherical shells

A ring has no samples in its interior, so the point prototype at its center is far from every member, and two concentric rings have the same center: no point prototype can tell them apart. Shell clustering describes cluster i by a center vi and a radius ri and measures the distance of a sample as its deviation from the sphere. The two published algorithms implemented here differ in this distance. Davé’s fuzzy c-shells algorithm (FCS) [74] uses the squared radial (geometric) deviation, and the fuzzy c-spherical shells algorithm (FCSS) of Krishnapuram, Nasraoui, and Frigui [75] the squared algebraic distance,

Dik,FCS2 = ( ‖x k −vi‖ −ri )2,D ik,FCSS2 = ( ‖x k −vi‖ 2 −r i2 )2,
(6.15)

both used in the c-means functional with the FCM membership formula. The two algorithms differ in the prototype update. For FCS the necessary conditions,

ri = ∑ kμikm ‖xk −vi‖ ∑ kμikm ,∑ kμikm (1 − ri ‖xk −vi‖ )(xk −vi) = 0,
(6.16)

are coupled and nonlinear in vi, and Davé solved them by Newton’s method in every iteration. FCSS avoids this inner iteration: the algebraic distance is ‖xk‖ 2 + piTyk with the reparametrized prototype pi = [−2viT,viTvi −ri2]T and the regressors yk = [xkT,1]T, i.e. linear in pi, so the weighted least-squares minimizer is in closed form,

pi = − (∑ kμikmy kykT )−1 ∑ kμikm ‖x k‖ 2y k, vi = −1 2pi,1:n,ri2 = v iTv i −pi,n+1,
(6.17)

one (n + 1) ×(n + 1) solve per cluster and iteration. Near the shell the two distances are related by ‖x‖2 −r2 = ( ‖x‖ −r)( ‖x‖ + r) ≈2r( ‖x‖ −r): the algebraic distance is about 2ri times the radial deviation, so the same radial deviation counts more on a large shell than on a small one, and FCSS memberships favor small shells. The bias shows when nested shells of similar radius have to be separated or when only arcs are observed; FCS does not have it. fuzzyclust implements both: algorithm="fcss" is the default, and algorithm="fcs" refines the closed-form fit in every iteration by newton_steps Gauss–Newton steps on the radial residuals, a numerically convenient form of Davé’s Newton solution. The initialization deserves attention. Shell clustering has a notorious local minimum—one big circle through everything, with the other shells fitting noise—and a random start rarely escapes it when the shells intersect; the hardened partition of an FCM run is then a good start, because the FCM groups lie on different shells. For concentric shells FCM halves every ring and both shells converge to the mean radius; here the further restarts of n_init, which start from random point prototypes and are selected by J, find the rings.

Algorithm

In a nutshell: Fuzzy c-shells

  • Prototype = center and radius; distance = deviation from the sphere (radial in FCS, algebraic in FCSS); the membership formula is that of FCM.
  • FCSS has a closed-form least-squares update and is the default; FCS needs Newton steps but is unbiased with respect to the shell size (FCSS favors small shells).
  • Start from the hardened FCM partition for separate or intersecting shells and use restarts for concentric shells; the results are the radii and the signed radial residuals.

6.2.7 Volume prototypes and adaptive cluster merging

A point prototype measures how far a sample is from the center of a cluster. A sample in the outer part of a large cluster can therefore be closer to the prototype of a small neighboring cluster than to its own, and the membership formula hands it to the neighbor: FCM and GK equalize the clusters, splitting a large diffuse group and letting small groups absorb its pieces (section 3.4.6). Gath–Geva solves the problem with densities and priors at the price of a sensitive iteration. Kaymak and Setnes [43] keep the stable FCM iteration and change the prototype: a volume prototype is a hypersphere (or, in the adaptive norm of GK, a hyperellipsoid) of radius ri around vi, and only the distance to its surface counts,

D~ik = max ⁡ (0,DikAi −ri),DikAi2 = (x k −vi)TA i(xk −vi),
(6.18)

with Ai = I or the GK norm (3.10). The functional is the c-means functional with D~ik2; the memberships follow the FCM formula (3.6) with D~ik in place of Dik, so a sample inside exactly one core belongs fully to that cluster; and the centers are the μikm-weighted means. The radius adapts to the cluster. Kaymak and Setnes derive it from the fuzzy covariance matrix as (det ⁡ Fi)1∕(2n), the geometric mean of the standard deviations along the principal axes, so that a sphere of that radius has the volume of the cluster, and they multiply it by a factor that grows as the clusters merge. The toolbox uses a simpler estimate, recomputed at every iteration: the membership-weighted mean distance of the data from the center,

ri = κ∑ kμikmDikAi ∑ kμikm ,
(6.19)

with a fixed scale factor κ (default one); κ = 0 recovers FCM or GK. A large cluster thus has a large core, its outer members are near the surface of that core, and they stay with it. Cores that grow too large are the failure mode of the method: a core that reaches across a neighboring group swallows it, so κ should not be raised above one (section 6.4.7).

Adaptive cluster merging. Kaymak and Setnes combine the volume prototypes with merging during the iteration. The algorithm starts with a deliberately large number of clusters. They measure the similarity of two clusters by the fuzzy inclusion measure Iij = ∑ ⁡ k min ⁡ (μik,μjk)∕∑ ⁡ kμik, symmetrized as Sij = max ⁡ (Iij,Iji), and in every iteration in which the largest similarity has changed by less than a tolerance they merge the most similar pair, provided that its similarity exceeds the threshold 1∕(c −1), which rises as the number c of clusters falls; the iteration continues with one cluster fewer. The toolbox uses a variant that is the similarity criterion of compatible cluster merging (section 4.2.7) built into the iteration: it merges only when the partition has converged for the current number of clusters, it measures the similarity by the ratio of fuzzy intersection and union, Sij = ∑ ⁡ k min ⁡ (μik,μjk)∕∑ ⁡ k max ⁡ (μik,μjk) (4.17), and its threshold is fixed. Inside the cores the memberships are nearly crisp, which would hide the overlap of two clusters that share a group, so the toolbox evaluates the similarity on the memberships that the center distances alone would give, rescaled to m = 2; two clusters on one group then have Sij ≈0.25–0.35, and the default threshold is 0.2.

Algorithm

In a nutshell: Volume prototypes and adaptive merging

  • A prototype is a core of radius ri with zero distance inside; only the distance to the core surface counts, which removes the size-equalizing bias of point prototypes.
  • Spherical (Euclidean) or ellipsoidal (GK norm) cores; the radius is re-estimated from the cluster, κ = 0 is FCM/GK; keep κ ≤1.
  • Adaptive merging starts with too many clusters and merges similar pairs during the iteration; the final number is insensitive to the starting number.
  • Stays within the stable FCM iteration; a lighter alternative to Gath–Geva for clusters of different size.
  • Parameters: n_clusters, m, norm, radius, radius_scale, merge, similarity_threshold, gamma, beta; attributes radii_, n_clusters_, merge_history_.

6.2.8 Learning which features matter

The Euclidean distance of FCM gives every feature the same weight. After standardization, a feature of pure noise contributes as much to Dik2 as a feature that separates the clusters, and enough such features drown the structure. Clusters that are defined by different features, one tight along x1 and another along x2, cannot be described by one shared norm at all. The two methods of this section learn feature weights together with the partition. Both use the per-feature squared distances dikj2 = (xkj −vij)2 and the membership-weighted scatter of a cluster along a feature,

sij = ∑ k=1Nμ ikmd ikj2,
(6.20)

and both reward a feature along which the members of the clusters scatter little.

Weighted fuzzy c-means. The simpler of the two gives all clusters a common weight vector α, ∑ ⁡ jαj = 1, raised to an exponent t > 1,

J = ∑ i=1c ∑ k=1Nμ ikm ∑ j=1nα jtd ikj2,α j = 1 ∑ l=1n(sj∕sl)1∕(t−1),sj = ∑ i=1cs ij.
(6.21)

This is the fuzzy form of the automated variable weighting that Huang, Ng, Rong, and Li [76] proposed for k-means; Keller and Klawonn [77] had introduced the same kind of functional with one weight for each variable and each cluster, which is the form of SCAD-2 below. The weight update has the form of the FCM membership formula with the total scatter of a feature in place of the distance to a prototype. The weights define the diagonal of a learned norm-inducing matrix A = diag ⁡ (αjt), which places the method between FCM with the fixed diagonal norm and GK with its full, cluster-specific norm. As m does for the memberships, the exponent t controls how sharply the weight concentrates: t →1 puts all weight on the feature of smallest scatter, and t →∞ gives uniform weights.

SCAD. Frigui and Nasraoui’s simultaneous clustering and attribute discrimination [78] gives every cluster its own weights wij, ∑ ⁡ jwij = 1, as Keller and Klawonn did, so that different clusters can live in different subspaces. SCAD-1 uses the weights linearly and prevents the trivial solution—all weight on the single feature of smallest scatter—by a quadratic term with a cluster-specific coefficient δi,

J1 = ∑ i=1c ∑ k=1Nμ ikm ∑ j=1nw ijdikj2 + ∑ i=1cδ i ∑ j=1nw ij2, wij = 1 n + 1 2δi(1 n∑ l=1ns il −sij),δi = K∑ kμikm ∑ jwijdikj2 ∑ jwij2 , (6.22)

where the weight of a feature rises above 1∕n when the cluster scatters less along it than on average. Negative weights are set to zero and the row is renormalized, and δi is re-estimated from the current partition so that the two terms of the functional stay balanced (K is a scale factor, default one). SCAD-2 raises the weights to an exponent q > 1 instead and needs no δi,

J2 = ∑ i=1c ∑ k=1Nμ ikm ∑ j=1nw ijqd ikj2,w ij = 1 ∑ l=1n(sij∕sil)1∕(q−1);
(6.23)

its weights are never exactly zero. In both versions the memberships follow the FCM formula with the weighted distance Dik2 = ∑ ⁡ jwijdikj2 (or wijq), and the centers are the μikm-weighted means, since each coordinate of a center minimizes its own weighted sum of squares. The level sets of the weighted distance are axis-parallel ellipsoids, stretched along the features a cluster ignores.

Two cautions apply to both methods. First, the weights reward a small within-cluster scatter, so the features must be on comparable scales: a feature of small variance attracts the weight regardless of its relevance, and even among standardized features one along which the data can be cut into c thin slices may attract all of it when the exponent is close to one. Second, the weights are learned from the partition: if the noise features already dominate the first iterations, the partition carries no information and the weights stay uniform. Feature weighting raises the number of noise features that FCM tolerates; it does not replace feature selection when most features are irrelevant (section 6.4.8).

Algorithm

In a nutshell: Weighted fuzzy c-means

  • One weight vector for all clusters, learned with the partition: a learned diagonal norm diag ⁡ (αjt).
  • Down-weights features along which the clusters scatter widely (noise features); reports a global feature relevance.
  • Standardize first; keep t well above one (t ≈3), otherwise the weight concentrates on one feature.
  • Parameters: n_clusters, m, t; attribute feature_weights_.

Algorithm

In a nutshell: SCAD

  • A weight vector per cluster: clusters may be defined by different features (subspace clusters), and an irrelevant feature is down-weighted in every cluster.
  • SCAD-1: linear weights with a balancing quadratic term, may give exact zeros; SCAD-2: weights with an exponent q, never zero, sharper for q near one.
  • Same cost as FCM plus O(Ncn) for the scatters; standardize first.
  • Parameters: n_clusters, m, variant, q, delta, delta_scale; attributes feature_weights_(c,n), delta_.

6.3 Using it in fuzzyclust

The nine estimators of this chapter live in fuzzyclust.extensions. They derive from BaseFuzzyClusterer and share the common interface: fit, predict, predict_proba, transform, score, the n_init restarts, and pandas input. What predict_proba returns depends on the method and is stated in every docstring: memberships that sum to one (kernel FCM, FCV, shells, volume prototypes, the feature-weighted methods, and PFCM), typicalities that do not (PCM), or real memberships whose rows sum to 1 −μ∗k (noise clustering).

fuzzyclust.extensions.PCM

n_clusters=3, m=2.0, eta=None, eta_scale=1.0, tol, max_iter, init="fcm"|"random"|"kmeans++"|array, n_init=1, random_state, verbose.
Attributes cluster_centers_, typicality_ (= membership_, rows not normalized), labels_, eta_. predict_proba and predict_typicality return typicalities. Use m ≈1.5; eta_scale is the factor K of (6.3). An init array holds either initial FCM prototypes (c,n) or an initial partition (N,c), such as the membership_ of a fitted FCM or GK model.

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, max_iter, init="fcm", n_init=1, random_state, verbose.
Attributes membership_ (rows sum to one), typicality_, gamma_, labels_. predict_proba gives memberships, predict_typicality typicalities. b = 0 is FCM, a = 0 is PCM.

fuzzyclust.extensions.NoiseClustering

n_clusters=3, m=2.0, delta=None, delta_scale=0.5, tol, max_iter, init, n_init=1, random_state, verbose.
Attributes membership_ (real clusters, rows sum to 1 −μ∗k), noise_membership_, delta_, labels_ ( −1 for noise-dominated samples). delta_scale is λ of (6.8); predict_noise_membership(X) for new data.

fuzzyclust.extensions.KernelFCM

n_clusters=3, m=2.0, kernel="rbf"|"poly"|"linear"|"sigmoid"|"cosine"| "laplacian", gamma=None, degree=3, coef0=1.0, prototypes="feature"| "input", tol, max_iter, init, n_init=1, random_state, verbose.
Kernels through sklearn.metrics.pairwise; gamma=None uses 1∕(nVar(X)). prototypes="input" is the Zhang–Chen variant (Gaussian kernel only). Attributes membership_, cluster_centers_ (approximate pre-images for "feature"), gamma_; predict_proba uses the kernelized distance (6.9).

fuzzyclust.extensions.FuzzyCVarieties

n_clusters=3, m=2.0, n_dims=1, alpha=0.0, tol, max_iter, init, n_init=1, random_state, verbose.
Attributes cluster_centers_, directions_ (c ×r ×n), scatter_matrices_, covariances_, eigenvalues_ (descending), membership_. n_dims=0 is FCM, alpha the elliptotype weight of (6.14).

fuzzyclust.extensions.FuzzyCShells

n_clusters=3, m=2.0, algorithm="fcss"|"fcs", newton_steps=2, tol, max_iter, init="fcm"|"random"|"kmeans++"|array, n_init=1, random_state, verbose.
Attributes cluster_centers_, radii_, membership_; distances_ and transform are | ‖xk −vi‖ 2 −ri2| for FCSS and | ‖xk −vi‖ −ri| for FCS; radial_deviation(X) gives the signed radial deviation for both.

fuzzyclust.extensions.VolumePrototypeFCM

n_clusters=3, m=2.0, norm="euclidean"|"adaptive", radius="fuzzy_mean", radius_scale=1.0, merge=False, similarity_threshold=0.2, gamma=0.0, beta=1e15, tol, max_iter, init, n_init=1, random_state, verbose.
radius is "fuzzy_mean" (6.19), a number or an array of c fixed radii; gamma, beta regularize the adaptive norm as in GK. With merge=True, n_clusters is the starting number and max_iter applies per number of clusters. Attributes radii_, n_clusters_, merge_history_ (iteration, number of clusters, pair, similarity), covariances_, norm_matrices_; distances_ and transform return D~ik, zero inside the cores.

fuzzyclust.extensions.FeatureWeightedFCM

n_clusters=3, m=2.0, t=2.0, tol, max_iter, init, n_init=1, random_state, verbose.
t > 1 is the weight exponent of (6.21). Attributes feature_weights_ (n,) summing to one, covariances_ (unweighted); distances_ and transform return the weighted distances.

fuzzyclust.extensions.SCAD

n_clusters=3, m=2.0, variant="scad1"|"scad2", q=2.0, delta=None, delta_scale=1.0, tol, max_iter, init, n_init=1, random_state, verbose.
delta=None re-estimates δi by (6.22) with the factor delta_scale = K; a number or an array fixes it (SCAD-1). q is the exponent of SCAD-2. Attributes feature_weights_ (c,n) with rows summing to one, delta_, covariances_.

data generators and plot helpers

In fuzzyclust.extensions: make_circles (intersecting circles, arcs, outliers), make_close_blobs (coincident-cluster test case), make_crossing_lines, and make_collinear_segments; the examples also use make_noisy_blobs, make_rings, make_two_moons, and make_different_densities from fuzzyclust.datasets. Plots: plot_typicality(X, T) (scatter colored by max ⁡ itik, also for 1 −μ∗k), plot_varieties(X, model), and plot_shells(X, model); the generic fuzzyclust.plotting.plot_membership_contours works for all estimators of the chapter through predict_proba.

The robust variants are drop-in replacements for FCM; the possibilistic ones are seeded by FCM internally:

fcm = FCM(n_clusters=3, random_state=0).fit(X) 
pcm = PCM(n_clusters=3, m=1.5, random_state=0).fit(X) 
print(f"scales eta_i = {pcm.eta_.round(2)}") 
print(f"center error: FCM {center_error(fcm.cluster_centers_):.3f}, PCM {center_error(pcm.cluster_centers_):.3f}")
   
pfcm = PFCM(n_clusters=3, a=1.0, b=4.0, m=2.0, eta=2.0, random_state=0).fit(X) 
U, T = pfcm.membership_, pfcm.typicality_ 
print(f"rows of U sum to one: {np.allclose(U.sum(axis=1), 1.0)};  typicality mass per sample: " 
      f"inliers {T[inliers].sum(axis=1).mean():.2f}, outliers {T[~inliers].sum(axis=1).mean():.2f}")
   
fcm = FCM(n_clusters=3, random_state=0).fit(X) 
nc = NoiseClustering(n_clusters=3, delta_scale=0.3, random_state=0).fit(X) 
n_noise = (nc.labels_ == -1).sum() 
print(f"noise distance delta = {nc.delta_:.2f}; {n_noise} samples labeled noise, " 
      f"{((nc.labels_ == -1) & ~inliers).sum()} of them true outliers") 
print(f"center error: FCM {center_error(fcm.cluster_centers_):.3f}, noise clustering {center_error(nc.cluster_centers_):.3f}")
   

The kernel and shape variants change the distance or the prototype and expose what they find (the kernel parameter, the line orientations, the radii):

fcm_r = FCM(n_clusters=2, random_state=0).fit(rings[0]) 
kfcm_r = KernelFCM(n_clusters=2, kernel="rbf", gamma=0.3, m=1.2, n_init=5, random_state=0).fit(rings[0]) 
fcm_m = FCM(n_clusters=2, random_state=0).fit(moons[0]) 
kfcm_m = KernelFCM(n_clusters=2, kernel="rbf", gamma=15.0, m=1.1, n_init=5, random_state=0).fit(moons[0]) 
for name, (_, y), f, k in (("rings", rings, fcm_r, kfcm_r), ("moons", moons, fcm_m, kfcm_m)): 
    print(f"{name}: FCM ARI = {adjusted_rand_score(y, f.labels_):.2f}, " 
          f"kernel FCM (gamma = {k.gamma_:g}) ARI = {adjusted_rand_score(y, k.labels_):.2f}")
   
fcm = FCM(n_clusters=3, n_init=5, random_state=0).fit(X) 
gk = GK(n_clusters=3, n_init=5, random_state=0).fit(X) 
fcl = FuzzyCVarieties(n_clusters=3, n_dims=1, n_init=5, random_state=0).fit(X) 
angles = np.degrees(np.arctan2(fcl.directions_[:, 0, 1], fcl.directions_[:, 0, 0])) % 180 
print(f"FCM ARI = {adjusted_rand_score(y, fcm.labels_):.2f}, GK ARI = {adjusted_rand_score(y, gk.labels_):.2f}, " 
      f"fuzzy c-lines ARI = {adjusted_rand_score(y, fcl.labels_):.2f}") 
print(f"line orientations found: {np.sort(angles).round(1)} degrees (true: 0, 60, 120)")
   
fcm_r = FCM(n_clusters=2, random_state=0).fit(Xr) 
fcss_r = FuzzyCShells(n_clusters=2, algorithm="fcss", n_init=5, random_state=0).fit(Xr) 
fcss_c = FuzzyCShells(n_clusters=3, algorithm="fcss", random_state=0).fit(Xc) 
print(f"rings: FCM ARI = {adjusted_rand_score(yr, fcm_r.labels_):.2f}, FCSS ARI = " 
      f"{adjusted_rand_score(yr, fcss_r.labels_):.2f}, radii found {np.sort(fcss_r.radii_).round(2)} (true 1, 3)") 
ce, re = match(fcss_c, true_c, true_r) 
print(f"circles: FCSS ARI = {adjusted_rand_score(yc, fcss_c.labels_):.2f}, " 
      f"largest center error {ce:.3f}, largest radius error {re:.3f}")
   

Volume prototypes are a drop-in replacement for FCM, and with merge=True the number of clusters becomes a result:

fcm = FCM(n_clusters=3, n_init=5, random_state=0).fit(X) 
vp = VolumePrototypeFCM(n_clusters=3, n_init=5, random_state=0).fit(X) 
print(f"ARI: FCM {adjusted_rand_score(y, fcm.labels_):.2f}, volume prototypes {adjusted_rand_score(y, vp.labels_):.2f}") 
print("core radii r_i:", np.round(vp.radii_, 2))
   
vpm = VolumePrototypeFCM(n_clusters=8, merge=True, similarity_threshold=0.2, random_state=0).fit(X) 
for step in vpm.merge_history_: 
    print(f"iteration {step[’iteration’]:3d}: c = {step[’n_clusters’]} -> merge {step[’pair’]} " 
          f"(S = {step[’similarity’]:.2f})") 
print(f"final number of clusters: {vpm.n_clusters_}, ARI = {adjusted_rand_score(y, vpm.labels_):.2f}")
   

The feature-weighted methods return the learned weights next to the partition:

common = dict(n_clusters=3, m=1.3, init="kmeans++", n_init=5, random_state=0) 
fcm = FCM(**common).fit(X) 
wfcm = FeatureWeightedFCM(t=3.0, **common).fit(X)  # one weight vector for all clusters 
scad = SCAD(variant="scad1", **common).fit(X)  # one weight vector per cluster 
for name, model in (("FCM", fcm), ("weighted FCM", wfcm), ("SCAD-1", scad)): 
    print(f"{name:13s} ARI = {adjusted_rand_score(y, model.labels_):.2f}") 
print("global weights:", np.round(wfcm.feature_weights_, 2))
   
scad2 = SCAD(n_clusters=3, variant="scad2", q=2.0, n_init=5, random_state=0).fit(X_bands) 
print("SCAD-2 weights (rows: clusters, columns: x1, x2):") 
print(np.round(scad2.feature_weights_, 2))
   

6.4 Examples

The first three examples share one data set, generated by make_noisy_blobs: three Gaussian groups of 100 points (σ = 0.6, centers 4.2 to 7.5 apart) with 60 uniformly scattered outliers. The “center error” reported is the largest distance between an estimated prototype and the sample mean of the matched true group. FCM, pulled outward by the outliers, has a center error of 0.20 on this data set; without the outliers it would be 0.02.

6.4.1 PCM: typicalities, scales, and coincident clusters

With m = 1.5 and scales ηi = (2.7,3.4,2.6) from the FCM run, PCM brings the center error down to 0.04 (fig. 6.4). The maximal typicality separates the two populations cleanly—median 0.97 for the inliers, 0.09 for the outliers—and the 44 samples below a threshold of 0.2 are all true outliers. The contour maps show the difference in kind: the FCM maximal membership never drops below 1∕3 and rises again far from the data, whereas the PCM typicality is a bump of width η i around every prototype and vanishes elsewhere. Figure 6.5 shows the same along a probe line through two centers, the empirical counterpart of fig. 6.2. The parameter study (fig. 6.6) varies the scale factor K and the exponent. For m = 1.5 the center error is below 0.05 for K = 0.5 and K = 1 (0.08 at K = 0.25) and rises to 0.28 at K = 2; for m = 2 it is already 0.17 at K = 1; and for m = 3 the typicality decays so slowly that the outliers keep a mean maximal typicality of 0.3 at K = 1 and PCM is worse than FCM for every K (center error 0.24 or more). The coincident-cluster failure (fig. 6.7) appears on a group of 200 points next to a group of 40 at a distance of 2.5. With K = 0.5 the two prototypes are 2.5 apart; with K = 1 they coincide (|v1 −v2|= 0.00) and the small group is lost. FCM never shows this failure, because its memberships compete.

Figure 6.4

Figure 6.4. FCM memberships (left) and PCM typicalities (middle) on three groups with 60 outliers: the FCM contours tile the plane and the centers are pulled outward, the PCM contours are bumps around the prototypes. The maximal typicality of every sample (right) singles out the outliers; stars are the true group means.

Open in ColabExample plot_01_pcm_typicality.py in the gallery

Figure 6.5

Figure 6.5. Along a line from one center through another and beyond, the FCM memberships cross at the midpoint and stay high beyond the prototypes, whereas the PCM typicalities peak at the prototypes and vanish on both sides.

Figure 6.6

Figure 6.6. Center error (left) and mean maximal typicality of the outliers (right) against the scale factor K for three exponents: m = 1.5 with K ≤1 is robust, too large a K lets the outliers back in, and too large an m makes the typicality decay too slowly.

Figure 6.7

Figure 6.7. Coincident clusters: a large group next to a small, close one. With K = 0.5 the two PCM prototypes are separated, with K = 1 and beyond they drift into the large group together; the dashed circles have radius η i.

6.4.2 PFCM: the a∕b trade-off

PFCM with a = 1 and b = 4 returns both matrices on the noisy blobs (fig. 6.8): memberships whose rows sum to one and whose contours are the familiar FCM cells, and typicalities that sum to 0.60 per inlier against 0.13 per outlier and flag the outliers as PCM does. The study of the weights (fig. 6.9, left) shows the center error dropping from the FCM value 0.20 as soon as the typicalities enter the update (b ≥0.5 gives 0.05–0.09). The right panel shows what the memberships buy on the coincident-cluster data: PCM merges the two prototypes at K = 1, PFCM with a = b = 1 keeps them apart at K = 1, halves their distance at K = 2, and nearly merges them at K = 4, and with a = 20 the prototypes stay about 2 apart for every scale factor up to 16; fig. 6.10 shows the three partitions at K = 4. Raising b alone does not reproduce PCM, because b also tightens the effective scale γi∕b inside the typicality. The printed study of η and the scale factor confirms that a smaller η makes the outliers less typical (mean maximal typicality 0.05 at η = 1.5 against 0.22 at η = 3, for K = 1). It also reveals the second effect discussed in section 6.2.2: with tight scales (K = 0.5) the center error rises to 0.12–0.13 for every η, because the typicalities of the core samples shrink and the membership term regains weight, whereas K = 2 with η = 2 gives 0.045.

Figure 6.8

Figure 6.8. PFCM on the noisy blobs: the memberships (left) sum to one and partition the plane, the typicalities (right) are bumps around the prototypes and flag the outliers.

Open in ColabExample plot_02_pfcm_trade_off.py in the gallery

Figure 6.9

Figure 6.9. Left: center error on the noisy blobs against the typicality weight b (with a = 1); b = 0 is FCM. Right: distance between the two prototypes on the coincident-cluster data against the scale factor K for PCM and for PFCM with increasing membership weight a.

Figure 6.10

Figure 6.10. Partitions of the coincident-cluster data at K = 4: PCM merges the prototypes, PFCM with a = b = 1 nearly merges them, and PFCM with a = 20 keeps them on their groups.

6.4.3 Noise clustering: the multiplier λ

With λ = 0.3 the noise distance comes out at δ = 3.0 (fig. 6.11): 31 samples are labeled noise, all of them true outliers, the center error is 0.06, and the membership contours of the real clusters close around the groups where those of FCM tile the plane. Along the probe line (fig. 6.12) the real memberships decay and the noise membership takes over beyond δ. The scan over λ (fig. 6.13) maps the trade-off. With λ = 0.1 (δ = 1.7), 50 of the 60 outliers and one inlier are labeled noise, with a center error of 0.03; λ = 0.02 declares 128 inliers noise, and the partition of the inliers degrades (ARI 0.34); λ ≥2 (δ ≥7.8) labels nothing noise, and the center error climbs back to 0.14–0.17. The outliers that escape at moderate λ are those that fell inside a group. Figure 6.14 shows three of these partitions with the circles of radius δ. A fixed δ = 106 reproduces FCM exactly (largest noise membership 3 ⋅10−11, center error 0.20).

Figure 6.11

Figure 6.11. FCM (left) and noise clustering with λ = 0.3 (middle) on the noisy blobs; the dashed circles have radius δ and the gray samples are labeled noise. Right: the membership 1 −μ∗k in the real clusters.

Open in ColabExample plot_03_noise_clustering.py in the gallery

Figure 6.12

Figure 6.12. Memberships along a probe line through two centers: in noise clustering the real memberships decay and the noise membership (dashed) takes over beyond δ.

Figure 6.13

Figure 6.13. Number of true outliers and of inliers labeled noise (left) and center error (right) against the multiplier λ.

Figure 6.14

Figure 6.14. Partitions for λ = 0.05, 0.3, and 2: a small λ peels the tails off the groups, a large one lets every outlier back in.

6.4.4 Kernel FCM on rings and moons

The data are two concentric rings of radii 1 and 3 and two moons with a gap of about 0.3. FCM reaches adjusted Rand indices of 0.00 and 0.26; kernel FCM with feature-space prototypes recovers both exactly, with γ = 0.3 and m = 1.2 on the rings and γ = 15 and m = 1.1 on the moons, each with five restarts (fig. 6.15). The contours of the maximal membership, evaluated on a grid through the kernelized distance (6.9), follow the rings and bend around the moons. The crosses are the approximate pre-images of the prototypes and play no role in the distances; on the rings both lie near the origin. The scan over γ (fig. 6.16) shows the narrow window: on the rings only γ ∈[0.2,0.5] succeeds (γ ≤0.1 behaves like FCM, γ ≥1 fragments the rings), on the moons γ ∈[10,30]. At the chosen values 1∕γ is 1.8 and 0.26, the gap between the structures in each case. Figure 6.17 shows the rings at γ = 0.05, 0.3, and 5, the last with a mean maximal membership of 0.5, that is, an uninformative partition. The exponent matters as much: at γ = 0.3 the rings are found for m ≤1.5, whereas with m = 2 the agreement drops to 0.96 and with m = 3 to 0.27, because every feature-space prototype approaches the mean of all mapped samples. A polynomial kernel of degree two or three does not recover the rings (ARI 0.19 and 0.18). In the quadratic monomials a circle is a hyperplane, and one such hyperplane does separate the two rings, but the outer ring is spread over that space far more widely than the inner one, and a partition that splits it has the smaller J; the linear kernel is FCM. The input-space variant (fig. 6.18) cannot find rings but is a robust FCM: on the noisy blobs its center error is 0.03–0.04 for γ between 0.1 and 0.3 and below 0.09 from γ = 0.03 to 1, against 0.20 for FCM.

Figure 6.15

Figure 6.15. FCM (left) and kernel FCM with feature-space prototypes (right) on two rings (top) and two moons (bottom); contours of the maximal membership evaluated through the kernelized distance.

Open in ColabExample plot_04_kernel_fcm.py in the gallery

Figure 6.16

Figure 6.16. Agreement with the true groups against the kernel parameter γ on the rings (m = 1.2) and the moons (m = 1.1); the dashed line is FCM.

Figure 6.17

Figure 6.17. The rings with γ = 0.05 (FCM-like halves), γ = 0.3 (the rings), and γ = 5 (orthogonal feature space, arbitrary partition).

Figure 6.18

Figure 6.18. Kernel FCM with input-space prototypes on the noisy blobs: the saturating distance makes it a robust FCM (left), for a wide range of γ (right).

6.4.5 Fuzzy c-varieties on crossing lines, and the elliptotype α

The data are three lines of 80 points through a common point, at 0∘, 60∘, and 120∘ (fig. 6.19). FCM tiles the plane into three cells (ARI 0.09); GK stretches its ellipsoids but cannot align one with each line without swallowing the centers of the others (ARI 0.33); fuzzy c-lines recovers the three lines (ARI 0.96) with orientations 60.2∘, 120.2∘, and 179.8∘ ≡−0.2∘. The only ambiguous points are those near the crossing, which are close to all three lines. The membership contours are bands around the lines, and the eigenvalues of the scatter matrices show a spread along each line about 600 times larger than the scatter around it (fig. 6.20). The elliptotype study (fig. 6.21) uses two collinear segments with a gap and an oblique third segment. Pure fuzzy c-lines (α = 0) sees the collinear segments as one line and spends a prototype on noise (ARI 0.49), and α = 0.05 already separates them (ARI 1.0). On the crossing lines, in contrast, the agreement falls from 0.96 at α = 0 and 0.95 at α = 0.05 to 0.83 at α = 0.1 and to 0.2 or less for α ≥0.2: where lines cross, the position along the line must not count. The printed studies show the need for restarts (mean ARI over ten seeds 0.73 with one start, 0.96 with ten), the usual role of m, and two planes in three dimensions recovered with n_dims=2 (ARI 0.95, normals along the y and z axes).

Figure 6.19

Figure 6.19. Three lines through one point: FCM tiles the plane (left), GK cuts the lines into ellipsoidal pieces (middle), and fuzzy c-lines finds the lines (right).

Open in ColabExample plot_05_fuzzy_c_varieties.py in the gallery

Figure 6.20

Figure 6.20. Fuzzy c-lines: the maximal membership is a band around each line (left); the eigenvalues of the fuzzy scatter matrices separate the spread along the lines from the scatter around them (right).

Figure 6.21

Figure 6.21. Two collinear segments and an oblique one, clustered with α = 0 (left; the collinear segments form one line) and with α = 0.3 (middle), and the agreement against α for these data and for the crossing lines (right).

6.4.6 Fuzzy c-shells: radius recovery

FCM halves two concentric rings (ARI 0.00), whereas FCSS with five restarts recovers them with radii 1.00 and 3.00. On three circles of radii 2, 1.2, and 1, two of which intersect, FCSS started from the FCM-hardened partition finds the centers to within 0.015 and the radii to within 0.007, with an ARI of 0.97; the points near the intersections have shared memberships (fig. 6.22). The membership contours are rings around the fitted circles, and the signed radial residuals of the samples from their own shell are centered at zero, with a spread close to the generating noise level (fig. 6.23). The initialization study (fig. 6.24) shows the two faces of the FCM start. On the concentric rings a single run converges to two circles of radius 2.1 and 2.2 through both rings (J = 746), five restarts find the rings (J = 62), and over ten seeds the FCM start needs ten restarts to succeed every time, while random point prototypes need three. On the intersecting circles, conversely, the FCM start succeeds at once (ARI 0.97) and a single random start fails (ARI 0.08). The comparison of the two algorithms on three concentric rings of radii 1, 1.6, and 3 (fig. 6.25) exposes the small-shell bias of the algebraic distance: both find the rings from the best of ten restarts, but over five seeds FCS reaches a mean ARI of 0.90 against 0.80 for FCSS, because the algebraic distance weights the same radial deviation about three times more on the outer ring than on the inner one. On the intersecting circles the two algorithms agree to within 0.01 in centers and radii for every m, and m only sets how strongly the memberships are shared at the intersections.

Figure 6.22

Figure 6.22. FCM on two concentric rings (left) and FCSS on the same rings (middle) and on three circles, two of which intersect (right); the fitted circles and their centers are drawn.

Open in ColabExample plot_06_fuzzy_c_shells.py in the gallery

Figure 6.23

Figure 6.23. Maximal membership around the two fitted rings (left) and the signed radial residuals of the samples from their own shell on the intersecting circles (right).

Figure 6.24

Figure 6.24. Concentric rings from the FCM-hardened start with a single run (left; two circles through both rings) and with five restarts (middle), and the agreement over ten seeds against the number of restarts for three initializations (right).

Figure 6.25

Figure 6.25. Three concentric rings of radii 1, 1.6, and 3 with FCSS (left) and FCS (right), both from the best of ten restarts.

6.4.7 Volume prototypes on clusters of different size

The script plot_08_volume_prototypes.py returns to the data of section 3.4.6: a large diffuse group of 300 samples next to two small dense ones. FCM splits the large group and gives a slice of it to each small cluster (adjusted Rand index 0.70); with volume prototypes the cores grow to radii 1.65, 0.83, and 0.56, and the large cluster keeps its members (ARI 0.85; fig. 6.26). The membership profile along the line from the center of the large group to that of the smallest one (fig. 6.27) shows the mechanism. The memberships are one inside both cores, and the border between the clusters, where the two memberships cross, lies at 0.61 of the way instead of 0.43 for FCM, whose small-cluster prototype has in addition been pulled toward the large group.

Figure 6.26

Figure 6.26. FCM (left) and fuzzy clustering with volume prototypes (right) on a large diffuse group and two small dense ones; the dashed circles are the cores, inside which the distance is zero.

Open in ColabExample plot_08_volume_prototypes.py in the gallery

Figure 6.27

Figure 6.27. Memberships along the line from the center of the large group to the center of the smallest one: with volume prototypes (solid) the memberships are one inside the shaded cores and the border moves toward the small cluster; FCM (dotted) for comparison.

Started with eight clusters, adaptive merging performs five merges, at similarities between 0.26 and 0.34: the first joins the two clusters that share the wider of the two small groups, the other four join pieces of the large group. It ends with three clusters and the same partition as before (fig. 6.28). The parameter study (fig. 6.29) confirms the recommendations of section 6.2.7. The agreement rises with the radius scale from the FCM value 0.70 at κ = 0 to 0.85 at κ = 1 and collapses beyond it (0.29 at κ = 1.25), when a core grows over a neighboring group. The merging threshold has a plateau at three clusters from 0.15 to 0.25; a threshold of 0.30 stops at five clusters, thresholds of 0.35 and above do not merge at all, and 0.10 merges distinct groups down to one cluster. Started with any number of clusters from four to twelve, the merging ends at three.

Figure 6.28

Figure 6.28. Adaptive cluster merging: eight volume prototypes before merging (left) and the three clusters with their cores after five merges (right).

Figure 6.29

Figure 6.29. Parameter study: agreement with the true groups against the radius scale κ (left), final number of clusters against the similarity threshold (middle) and against the starting number of clusters (right).

6.4.8 Feature weights: noise features and subspace clusters

The script plot_07_feature_weighting.py adds six standardized noise features to three groups in two informative features (m = 1.3 for all methods, because in eight dimensions the FCM memberships with m = 2 are nearly uniform). FCM still finds the groups, but with errors (ARI 0.92); the weighted FCM with t = 3 and SCAD-1 recover them exactly (fig. 6.30). The global weights of the weighted FCM are 0.24 and 0.25 for the informative features and 0.09 for every noise feature. The SCAD-1 weights show the same pattern in every cluster, but less sharply (0.16 to 0.18 against 0.09 to 0.12), because the automatic δi keeps the weights near uniform unless the scatters differ strongly.

Figure 6.30

Figure 6.30. Two informative and six noise features. Left: the weighted FCM partition in the informative features. Middle: the global weights αj concentrate on x1 and x2. Right: the SCAD-1 weights of every cluster.

Open in ColabExample plot_07_feature_weighting.py in the gallery

On three clusters that live in different subspaces (a band tight along x1, a band tight along x2, and a compact blob), SCAD-2 assigns 0.98 and 0.99 of the weight to the feature along which each band is tight and splits the weight of the blob evenly (0.49, 0.51); the level sets of the weighted distances are ellipses stretched along the feature a cluster ignores (fig. 6.31). The partition itself is no better than that of FCM (ARI 0.90 for both, because the ends of the bands are ambiguous); what SCAD adds is the description of every cluster by its relevant features. The parameter study (fig. 6.32) varies the number of noise features. FCM degrades steadily (ARI 0.96 with four, 0.81 with eight), the weighted FCM stays at 1.00 and SCAD-1 at 0.98 or above up to eight, and from ten noise features on all methods fail, because the partition of the first iterations is already dominated by noise and the weights are learned from it. The exponent study shows the concentration trap: with t = 1.5 or 2 the weighted FCM puts 0.98 or 0.80 of the weight on the informative features but cuts the data along a single one of them (ARI 0.47), while every t ≥2.5 finds the groups.

Figure 6.31

Figure 6.31. SCAD-2 on clusters in different subspaces: level sets of the weighted distance of every cluster (left) and the weights (right); each band weights the feature along which it is tight.

Figure 6.32

Figure 6.32. Parameter study: agreement with the true groups against the number of noise features for FCM, the weighted FCM, and SCAD-1 (left), and agreement and total weight of the informative features against the weight exponent t of the weighted FCM with four noise features (right).

6.5 Further reading

The possibilistic c-means was introduced in [14], and its insights and recommendations (the exponent, the fixed scales, the coincident clusters) are in [65]; the possibilistic fuzzy c-means is from [63]. Noise clustering is from [64], and the unified view of PCM, noise clustering, and robust statistics [67] is given in [66]. Kernel fuzzy c-means with input-space prototypes is from [71], and its application to incomplete data from [79]; the feature-space variant is the fuzzy counterpart of the kernel k-means of [70]; the comparative study of both against FCM is [69]; and kernels in general are treated in [68]. Fuzzy c-lines and fuzzy c-varieties with their convex combinations are introduced in the two papers [72, 73], within the framework of Bezdek’s book [3]. Fuzzy c-shells is from [74] and the fuzzy c-spherical shells algorithm from [75]; the family of shell algorithms for ellipses and quadrics, together with their possibilistic versions, is surveyed in [80]. The Gustafson–Kessel algorithm [18], with which the c-varieties are compared, is treated in section 3.2.4, and the graph-based methods that find arbitrary shapes without a prototype follow in chapter 7. Volume prototypes and adaptive cluster merging are due to Kaymak and Setnes [43]; the similarity by which the toolbox merges is that of [42]. The weighted fuzzy c-means with global attribute weights is the fuzzy form of the variable-weighted k-means of Huang et al. [76]; cluster-specific weights with an exponent are due to Keller and Klawonn [77], and simultaneous clustering and attribute discrimination, with its regularized and exponent forms, to Frigui and Nasraoui [78].