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.
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
Center the data at its mean, then compute the covariance matrix.
The eigenvectors of the covariance matrix are the principal directions; the eigenvalues are the variances along them.
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.