0
$\begingroup$

This question is for using clustering for EDA in a structured dataset. My understanding is that k-means does not do well with categorical data because it cannot interpret means of non-numerical data. I've heard k-modes is a good alternative.

But can it be used for both categorical and numerical columns? Or is it just for categorical? Or, is there a more effective way to cluster mixed-type data?

$\endgroup$
0
$\begingroup$

There also is the hybrid using the mean on numeric attributes and the mode on categorical attributes. This combination is obvious and easy to implement.

However it does not save you from finding the proper weighting of all of these attributes, which IMHO is pretty much impossible and makes most results on such mixed data untrustworthy, and little better than guessing. Just that many people don't seem to care, as long as they have some result...

$\endgroup$
  • $\begingroup$ I see, thanks for the info. So which do you recommend for real-world? Using either one or the other (just using the numerical w/ k-means or just using categoricals w/ k-modes) or using the hybrid? And if hybrid, how do you implement both of them on the same dataset? $\endgroup$ – Greg Rosen Oct 4 at 4:29
  • $\begingroup$ The implementation is trivial, just use the mean for the numerical and the mode for the categoricial features. Even if you just use either, you'll nevertheless have to solve the weighting if you want meaningful results, because attributes on such data are not equal. It's not the Iris data set where each attribute is a leaf length and 1 unit on each attribute is the same. Try to write down the function you optimize - what good is it for your problem to optimize this function? $\endgroup$ – Anony-Mousse Oct 4 at 5:07
  • $\begingroup$ Does sklearn's StandardScaler help with weighting? I'll usually use that before my clustering. $\endgroup$ – Greg Rosen Oct 4 at 19:35
  • $\begingroup$ That is a very crude heuristic. Usually better than not scaling. $\endgroup$ – Anony-Mousse Oct 4 at 20:34
  • $\begingroup$ StandardScaler ist a crude heuristic. Often better than not scaling, but it can harm, for example with histogram data. One-hot encoded data can be seen as a special kind of histograms, so I'd rather not use it with such data, for example. And it does not solve the problem that different attributes are of different relevancy to the problem, or that they can be meaningless, or that they can be correlated. $\endgroup$ – Anony-Mousse Oct 4 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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