Lensa ML
Lensa ML

How Dimensionality Reduction Works

Step 1 of 6

The Curse of Dimensions

More features means exponentially more space

1D — Line12 points on a line - cozy!

As dimensions increase, the same number of data points become exponentially sparser. In high dimensions, most of the space is empty — data gets lonely. This is the curse of dimensionality.

Step 1 of 6: The Curse of Dimensions

More features means exponentially more space

1D — Line12 points on a line - cozy!

As dimensions increase, the same number of data points become exponentially sparser. In high dimensions, most of the space is empty — data gets lonely. This is the curse of dimensionality.

Step 2 of 6: PCA — Find the Best Angle

Rotate the data to maximize variance

PC1 axis (rotate me!)
56°
Explained Variance
43.9%

PCA finds the axis that captures the most spread (variance) in the data. Rotate the line to maximize the explained variance — that is the first principal component.

Step 3 of 6: Choosing Dimensions

How many components to keep?

Scree Plot42%PC125%PC215%PC310%PC45%PC53%PC682% keptComponentsVariance %
3 of 6
Variance Kept
82%
Recon. Error
18%

The scree plot shows variance captured by each component. Look for the elbow — the point where adding more components gives diminishing returns. Fewer components means more compression but higher reconstruction error.

Step 4 of 6: PCA in Action

Compress and reconstruct

Original (5 features)PCA (2 comp.)Reconstructedf10.8f20.3f30.9f40.2f50.71.260.670.80.60.80.40.6Reconstruction Error0.140

PCA compresses 5 features into 2 components, then reconstructs the original. More components = lower error, but less compression. The red shows information lost.

Step 5 of 6: t-SNE — Preserving Neighborhoods

Keeping similar points close in 2D

High-DimensionalABCClusters overlap in raw viewt-SNEt-SNE 2D
10

t-SNE maps high-dimensional data to 2D while preserving local neighborhoods. Similar points stay close. The perplexity parameter controls how many neighbors each point considers — higher values reveal broader structure.

Step 6 of 6: PCA vs t-SNE

Linear simplicity vs non-linear beauty

PCAClusters overlapvst-SNEClusters well-separated
PCAt-SNE
TypeLinearNon-linear
SpeedFastSlow
DistancesPreservedDistorted
Best forPreprocessingVisualization

Use PCA when you need fast, invertible dimensionality reduction (preprocessing, denoising). Use t-SNE when you want to visualize clusters — but remember, distances between clusters are not meaningful.