I'm working on a project and I need to be able to make some decision trees based on a dataset I've imported into R. Using the rpart package, I'd like to be able to create a pair of decision trees, one using the gini split criteria and the other using the entropy split criteria. I'd also like to be able to adjust the maximum tree depth if possible. Does anybody know how to do this? I'd greatly appreciate any help!
This function combines and extends plot. rpart and text. rpart in the rpart package. It automatically scales and adjusts the displayed tree for best fit.
Rpart is a powerful machine learning library in R that is used for building classification and regression trees. This library implements recursive partitioning and is very easy to use.
According to the R manual here, rpart()
can be set to use the gini or information (i.e. entropy) split using the parameter:
parms = list(split = "gini"))
or
parms = list(split = "information"))
... respectively.
You can also add parameters for rpart.control
(see here) including maxdepth
, for which the default is 30
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With