I am currently solving one classification problem using CART in R, while doing it I build a tree .I want to know how to know the number of splits in a tree.
My tree.
How to choose the number of splits in a tree
sid100158
#1
shuvayan
#2
hello @sid100158,
If you see the above image for rpart.control you can see that there are several options like minsplit = 20, minbucket etc.These parameters can be used to change the number of splits indirectly.For example:
rpart.fit <- rpart(quality_bin ~ .,data = training)
rpart.plot::rpart.plot(rpart.fit)
gives
.
And
#Rpart with control:
rpart.cntrl <- rpart.control(minsplit = 100)
rpart.cntrl.fit <- rpart(quality_bin ~ .,data = training,control = rpart.cntrl)
rpart.plot::rpart.plot(rpart.cntrl.fit)
will give you:
If you notice the number of splits is different here.
Similarly the other parameters in rpart.control can be used.
Hope this helps!!