18.6 Decision Trees
20210103
Representation | Method | Measure |
---|---|---|
Tree | Recursive Partitioning | Information Gain |
To build a decision tree we typically use rpart::rpart().
<- "rpart"
mtype <- "decision tree"
mdesc
%>%
ds select(all_of(vars)) %>%
slice(tr) %>%
rpart(form, ., method="class", control=rpart.control(maxdepth=3)) %T>%
print() ->
model
## n= 123722
##
## node), split, n, loss, yval, (yprob)
## * denotes terminal node
##
## 1) root 123722 25943 No (0.7903122 0.2096878)
## 2) humidity_3pm< 72.5 105663 14881 No (0.8591655 0.1408345) *
## 3) humidity_3pm>=72.5 18059 6997 Yes (0.3874522 0.6125478)
## 6) humidity_3pm< 83.5 10136 4855 No (0.5210142 0.4789858)
## 12) rainfall< 2.7 6884 2721 No (0.6047356 0.3952644) *
## 13) rainfall>=2.7 3252 1118 Yes (0.3437884 0.6562116) *
## 7) humidity_3pm>=83.5 7923 1716 Yes (0.2165846 0.7834154) *
Chapter 20 covers decision trees in detail whilst Chapter 14 uses decision trees as the model builder to demonstrate the model template. Examples of decision tree induction are available through the rain, iris, and pyiris packages from MLHub.
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0
