Math

Principal Component Analysis

PCA rotates the coordinate system to align with the data’s variance. The first principal component captures the most spread; the second is orthogonal to it.

7 minLevel 3/3The interactive stage stays ad-free.
Samples90PC1 variance88.0%PC1 angle49.3°λ₁ / λ₂1.82 / 0.25

PCA centers the cloud and finds the orthogonal directions of maximum variance. The amber axis is PC1; the rose axis is PC2. With less noise, PC1 captures a larger share of the total variance and the cloud becomes a thin cigar.

What you are seeing

1

Center the data at its mean, then compute the covariance matrix.

2

The eigenvectors of the covariance matrix are the principal directions; the eigenvalues are the variances along them.

3

Projecting onto the first few components reduces dimension while preserving as much variance as possible.

Why it matters

PCA is used for visualization, compression, noise reduction, and feature extraction in data science and machine learning.

Complexity & details

Computing a 2D covariance matrix is O(n). Eigendecomposition of a 2×2 matrix is O(1).

Frequently asked questions

How is PCA related to SVD?+

PCA is the SVD of the centered data matrix. The right singular vectors are the principal directions and squared singular values are the variances.

Does PCA need labels?+

No. PCA is unsupervised: it looks only at the feature values, not at any target or class label.