18.6 Decision Trees
20210103
Representation | Method | Measure |
---|---|---|
Tree | Recursive Partitioning | Information Gain |
To build a decision tree we typically use rpart::rpart().
mtype <- "rpart"
mdesc <- "decision tree"
ds %>%
select(all_of(vars)) %>%
slice(tr) %>%
rpart(form, ., method="class", control=rpart.control(maxdepth=3)) %T>%
print() ->
model
## n= 158807
##
## node), split, n, loss, yval, (yprob)
## * denotes terminal node
##
## 1) root 158807 34370 No (0.7835738 0.2164262)
## 2) humidity_3pm< 71.5 132550 18502 No (0.8604149 0.1395851) *
## 3) humidity_3pm>=71.5 26257 10389 Yes (0.3956659 0.6043341)
## 6) humidity_3pm< 83.5 15155 7199 No (0.5249753 0.4750247)
## 12) wind_gust_speed< 42 9116 3442 No (0.6224221 0.3775779) *
## 13) wind_gust_speed>=42 6039 2282 Yes (0.3778771 0.6221229) *
## 7) humidity_3pm>=83.5 11102 2433 Yes (0.2191497 0.7808503) *
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-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0