0

I'm working on a project and I need to make a decision tree based on a dataset I've imported into R. The dataset contains 155 observations and 24 attributes + class. I created a tree using the rpart package. However, the tree came out very simple, with only one split (like an upside-down V). I tried various rpart.control combinations but nothing worked. I suspect that my tree is using only one observation and this is the reason why the tree is so simple. Any ideas how to fix it would be appreciated :) This is my code:

tree_01<-rpart(data=training.data, formula=class~.) #,control=rpart.control(minsplit=5))
Lluís Ramon
  • 576
  • 4
  • 7

1 Answers1

1

Try to use a smaller complexity parameter cp, default is set to 0.01. It has to be defined at ?rpart.control.

Example of how to use it:

rpart(formula, data, control = rpart.control(cp = 0.001))
Lluís Ramon
  • 576
  • 4
  • 7