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=120704 (3018 observations deleted due to missingness)
## 
## node), split, n, deviance, yval
##       * denotes terminal node
## 
##  1) root 120704 8785460.0  2.272201  
##    2) humidity_3pm< 83.5 112864 3791677.0  1.486089  
##      4) humidity_3pm< 66.5 94010 1731286.0  0.983856 *
##      5) humidity_3pm>=66.5 18854 1918441.0  3.990326 *
##    3) humidity_3pm>=83.5 7840 3919967.0 13.589010  
##      6) rainfall< 39.1 7439 2505518.0 11.983020  
##       12) min_temp< 15.95 5209  838540.7  9.100749 *
##       13) min_temp>=15.95 2230 1522622.0 18.715650 *
##      7) rainfall>=39.1 401 1039330.0 43.381800 *


Your donation will support ongoing development 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.