What does principal component analysis (PCA) do to a dataset, what are principal components geometrically, and why do we often keep only the first few?
Unsupervised learning, Principal component analysis
Level L1 Beginner. Length Short. Nature Th Theoretical.
What's being asked
Whether you have the geometric intuition for PCA before learning about feature scaling, covariance matrices or singular value decomposition (SVD).
Key idea
PCA rotates the coordinate axes of centred data so that the first new axis (PC1, first principal component) points along the direction of widest spread (largest variance), the second axis (PC2) is perpendicular to PC1 along the next widest spread, and so on. Keeping only the top axes compresses the data while losing as little information as possible.
Steps
- Use a camera analogy: imagine taking a 2-D (two-dimensional) photograph of a 3-D (three-dimensional) flat pancake. If you shoot from directly above, looking along the thin direction, the photo keeps almost all the shape and drops only the thickness.
- Describe how PCA builds the new axes: first centre the cloud of points around zero, then pick PC1 along the direction where points vary most, PC2 at to PC1 along the next largest variation, and continue up to the number of original features.
- Explain why we keep only the top components: later components capture tiny variations (often just measurement noise), so dropping them shrinks storage, speeds up downstream models, and lets us plot high-dimensional data in 2-D or 3-D.
- Note the main trade-off: each principal component is a blend of all original features, so you gain compactness at the cost of easy feature-by-feature interpretability.
Common mistakes
- Thinking PCA picks a subset of the original features (feature selection); instead, it creates new rotated combinations of them.
- Using labels to guide the axes; PCA is unsupervised and only looks at feature spread, so the top components might not be the best ones for a classification label.
- Running PCA without scaling features that have wildly different units (like age in years and salary in rupees), which lets the large-unit feature dominate PC1.
How long your answer should be
About 2 minutes: camera analogy, perpendicular variance-ordered axes, and why we drop the tail.
Read this
Previous in Unsupervised learning: How does the k-means clustering algorithm group unlabelled data points into clusters, and what happens in one full iteration on the 1-D (one-dimensional) points with starting from initial centres and ?
Next in Unsupervised learning: Why should you usually standardise features before running principal component analysis (PCA)?