So my question is, which level gets number 1, which one gets 2.. etc. I speculated that it could be the order in which they appear in the input / alphabetically, but none of these seem to be correct.

I don't know much about R and Google can't help me on this particular question.

  • $\begingroup$ not clear: do you mean whether/how visualization functions (such as varImpPlot) in the randomForest package sort variables in the output? (for the above's default it is the order of decreasing importance) $\endgroup$ – katya Nov 12 '14 at 2:08
  • $\begingroup$ Nope :). If a node in a tree chooses a categorical feature for splitting, it will provide a "split-point" in the form of an integer. All objects that are in category number C go to the left if the C-th bit of "split-point" is 1, otherwise they go to the right. My question is, how does R assign category numbers to categories? If my feature is City, it'll have to give numbers to "New York", "London", "Berlin". I'm not sure how it decides to do that. How can I know to which town it's referring to by "1". How does it hash them. $\endgroup$ – user5432545u Nov 12 '14 at 2:19
  • $\begingroup$ shouldn't these be coded as dummy variables in order to get a meaningful classification (however it numbers them won't be truly numeric)? $\endgroup$ – katya Nov 12 '14 at 3:33
  • $\begingroup$ Well I don't want them to be truly numeric. The number part is just for convenience inside the algorithm. Otherwise, an integer couldn't encode a subset :) Maybe I wasn't clear enough, this has nothing to do with the algorithmic part, it's just a technical detail of how R does things. $\endgroup$ – user5432545u Nov 12 '14 at 19:25

Your Answer

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

Browse other questions tagged or ask your own question.