Since the decision tree algorithm split on an attribute at every step, the maximum depth of a decision tree is equal to the number of attributes of the data. Is this correct?
2 Answers
No, because the data can be split on the same attribute multiple times. And this characteristic of decision trees is important because it allows them to capture nonlinearities in individual attributes.
Edit: In support of the point above, here's the first regression tree I created. Note that volatile acidity and alcohol appear multiple times:
-
5$\begingroup$ @mkt if you feel like editing again you can add that typically a decision tree stops creating new branches when wither a pre-specified purity level is reached, a node has less than a specified number of elements, or a split of a node would lead to a new node with less than a specified number of elements. These reasons can easily lead to an attribute not being used at all. $\endgroup$– mehCommented May 18, 2018 at 13:47
-
1$\begingroup$ +1, but this plot does leave something to be desired. Which branch represents
yes
, eg? It might help to post the dataset & code, if that's doable. $\endgroup$ Commented May 18, 2018 at 14:05 -
4$\begingroup$ What I mean is, suppose
alcohol = 10.50
(ie,alcohol < 10.53
), do you then proceed down the right or left branch of the tree? $\endgroup$ Commented May 18, 2018 at 14:35 -
1$\begingroup$ Nice answer! Can you clarify what your outcome variable was for the decision tree you built and also if there were any other attributes that did not turn out to be important and don't feature in your plot? $\endgroup$ Commented May 18, 2018 at 14:38
-
1$\begingroup$ @IsabellaGhement how is that relevant to the question that was asked? It seems like it would just distract from the main point. $\endgroup$ Commented May 18, 2018 at 22:13
Well if the features are categorical this above regression answer doesn't really hold true. Then it is dependent on the number of categories how many splits you can do on one feature. If each feature only has two categories, then OP would be correct.
-
$\begingroup$ Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. $\endgroup$– Community BotCommented Apr 16, 2023 at 4:58
-
$\begingroup$ This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review $\endgroup$ Commented Apr 16, 2023 at 5:17