Real data often has dozens or thousands of features, but its structure can live in far fewer. Flatten a 3D cloud into 2D four different ways and check what each method keeps and what it throws away.
PCA looks at how the features vary together (the covariance matrix) and finds the directions along which the data spreads most. Each bar is the share of total variance along one principal component. If the first bars dominate, the data is effectively lower-dimensional.
The table is the covariance matrix of the current 3D data. Diagonal = variance of each feature, off-diagonal = how two features move together.
Choosing a method means choosing what to preserve. Feature selection simply keeps a subset of the original features. Random projection and PCA are linear projections: they cast a shadow of the cloud onto a flat surface, the first along random directions, the second along directions chosen to retain the most variance. Nonlinear methods try to follow the shape of the data itself. Load the Swiss roll and compare PCA with Isomap: PCA squashes the layers on top of each other, while Isomap follows neighbours along the sheet.
| Method | Type | Tries to keep | Watch out |
|---|---|---|---|
| Feature selection | Feature subset | Original, interpretable features | Dropped features are gone entirely |
| Random projection | Linear | Pairwise distances, approximately | Depends on the directions drawn; a poor draw can lose structure, especially in few dimensions |
| PCA | Linear, unsupervised | Maximum variance | Sensitive to feature scale; misses curved structure |
| LDA | Linear, supervised | Separation between known classes | Needs labels |
| Isomap | Nonlinear | Distances along the neighbour graph | Shortcuts if k is too large; breaks if graph is disconnected |
| t-SNE | Nonlinear | Local neighbourhoods | Distances between far-apart clusters and cluster sizes may not mean much |
| UMAP | Nonlinear | Local structure, often some global layout | Settings change the picture; interpret with care |
| Autoencoder | Nonlinear, learned | Whatever lets it reconstruct the input | Needs training, tuning and enough data |
This page implements feature selection, random projection, PCA, and Isomap. LDA, t-SNE, UMAP, and autoencoders are included for context but are not implemented in this interactive demo.
Two simple checks. PCA variance explained says how much of the total variance PCA’s two components retain; it is a PCA measure, not a universal score of information preserved, so it is not shown for other methods. Neighbour preservation works for every method: it is the average share of each point’s 5 nearest neighbours in 3D that are still among its 5 nearest in 2D.
Neighbour preservation is a local-neighbourhood diagnostic, not a complete measure of embedding quality: it says nothing about far-apart structure. The two tiles can disagree: on the Swiss roll, PCA keeps a high share of variance but few neighbours, because the layers land on top of each other.
Numbers below update live with your data and method.
Eigenvectors vi are the principal directions; eigenvalues λi are the variance along them. Their sum equals the trace of C (the total variance).
Projecting down and back leaves an error equal to the variance you dropped. The check below computes it directly from the points.
Load the Swiss roll and use PCA. Check where the colours end up and the neighbours-kept tile.
A tilted plane is already 2D inside 3D. See how much variance PCA keeps.
Swiss roll with k = 40. A larger k can let neighbours link different layers and shortcut the surface; the effect depends on how the points are spread.