1
$\begingroup$

I have a set of medical records, one of the columns has the name of 2000 different doctors. What do I need to do in order to convert these strings to numbers? I want to use a decision tree.

$\endgroup$
1
$\begingroup$

You’ll use two new binary features and use one hot encoding. For example, for Dr. A your features will be [1,0], and for Dr. B your features will be [0,1]. Assigning arbitrary numbers to each doctor is not the correct approach because it induces an implicit ordering, i.e. normally you don’t have Dr. A < Dr. B but depending on your assigned numbers, you’ll end up with comparable doctors, but you shouldn’t have.

Specifically for decision trees, most libraries don't require you to convert your categorical features into numeric. So, you should be able to use them as is.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ sorryyy, one of the columns has the name of 2000 different doctors i think cant one hot because is too much. $\endgroup$ – younessaj 7 Mar 22 at 12:58

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