0
$\begingroup$

I'm using Matlab to discover some clusters in a dataset that has both numerical (e.g., $) and categorical (e.g.,zip code) variables. I know some tools can handle categorical variables as factors but I'm not sure if this is the case for Matlab.

I'm looking for a good way of representing my categorical variables and I'm not sure that just using dummy variables would be the best way to go. One idea is to represent each digit from my zip code, for example, as a 10 digits long binary variable. By doing so, I would have 50 new binary variables.

Questions:

  • Is this an acceptable way of approaching this problem?
  • What other and/or more efficient ways of representing categorical variables in a hybrid dataset are there?
  • Do I actually need to numerically represent my categorical variables or can Matlab actually handle the mixed dataset?
$\endgroup$
1
$\begingroup$

It may work as desired, or it may not.

The problem is, by introducing a lot of binary features, you also introduce bias, if you blindly use e.g. Euclidean distance. You will need to pay extra attention to normalizing your data and weighting your attributes appropriately.

One way or another, first make sure you can measure similarity reasonably before continuing with clustering.

$\endgroup$
  • $\begingroup$ Thanks for your answer. What I was thinking is that by simply using "regular" dummy variables, the number size of new variable (zip code, for example) would be way bigger than this simple 10x1 representation. $\endgroup$ – saint Jun 12 '13 at 13:49

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.