Sitemap

Member-only story

Making Sense of Categorical Survey Data: A K-Modes Clustering Case Study

5 min readJan 24, 2025

--

When analysing survey responses, selecting the right clustering methodology is essential. Surveys often consist of categorical data, such as “What is your age range?” with options like “under 14,” “14–18,” “19–24,” and so on. For clustering analyses involving such data, K-Means clustering falls short because it relies on minimising Euclidean distances, which are not meaningful for categorical variables. This is where K-Modes comes in — a clustering method specifically designed for categorical data. By using dissimilarity measures instead of distances, K-Modes groups responses based on their categorical similarities, making it the ideal choice for a project I worked on for a client, which involves analysing a survey with only categorical questions.

Side by Side comparison of K-means and K-modes (Image by Author)

How Does K-Modes Work?

K-Modes clustering operates differently from numerical clustering methods like K-Means. Here’s a simplified breakdown:

  1. Initial Centroids: Randomly select initial cluster centroids. Each centroid represents the most frequent category for each feature within the cluster.
  2. Assign Rows to Clusters: Each data point (row) is assigned to the cluster whose centroid is most similar to it, based on the number of mismatched categories. Therefore, the row is assigned to the…

--

--