Why is Euclidean distance over one-hot encoded categories problematic for k-means?

Quick Overview

Asks why running k-means with Euclidean distance on one-hot encoded categorical features gives poor clusters. Tests understanding of distances between one-hot vectors, what averaged centroids mean, weighting against numeric features, and alternatives such as k-modes and Gower distance.

Why is Euclidean distance over one-hot encoded categories problematic for k-means?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why is Euclidean distance over one-hot encoded categories problematic for k-means? ```hint Compute a few distances Work out the Euclidean distance between the one-hot vectors of two different categories, then look at what the k-means update step produces from a cluster of such vectors. ``` ```hint Mix in a numeric column Suppose the data also has standardized numeric features. Compare how much one category mismatch adds to the squared distance with how much a numeric difference adds. ``` ### What a Strong Answer Covers - What Euclidean distance between one-hot vectors looks like, and what it says about similarity between categories - What the k-means centroid of one-hot vectors is and why it does not stand for a category - How one-hot columns interact with numeric features and with other categorical columns in the distance - Methods better suited to categorical or mixed data, and when each fits ### Follow-up Questions - What does k-means on one-hot columns actually minimize inside a cluster? - How does k-modes update its cluster centers, and what happens when there are ties? - How would you choose the weight between the numeric and categorical parts in k-prototypes? - If you have learned embeddings for the categories, when is k-means on them reasonable?

Overview: Asks why running k-means with Euclidean distance on one-hot encoded categorical features gives poor clusters. Tests understanding of distances between one-hot vectors, what averaged centroids mean, weighting against numeric features, and alternatives such as k-modes and Gower distance.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Why is Euclidean distance over one-hot encoded categories problematic for k-means?

What a Strong Answer Covers Guidance

  • What Euclidean distance between one-hot vectors looks like, and what it says about similarity between categories
  • What the k-means centroid of one-hot vectors is and why it does not stand for a category
  • How one-hot columns interact with numeric features and with other categorical columns in the distance
  • Methods better suited to categorical or mixed data, and when each fits

Follow-up Questions Guidance

  • What does k-means on one-hot columns actually minimize inside a cluster?
  • How does k-modes update its cluster centers, and what happens when there are ties?
  • How would you choose the weight between the numeric and categorical parts in k-prototypes?
  • If you have learned embeddings for the categories, when is k-means on them reasonable?