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= 139059 
## 
## node), split, n, loss, yval, (yprob)
##       * denotes terminal node
## 
##  1) root 139059 29564 No (0.7873996 0.2126004)  
##    2) humidity_3pm< 71.5 116635 16162 No (0.8614310 0.1385690) *
##    3) humidity_3pm>=71.5 22424  9022 Yes (0.4023368 0.5976632)  
##      6) humidity_3pm< 82.5 12283  5610 No (0.5432712 0.4567288)  
##       12) wind_gust_speed< 42 7429  2662 No (0.6416745 0.3583255) *
##       13) wind_gust_speed>=42 4854  1906 Yes (0.3926658 0.6073342) *
##      7) humidity_3pm>=82.5 10141  2349 Yes (0.2316340 0.7683660) *

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