PCA (Dimensionality Reduction)
Machine Learning · Advanced
Definition
PCA projects data onto new axes (principal components) that capture the most variance.
Reduces features, speeds models and helps visualization.
Diagram
Flowchart
Example: Variance explained
eig = [4.0, 1.0]
print(eig[0] / sum(eig))Output: 0.8
Complexity
O(n·d² + d³)
Key points
- Components are orthogonal
- Always scale features first
Interview questions
How many components to keep?
Enough to explain ~90–95% of the variance.