0
$\begingroup$

In the following dataset, if we want to include just two variables, STORE and PctDiscMM, in a classification tree model, what is the possible number of first splits?

library(islr)
data(OJ)
length(unique(OJ$PctDiscMM))
length(unique(OJ$ STORE))

length(unique(OJ$PctDiscMM))=18 and length(unique(OJ$ STORE))=5, therefore could we say that the number of first splits equals to 17 * 4 = 64?

$\endgroup$

1 Answer 1

0
$\begingroup$

The first slip can be either Store or PctDiscMM. Assuming you create binary tree. There are 18 options for Store and 5 options for PctDiscMM.

Possible number of first split = 18 + 5

$\endgroup$
4
  • $\begingroup$ ebrahimi was incorrect to multiply because as you point out the split is one feature or the other. But they were right about 18-1 and 5-1, because a candidate split will always have at least one point on each side of the split. $\endgroup$
    – Ben Reiniger
    Oct 27, 2022 at 14:20
  • $\begingroup$ Yes . You are right. For eg: if there are two options, we have one split. Here we have 23 options. So 22 possible splits. $\endgroup$
    – amol goel
    Oct 27, 2022 at 15:15
  • $\begingroup$ (18-1)+(5-1)=21 possible splits. $\endgroup$
    – Ben Reiniger
    Oct 27, 2022 at 15:34
  • $\begingroup$ @BenReiniger Thanks. I forgot to mention that OJ$STORE is a categorical variable, so how it will be? (18-1)+2^(5-1)-1=17+15=32. $\endgroup$
    – ebrahimi
    Nov 11, 2022 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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