1
$\begingroup$

How exactly does k-means clustering for categorical data work?

I have a dataset which has several categorical features that can have 2,3,4,..,n values. I could one hot encode them, but I'm not sure if it even makes sense because k-means uses a distance metric.

I looked into k-prototype clustering, but tried it on my dataset, but plotting it does not make sense when the y-axis and y-axis are just integer values that are small.

$\endgroup$
1
0
$\begingroup$

You can use distance metrics that are better suited to boolean values such as Jaccard, or Manhattan. Usually K-means uses mean as the metric to re-adjust the centroid of the current cluster, but I think you could change this to majority vote.

I think if you one-hot encoded the categorical features, you could use Jaccard for similarity and then majority vote for updating the centroid. Jaccard would be good if your data is quite sparse. Can you reform your data so that it is one-hot encoded? What does the distribution look like of the count per row?

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.