Splitting attribute appearing in same branch in Decision tree?

While preparing decision tree for the titanic survival dataset, I tried to visualize the tree by creating logs indicating depth, feature, and whether it’s left or right node. I got the following data:

  1. Depth is 0, Feature is Sex, left: Nan, Right: Nan
  2. Depth is 1, Feature is Pclass, left: True, Right: False
  3. Depth is 2, Feature is Pclass, left: True, Right: False
  4. Depth is 3, Feature is Parch, left: True, Right: False
  5. Depth is 4, Feature is Age, left: True, Right: False
  6. Depth is 5, Feature is Age, left: True, Right: False
  7. Depth is 5, Feature is Age, left: False, Right: True

and so on …

Here, in 2 and 3, Pclass is appearing in same branch(left) and in 5 and 6, Age is also appearing in same branch(left).

Why?

Hey @preetishvij, yes in decission trees a features may appear multiple times, and yes it may appear consecutively as well. This is seen in the features having multiple values, like in a variable having range of values, as in Age, or in a feature having multiple classes, like PClass.

On the other hand this thing can’t be seen with variables having two discrete values, like in ‘Sex’ attribute, for the time being assume there are two choices only, ‘male’ and ‘female’, In this case, as soon as split is performed on this column, than one branch will have all males on one side, and other side will have all females, So tree can’t be further divided into two sections with this feature anymore. So split will not be performed on this feature again.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.