intermediateadvanced-ml

Principal Component Analysis (PCA)

Squeeze dozens of correlated features into a handful of ones that capture almost all the story.

Key Points

What it is

PCA is a dimensionality reduction technique that transforms a dataset with many, possibly correlated features into a smaller set of new, uncorrelated features called principal components, ordered by how much variance (information) they capture from the original data.

Why it exists

Datasets with dozens or hundreds of features are slow to train on, prone to overfitting, and hard to visualize. Many of those features are also correlated and carry redundant information. PCA exists to compress that redundancy into fewer, information-dense dimensions without throwing away much of the signal.

Intuition

Imagine photographing a 3D object with a single camera. From most angles, you lose some information — but there's one angle that captures the most 'shape' of the object in a single 2D photo. PCA finds that best angle (and the next-best perpendicular angle, and so on) mathematically, for data instead of physical objects.

How it works

  1. Standardize the data

    Scale all features to have mean 0 and unit variance so no feature dominates due to scale alone.

  2. Compute the covariance matrix

    Measure how every pair of features varies together.

  3. Find eigenvectors and eigenvalues

    Eigenvectors of the covariance matrix become the new principal component directions; eigenvalues tell you how much variance each captures.

  4. Project the data

    Transform the original data onto the top-k principal components, keeping the ones that capture the most variance.

When to use

When not to use

Common mistakes

In practice

Used for visualization of high-dimensional data, noise reduction, speeding up downstream models, and as a preprocessing step before clustering when the raw feature count is very high.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

t-snecurse-of-dimensionalityfeature-scaling
Chirp at me!