This recipe covers the use of tree models for regression. The
rpart package provides the necessary functions to build regression trees.
rpart.plot packages if you do not already have them installed. If you have not already downloaded the data files for this chapter, do so now and ensure that the
education.csv files are in the R working directory.
To build regression trees, follow the steps below:
> library(rpart) > library(rpart.plot) > library(caret)
> bh <- read.csv("BostonHousing.csv")
> set.seed(1000) > t.idx <- createDataPartition(bh$MEDV, p=0.7, list = FALSE) ...