3
$\begingroup$

If there are only categorical variables in the dataset, will the depth of the decision tree be equal to the number of attributes? If not, can a value be split again?

$\endgroup$
0
$\begingroup$

First of all, it might be less than number of attributes when one of your attributes lose importance when others have been used due to some kind of dependence among them. Depending on the implementation, it might be larger also when branching is done like "Blue/Not Blue" at each level. But, typically, each categorical feature is handled in a single node (level), so you'll probably have depth $\leq$ number of features.

$\endgroup$
0
$\begingroup$

A variable can be split multiple times. This is part of what makes decision trees so powerful. Have a look at this example which uses a decision tree to model a sine wave. [1]

However, often it is a good idea to split a categorical variable into multiple dummy variables. This is especially true when there are many categories without a particular order involved for a variable. It should be easier for the tree construction algorithm to recognize predictive value in a dummy variable using a single split rather than by making two splits to isolate the category in the original variable.

[1] - http://scikit-learn.org/stable/auto_examples/tree/plot_tree_regression.html

$\endgroup$

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.