Dimensionality Reduction — ML Technical Interview Questions & Answers
Reducing feature count while keeping signal.
Dimensionality Reduction
- Simple meaning: Too many columns (200 marks-like features, 80 students) makes distance meaningless and models overfit. Dimensionality reduction keeps a smaller set of columns that still hold the story.
- Picture: 50 quiz scores that all move together → a few “skill” axes. PCA is the usual linear way. You can also pick features (selection) instead of mixing them (extraction).
- Use: plot in 2D, speed up KNN, denoise. Always: split / pipeline so test doesn’t fit the reduction.
- Trap: reducing until nothing is left, then wondering why the classifier is dumb. Trap: PCA without scaling.
Technical Interview Tip: Too many columns hurt. Compress or select. Scale first.
Code Examples for Dimensionality Reduction
Dimensionality Reduction — working example
# PCA-style intuition: project 2D → 1D by a direction vector
points = [(1.0, 1.0), (2.0, 2.0), (3.0, 2.8)]
# unit direction along y = x
ux, uy = 0.7071, 0.7071
proj = [x * ux + y * uy for x, y in points]
print([round(v, 3) for v in proj])
# Tiny ensemble: average two model votes
votes = [1, 0, 1]
v2 = [1, 1, 1]
ens = [1 if a + b >= 2 else 0 for a, b in zip(v1, v2)]
print(ens)Dimensionality Reduction — dim reduction compresses features; ensembles combine models; deep nets/RL/NLP are specialized families — practice the core math idea first.
How to Explain Dimensionality Reduction to an Interviewer
Why reduce dimensions?
Overfit Distance breaks Plots
Selection vs extraction?
Keep some columns vs mix into new ones