How do you cluster mixed numeric + categorical data?
hardAnswer
- (1) Gower distance — averages appropriate distances per feature type (Manhattan for numeric, matching for categorical).
- (2) k-prototypes — extends k-means with categorical dissimilarity.
- (3) Embed categorical as one-hot / target encoding, scale numerics, then k-means (loses interpretability).
- (4) UMAP with metric='gower' → then cluster in embedding.
- Most production tabular clustering uses Gower + PAM or k-prototypes.
Check yourself — multiple choice
- One-hot only
- Gower distance / k-prototypes / one-hot + scale + k-means / UMAP embedding; Gower + PAM common in tabular practice
- Same as k-means
- Random
Mixed data: Gower distance / k-prototypes / UMAP; not naive Euclidean.
#clustering#similarity
Practise Unsupervised Learning
214 interview questions in this topic.
Related questions
- Why do you scale features before k-means?
- Cosine similarity vs Euclidean — when do you use cosine?
- What is Dynamic Time Warping?
- You run k-means on customer data with age, income and number of purchases. What breaks?
- How does k-means work and what are its main limitations?
- How do you choose the number of clusters k?