20.74 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=187101 (5686 observations deleted due to missingness)
## 
## node), split, n, deviance, yval
##       * denotes terminal node
## 
##  1) root 187101 13637250.0   2.333881  
##    2) humidity_3pm< 83.5 174119  5581260.0   1.492223  
##      4) humidity_3pm< 67.5 146377  2881583.0   1.004715 *
##      5) humidity_3pm>=67.5 27742  2481331.0   4.064498 *
##    3) humidity_3pm>=83.5 12982  6278318.0  13.622480  
##      6) rainfall< 24.7 11712  3452853.0  11.444360  
##       12) min_temp< 11.75 5947   699981.8   7.722701 *
##       13) min_temp>=11.75 5765  2585529.0  15.283520 *
##      7) rainfall>=24.7 1270  2257490.0  33.709130  
##       14) min_temp< 22.05 1016  1019333.0  27.102850 *
##       15) min_temp>=22.05 254  1016452.0  60.134250  
##         30) max_temp>=26.75 198   475408.1  46.440400 *
##         31) max_temp< 26.75 56   372635.9 108.551800 *


If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, 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