How do outliers affect k-means and how do you handle them?
mediumAnswer
- Outliers pull centroids toward themselves (mean is non-robust) → distort cluster boundaries.
- Handle: (1) pre-cluster outlier removal via IsolationForest / z-score, (2) use k-medoids (median-like), (3) use DBSCAN which explicitly flags outliers as noise, (4) trim tails / winsorize before clustering.
- Always plot the largest / smallest per-cluster distances after fitting — extreme values are usually outliers or mistakes in the pipeline.
Check yourself — multiple choice
- No effect
- Outliers pull centroids in k-means; fix with pre-removal / k-medoids / DBSCAN / winsorize; inspect max intra-cluster distance post-fit
- Random
- Same as scaling
Outliers pull centroids → use k-medoids / DBSCAN / pre-removal / winsorize.
#clustering#anomaly-detection
Practise Unsupervised Learning
214 interview questions in this topic.