Unsupervised Learning — ML Technical Interview Questions & Answers
Finding structure in data without labels.
Unsupervised Learning
- Simple meaning: No label column. The sheet is only features. You look for structure: groups (clustering) or a simpler picture (PCA).
- Picture: 200 students, no pass/fail. K-means might find “high hours / high marks” vs “low hours”. You still must check if the groups mean something — the algorithm does not know “truth”.
- You cannot compute accuracy against y because there is no y. Use silhouette, plots, or a human looking at cluster profiles.
- Trap: treating cluster IDs as official categories in a report without a check. Trap: calling PCA a classifier.
Technical Interview Tip: No labels. Groups or a simpler view. Sanity-check the groups.
Code Examples for Unsupervised Learning
Unsupervised Learning — working example
# Tiny 1D k-means-style update (k=2)
points = [1.0, 1.5, 2.0, 8.0, 8.5, 9.0]
c1, c2 = 1.0, 9.0
for _ in range(3):
g1 = [p for p in points if abs(p - c1) <= abs(p - c2)]
g2 = [p for p in points if abs(p - c1) > abs(p - c2)]
c1 = sum(g1) / len(g1)
c2 = sum(g2) / len(g2)
print(round(c1, 2), round(c2, 2), len(g1), len(g2))Unsupervised Learning — clustering groups unlabeled points; k-means alternates assignment and centroid updates.
How to Explain Unsupervised Learning to an Interviewer
Unsupervised vs supervised?
No y vs has y
Two unsupervised jobs?
Clustering Dimensionality reduction