fuzzyclust.cluster.GG#

class fuzzyclust.cluster.GG(n_clusters=3, m=2.0, gamma=0.0, beta=1000000000000000.0, tol=0.0001, max_iter=300, init='random', n_init=1, random_state=None, verbose=0)[source]#

Bases: BaseFuzzyClusterer

Gath–Geva (GG) fuzzy clustering.

The distance of a sample to a cluster is the inverse of a (scaled) Gaussian density, so clusters are interpreted as Gaussian components with their own covariance and prior probability. GG therefore handles clusters of different shape, size and density, at the price of being more sensitive to initialization than FCM or GK (the exponential distance converges fast to a nearby local optimum). It is usually initialized with FCM or GK.

Parameters:
n_clustersint, default=3

Number of clusters \(c\).

mfloat, default=2.0

Fuzziness exponent. m == 1 gives the original fuzzy maximum likelihood estimation (FMLE) algorithm of Bezdek and Dunn; m == 2 is recommended because the exponential distance already produces rather crisp partitions.

gammafloat, default=0.0

Covariance regularization weight (shrinkage toward scaled identity), see GK.

betafloat, default=1e15

Condition-number bound of the covariance matrices.

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

Because of the sensitivity to initialization, passing the membership matrix of a fitted FCM/GK model is the recommended practice.

n_initint, default=1

Number of random restarts; the run with the lowest final \(J\) is kept (ignored when init is an array).

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)
labels_ndarray of shape (n_samples,)
distances_ndarray of shape (n_samples, n_clusters)

\(D_{ik}\) at convergence (square root of the GG distance).

covariances_ndarray of shape (n_clusters, n_features, n_features)

Fuzzy covariance matrices \(\mathbf{F}_{wi}\).

priors_ndarray of shape (n_clusters,)

Prior probabilities \(\alpha_i\).

eigenvalues_, eigenvectors_

Eigen-decomposition of covariances_ (ascending eigenvalues).

objective_, objective_history_, n_iter_

See BaseFuzzyClusterer.

Notes

The GG distance is

\[D^2_{ik} = \frac{\sqrt{\det\mathbf{F}_{wi}}}{\alpha_i} \exp\!\left(\tfrac12(\mathbf{x}_k-\mathbf{v}_i)^T\mathbf{F}_{wi}^{-1}(\mathbf{x}_k-\mathbf{v}_i)\right),\]

with the fuzzy covariance and the prior

\[\mathbf{F}_{wi} = \frac{\sum_k\mu_{ik}^{w}(\mathbf{x}_k-\mathbf{v}_i)(\mathbf{x}_k-\mathbf{v}_i)^T} {\sum_k\mu_{ik}^{w}},\qquad \alpha_i = \frac1N\sum_{k=1}^{N}\mu_{ik},\]

where the covariance weighting exponent \(w\) equals m (w = 2 by default, as in the MATLAB toolbox). Memberships and prototypes are updated with the FCM formulas. \(D^2_{ik}\) is the reciprocal of the posterior-weighted Gaussian density, so \(\mu_{ik}\) can be read as the posterior probability of cluster \(i\) given \(\mathbf{x}_k\). All exponentials are evaluated in the log domain for numerical stability.

References

[1]

I. Gath, A. B. Geva, “Unsupervised optimal fuzzy clustering”, IEEE Trans. Pattern Anal. Mach. Intell. 11(7), 1989.

[2]

J. C. Bezdek, J. C. Dunn, “Optimal fuzzy partitions: a heuristic for estimating the parameters in a mixture of normal distributions”, IEEE Trans. Computers, 1975.

Examples

>>> from fuzzyclust.cluster import FCM, GG
>>> from fuzzyclust.datasets import make_different_densities
>>> X, _ = make_different_densities(random_state=0)
>>> fcm = FCM(n_clusters=3, random_state=0).fit(X)
>>> gg = GG(n_clusters=3, init=fcm.membership_).fit(X)
>>> float(gg.priors_.sum().round(6))
1.0