Fundamentals of AI/ML · Prof. Parikshit Pareek & Prof. Jitin Singla · IIT Roorkee
Click on the plot to add data points. The principal components are computed live as eigenvectors of the sample covariance matrix C = (1/n) X⊤X. Try the preset datasets to see different shapes, and toggle the projection / reconstruction to see what PCA loses when we keep only PC1.
Preset:
raw data
centered data
PC1
PC2
projection onto PC1
Click anywhere in the plot to add a point. Click an existing point to remove it.
Display options
Mean & Covariance Matrix
n = 0 points
x̄ = —
C = (1/n) X⊤X =
Eigendecomposition of C
λ1 = —, v1 = —
λ2 = —, v2 = —
Total variance: tr(C) = —
Variance Explained
EVR(1) = —
EVR(2) = —
What to notice during class
Pick the Elongated cluster preset: EVR(1) is large, the ellipse is thin, the data is well-summarised by one PC.
Pick the Circular cluster: λ1 ≈ λ2, EVR(1) ≈ 0.5 — there is no preferred direction, PCA isn't useful.
Pick Two clusters: PC1 will align with the inter-cluster direction; PC2 captures the spread within each cluster.
Toggle Reconstruction lines: each line shows what's lost when we drop to 1-D. The lines are perpendicular to PC1 — the residuals.
Adding a single far-away outlier swings PC1 a lot. PCA is not robust.