I will try to implement a k-means algorithm over this dataset:

Team_Categorical  CreditAmount_Numeric   Retired?_Binary
       A                 15.3                   1
       B                 12                     0
       C                 6.2                    1

In order to apply k-means algorithm I need to transform the categorical variables into numeric. So I will apply binning transformaton over the Team_Categorical field. So I will have this dataset:

A    B   C  CreditAmount_Numeric   Retired?_Binary
1    0   0          15.3                 1
0    1   0          12                   0
0    0   1          6.2                  1

My question is: Should I transform CreditAmount_Numeric to binary too?


To answer your question, you need not transform the numeric to binary variable(you meant binning right?).

I will try to explain it with the above example:

snapshot Let's start with row-1 where A = 1 , B =0 , C=0 so it means that you are talking about A. So the value of CreditAmount_Numeric belongs to A and the retired binary value also belongs to A. Similarly, you can deduce for the rest records.

Conclusion is that you need not do any transformation on your numeric variable.

  • $\begingroup$ But for example, in K-Means it will be calculating centroides with binaries and numerics? Like making the average with all the numerics? $\endgroup$ – John_Rodgers Mar 1 '18 at 8:17
  • $\begingroup$ yes it takes centroides of the numeric variables and perform the clustering $\endgroup$ – Toros91 Mar 1 '18 at 8:24

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.