20.75 Regression Trees

The discussion so far has dwelt on classification trees. Regression trees are similarly well catered for in R.

We can plot regression trees as with classification trees, but the node information will be different and some options will not make sense. For example, extra= only makes sense for 100 and 101.

First we will build regression tree:

target <- "risk_mm"
vars <- c(inputs, target)
form <- formula(paste(target, "~ ."))
(model <- rpart(formula=form, data=ds[tr, vars]))
## n=154069 (4738 observations deleted due to missingness)
## 
## node), split, n, deviance, yval
##       * denotes terminal node
## 
##  1) root 154069 11298580.0  2.344708  
##    2) humidity_3pm< 83.5 143411  4641628.0  1.502737  
##      4) humidity_3pm< 68.5 122880  2310032.0  1.041501 *
##      5) humidity_3pm>=68.5 20531  2148997.0  4.263280 *
##    3) humidity_3pm>=83.5 10658  5187297.0 13.674030  
##      6) rainfall< 26.9 9713  3004984.0 11.538620  
##       12) min_temp< 19.95 8504  1654139.0  9.955903 *
##       13) min_temp>=19.95 1209  1179703.0 22.671300 *
##      7) rainfall>=26.9 945  1682784.0 35.622430  
##       14) min_temp< 19.55 613   628144.4 26.478630 *
##       15) min_temp>=19.55 332   908755.7 52.505420 *


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