fuzzyclust.extensions.FuzzyCVarieties#
- class fuzzyclust.extensions.FuzzyCVarieties(n_clusters=3, m=2.0, n_dims=1, alpha=0.0, tol=0.0001, max_iter=300, init='random', n_init=1, random_state=None, verbose=0)[source]#
Bases:
BaseFuzzyClustererFuzzy c-varieties (FCV) clustering: linear-variety prototypes (Bezdek et al.).
The prototype of cluster \(i\) is an \(r\)-dimensional linear variety (affine subspace) \(V_i=\{\mathbf{v}_i+\sum_{j=1}^{r}t_j\mathbf{s}_{ij}\}\) through the center \(\mathbf{v}_i\) spanned by orthonormal directions \(\mathbf{s}_{i1},\dots,\mathbf{s}_{ir}\). With \(r=1\) the prototypes are lines (fuzzy c-lines, FCL), with \(r=0\) points (FCM), with \(r=n-1\) hyperplanes. The distance of a sample to a cluster is its squared orthogonal distance to the variety, so data lying along lines or planes are grouped by the subspace they belong to rather than by their position along it – a sharper tool for linear structure than Gustafson–Kessel, whose ellipsoids still measure the position along the line. Because a line is infinitely long, two groups of points that happen to be collinear are merged; the fuzzy c-elliptotypes (FCE) compromise
alphamixes in the ordinary point distance to keep the clusters local.- Parameters:
- n_clusters
int, default=3 Number of clusters \(c\).
- m
float, default=2.0 Fuzziness exponent \(m>1\).
- n_dims
int, default=1 Dimension \(r\) of the varieties, \(0\le r<n\).
- alpha
float, default=0.0 Elliptotype weight \(\alpha\in[0,1]\) of the point distance: \(D^2 = \alpha\|\mathbf{x}_k-\mathbf{v}_i\|^2 + (1-\alpha)D^2_{\mathrm{FCV}}\).
0gives pure c-varieties,1FCM.- 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. Lines through a crossing have several local optima, so restarts are advisable.
- random_state
int,RandomStateinstanceorNone, default=None - verbose
int, default=0
- n_clusters
- Attributes:
- cluster_centers_
ndarrayofshape(n_clusters,n_features) Centers \(\mathbf{v}_i\) of the varieties (fuzzy means).
- directions_
ndarrayofshape(n_clusters,n_dims,n_features) Orthonormal direction vectors \(\mathbf{s}_{ij}\) (rows).
- scatter_matrices_
ndarrayofshape(n_clusters,n_features,n_features) Fuzzy scatter matrices \(\mathbf{S}_i\) whose leading eigenvectors are the directions.
- covariances_
ndarrayofshape(n_clusters,n_features,n_features) Fuzzy covariance matrices \(\mathbf{F}_i=\mathbf{S}_i/\sum_k\mu_{ik}^m\) (same eigenvectors; for the ellipse plots of the toolbox).
- eigenvalues_
ndarrayofshape(n_clusters,n_features) Eigenvalues of \(\mathbf{S}_i\) in descending order; the first \(r\) belong to the directions, the rest measure the scatter around the variety.
- membership_, labels_, distances_, objective_, objective_history_, n_iter_
See
BaseFuzzyClusterer.
- cluster_centers_
Notes
FCV minimizes the c-means functional \(J=\sum_i\sum_k\mu_{ik}^m D^2_{ik}\) with the squared orthogonal distance to the variety,
\[D^2_{ik} = \|\mathbf{x}_k-\mathbf{v}_i\|^2 - \sum_{j=1}^{r}\left((\mathbf{x}_k-\mathbf{v}_i)^T\mathbf{s}_{ij}\right)^2 .\]The necessary conditions are the FCM membership formula, the fuzzy mean for \(\mathbf{v}_i\) (unchanged from FCM), and for the directions the \(r\) unit eigenvectors belonging to the largest eigenvalues of the fuzzy scatter matrix
\[\mathbf{S}_i = \sum_{k=1}^{N}\mu_{ik}^m(\mathbf{x}_k-\mathbf{v}_i)(\mathbf{x}_k-\mathbf{v}_i)^T ,\]i.e. a membership-weighted principal component analysis per cluster. Bezdek et al. [2] also consider convex combinations \(\sum_r\alpha_r J_r\) of the FCV functionals of different dimension; the two-term combination of \(r=0\) and \(r=1\) (
alphaabove) is the fuzzy c-elliptotypes algorithm, whose prototypes are “elliptotypes” between a point and a line and whose distance, for the same \(\mathbf{v}_i\) and \(\mathbf{s}_{i1}\), is simply the convex combination of the two distances.References
[1]J. C. Bezdek, C. Coray, R. Gunderson, J. Watson, “Detection and characterization of cluster substructure. I. Linear structure: fuzzy c-lines”, SIAM J. Appl. Math. 40(2), 339–357, 1981.
[2]J. C. Bezdek, C. Coray, R. Gunderson, J. Watson, “Detection and characterization of cluster substructure. II. Fuzzy c-varieties and convex combinations thereof”, SIAM J. Appl. Math. 40(2), 358–372, 1981.
Examples
>>> from fuzzyclust.extensions import FuzzyCVarieties >>> from fuzzyclust.datasets import make_lines >>> X, y = make_lines(n_lines=3, random_state=0) >>> fcv = FuzzyCVarieties(n_clusters=3, n_dims=1, n_init=3, random_state=0).fit(X) >>> fcv.directions_.shape (3, 1, 2)
Examples using fuzzyclust.extensions.FuzzyCVarieties#
Fuzzy c-varieties: lines as prototypes, and the elliptotype compromise