How would you cluster a dataset that mixes numeric and categorical features?
Last updated
Avoid one-hot encoding plus plain k-means: 0/1 columns make Euclidean distances and centroid means hard to interpret, and high-cardinality categoricals distort scaling.
Use Gower distance (range-normalized numeric difference plus categorical mismatch) with k-medoids, hierarchical, or DBSCAN. It costs O(n²) memory, so it suits small to medium data.
Or use k-prototypes (k-means on numeric plus k-modes on categorical, balanced by a tuned weight γ), which scales linearly. Alternatively encode with FAMD or embeddings, then validate with silhouette and cluster profiling.
- https://medium.com/@sujathamudadla1213/interview-questions-on-machine-learning-clustering-algorithms-1521dbe6a1d6
- https://github.com/Devinterview-io/k-means-clustering-interview-questions
- https://medium.com/data-science/clustering-algorithm-for-data-with-mixed-categorical-and-numerical-features-d4e3a48066a0