# how to compute the possible number of splits in decision tree?

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?

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

• 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. Oct 27, 2022 at 14:20
• Yes . You are right. For eg: if there are two options, we have one split. Here we have 23 options. So 22 possible splits. Oct 27, 2022 at 15:15
• (18-1)+(5-1)=21 possible splits. Oct 27, 2022 at 15:34
• @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. Nov 11, 2022 at 18:49