PCA (Principal Component Analysis) Visualizer

Add data points and watch PCA find the directions of maximum variance — the foundation of dimensionality reduction.

Advertisement

Click to add points, or generate a random correlated dataset to see PCA find the dominant axis.

PC1 Variance Explained
PC2 Variance Explained
0Points
Advertisement

What PCA Is Actually Trying to Find

Principal Component Analysis finds new axes to describe your data, axes chosen specifically to capture as much of the data's variance (spread) as possible, in order of importance. The orange line in the visualization above is the first principal component (PC1), the single direction along which your data varies the most. The green dashed line is the second principal component (PC2), the direction of next-most variance, and for 2D data, it's always exactly perpendicular to PC1. Generate a "Random Correlated Data" set and you'll see PC1 align almost exactly with the visible diagonal trend in the points, PCA has found the dominant direction of spread automatically, without being told anything about the data's structure in advance.

Why "Variance Explained" Is the Key Number

The percentages shown for PC1 and PC2 tell you how much of the data's total spread each component captures. For genuinely correlated data (like the random example), PC1 often explains 90%+ of total variance, meaning you could describe each point's position almost entirely using just its coordinate along that single line, discarding the second dimension almost entirely with minimal information loss. This is the entire point of PCA as a dimensionality reduction technique, if a dataset with 100 original features can have its variance mostly explained by just 10 principal components, you can work with those 10 numbers instead of 100, with minimal loss of the information that actually matters.

Understanding Projection

Toggle on "Show projection onto PC1" to see exactly what dimensionality reduction looks like geometrically, every point gets projected (mapped) onto the PC1 line, its position summarized by a single number, how far along that line it falls, rather than its original two coordinates. The short red lines connecting each point to its projection represent the information being discarded, the "error" introduced by reducing from 2 dimensions to 1. PCA specifically chooses PC1's direction to minimize this total projection error across all points, equivalently, to maximize the variance captured along that single axis.

Why PCA Matters Beyond Visualization

Real-world PCA applications typically work with far more than 2 dimensions, reducing datasets with hundreds or thousands of features (genomic data, image pixels, word embeddings) down to a much smaller number of principal components that still capture most of the meaningful variance. This makes downstream machine learning models faster to train, less prone to overfitting on noisy or redundant features, and easier to visualize, plotting the first two or three principal components is a standard way to get an intuitive 2D or 3D view of otherwise impossible-to-visualize high-dimensional data.