# Best clustering algorithm to identify clusters and determine the closet cluster each individual response is near?

I have a survey where each question is related to a different 'shopper' type (there are 5 types so 5 questions). Each question is either binary (True/False) or scale based.

IE:

1. Do you like to shop at our physical location store ? (True/False)

2. Do our discounts entice you to shop more? a. no b. maybe c. yes


For each response I convert the answer choice to a numerical value. So True becomes 1, answer choice 2C becomes 3 etc.

At this point, I am clueless as too what clustering algorithm to use so I can create clusters for each of the 'shopper' types and measures each individual survey response submitted to determine a single cluster closet to the responses given and label the response as that cluster.

IE. This individual that submitted the survey response is 'location conscience shopper type'

Open to any new method of analysis not just clustering

Since they are categorical variables, I would cluster them using the k-medoids clustering method. Before applying this method, one-hot encode all the predictors.

Sklearn has an implementation: https://scikit-learn-extra.readthedocs.io/en/latest/generated/sklearn_extra.cluster.KMedoids.html

• thank you for the response, this is exactly what I was looking for. Can you please tell me why we need to one-hot encode all predictors? And can you give me a small example of one-hot encoding with the survey example to make sure I am understanding correctly – RustyShackleford Jan 6 at 20:00

you can have a look at these suggestions Clustering categorical data

i havent tried clustering on pure categorical dataset yet however have tried on text data where at the end you end up creating a sparse matrix and have had success there with hierarchical clustering using Wards' method

https://towardsdatascience.com/understanding-the-concept-of-hierarchical-clustering-technique-c6e8243758ec

Although I havent used this one before - but try k-mediods where mediods are identified instead of centroids using means https://www.geeksforgeeks.org/ml-k-medoids-clustering-with-example/