21.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=130455 (3546 observations deleted due to missingness)
## 
## node), split, n, deviance, yval
##       * denotes terminal node
## 
##  1) root 130455 9076127.0  2.259461  
##    2) humidity_3pm< 82.5 121064 3894820.0  1.431952  
##      4) humidity_3pm< 64.5 97329 1754387.0  0.929464 *
##      5) humidity_3pm>=64.5 23735 2015085.0  3.492479 *
##    3) humidity_3pm>=82.5 9391 4029685.0 12.927290  
##      6) rainfall< 24.7 8558 2481100.0 11.120370  
##       12) min_temp< 12.25 4641  547051.1  7.688839 *
##       13) min_temp>=12.25 3917 1814649.0 15.186160 *
##      7) rainfall>=24.7 833 1233579.0 31.491120  
##       14) min_temp< 21.05 638  557087.9 24.400000 *
##       15) min_temp>=21.05 195  539446.8 54.691790 *


Your donation will support ongoing development and give you access to the PDF version of the 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.