fuzzyclust.viz.pca_projection#
- fuzzyclust.viz.pca_projection(X, n_components=2, centers=None)[source]#
Project the data and the cluster prototypes onto the first principal components.
PCA finds the \(q\)-dimensional linear subspace that captures the largest part of the variance of the data. The eigenvectors \(\mathbf{w}_1,\dots,\mathbf{w}_q\) of the data covariance matrix
\[\mathbf{F} = \frac{1}{N}\sum_{k=1}^{N}(\mathbf{x}_k-\bar{\mathbf{x}})(\mathbf{x}_k-\bar{\mathbf{x}})^T\]with the \(q\) largest eigenvalues span the projection plane and the embedding of a sample is \(\mathbf{y}_k = \mathbf{W}^T(\mathbf{x}_k-\bar{\mathbf{x}})\). The cluster prototypes are mapped by the same affine transform, so the projected centers \(\mathbf{z}_i\) sit where the fuzzy means of the projected data would be (for Euclidean prototypes). The transform preserves variance, not distances, so compact high-dimensional clusters may overlap in the plane; this is the baseline the Sammon-type methods of this module improve on.
- Parameters:
- Xarray_like
ofshape(n_samples,n_features) Data matrix \(\mathbf{X}\).
- n_components
int, default=2 Dimension \(q\) of the projection.
- centersarray_like
ofshape(n_clusters,n_features),optional Cluster prototypes \(\mathbf{v}_i\) to project with the same transform.
- Xarray_like
- Returns:
- Y
ndarrayofshape(n_samples,n_components) Projected data \(\mathbf{y}_k\).
- Z
ndarrayofshape(n_clusters,n_components)orNone Projected prototypes \(\mathbf{z}_i\);
Noneifcentersis not given.- pca
sklearn.decomposition.PCA The fitted PCA object (
components_,explained_variance_ratio_,transformfor further data).
- Y
References
[1]Jolliffe, “Principal Component Analysis”, Springer, 2002.
[2]J. Vesanto, “Neural network tool for data mining: SOM Toolbox”, Proc. TOOLMET 2000, pp. 184-196, 2000.
Examples
>>> from fuzzyclust import FCM >>> from fuzzyclust.datasets import make_fuzzy_blobs >>> from fuzzyclust.viz import pca_projection >>> X, _ = make_fuzzy_blobs(n_clusters=3, n_features=5, random_state=0) >>> fcm = FCM(n_clusters=3, random_state=0).fit(X) >>> Y, Z, pca = pca_projection(X, 2, centers=fcm.cluster_centers_) >>> Y.shape, Z.shape ((300, 2), (3, 2))
Examples using fuzzyclust.viz.pca_projection#
PCA versus Sammon mapping: preserving variance or distances
Fuzzy Sammon mapping: projecting clusters, not just data
State-space reconstruction and prediction of a chaotic time series