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!
Asked
Active
Viewed 6,732 times
5
-
Would have been great if you attached a reproducible dataset so it can be used as reference by others. Guidance via http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Jochem Feb 24 '13 at 06:47
1 Answers
10
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
.

Simon
- 10,679
- 1
- 30
- 44
-
great answer! can you please take a look at my question? https://stackoverflow.com/questions/65679523/r-obtaining-rules-from-a-function thanks – stats_noob Jan 15 '21 at 00:58