I have a data set of 2300 entries, with 5 variables one of them the dependent variable which is binary.

I fitted a decision try using the rpart function in R over the 4 independent variables, and I had this tiny tree, which means the split was done using only one predictive variable.

Is it normal? How can I add the rest of the nodes? resulting tree graphic

  • $\begingroup$ We can't know unless you give more information. Maybe the data was perfectly separated using that variable. Maybe the decision tree used a fraction of the features as a regularization technique. Maybe you set a maximum depth of 2, or some other parameter that prevents additional splitting. $\endgroup$ Apr 15, 2020 at 21:56

3 Answers 3


Have you changed the max depth parameter? This parameter limits the depth of each tree. If you have set it up to max_depth=1 you wont be able to grow your tree further.

From the documentation:

max_depthint, default=None The maximum depth of the tree. If None, then nodes are expanded until all leaves are pure or until all leaves contain less than min_samples_split samples.

Also, it could be that you have your target on the train and your tree does not need to develop further.

Or that you are training with a small number of rows or columns

  • $\begingroup$ That's the documentation for sklearn, not rpart; but the hyperparameter plays the same role, in rpart it is called maxdepth. To the last two points, you can see in the graphic how many samples of each class live in each leaf; with rpart's default minsplit=20, it should be able to split further. Maybe it's the cp parameter? $\endgroup$
    – Ben Reiniger
    Apr 16, 2020 at 14:16

From my personal experience, I don't advise use lib rpart, if it's not necessary. It's quite hard to set up and he has often unexplainable behavior. If is required R, then choose rpart with module prp or ctree. Sample code with output:

#Churn its **factor** binary variable so I use method="class"
#minbucket - the minimum number of observations in any terminal leaf

fit<-rpart(Churn~., data=data_train, method = "class",minbucket=50)
prp(fit) # fancy way of draw decison tree and setup

Other parameters to set up the decision tree you will find here.

Sample output:

enter image description here

  • $\begingroup$ Ctree is based on some conditional inference thing and i just wanted the one with the entropy criteria, the package tree seems to do the trick, i have another issue, one of the numeeocal variables appeared twice, it was used for the first cut and for the second cut on the left, is that normal ? $\endgroup$
    – math geek
    Apr 16, 2020 at 11:33
  • 1
    $\begingroup$ Yes, it is normal, any feature can be used multiple times in a tree. $\endgroup$
    – fuwiak
    Apr 16, 2020 at 11:38

This doesn't seem normal.
It seems to be a case of leakage.
It might be possible that "Taux.Brut.de.Reusite.Serie.S" is highly correlated to the Dependent variable.

An example -
If I keep sugar_level as an independent variable and IsDiebetic as a dependent then one simple condition on sugar_level will split the whole data correctly.

  • $\begingroup$ It is indeed highly correlated with the dependent variable, i have changed the package from rpart to tree and it gave me a slightly bigger tree with good performance measures with minimal entropy, thank you guys for your feed back i appreciate it $\endgroup$
    – math geek
    Apr 16, 2020 at 9:05
  • $\begingroup$ Please help with answer acceptance. It helps the community $\endgroup$
    – 10xAI
    Apr 16, 2020 at 9:31

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.