Regression tree

We will jump right into the prostate dataset, but let's first load the necessary R packages. As always, please ensure that you have the libraries installed prior to loading the packages:

  > library(rpart) #classification and regression trees  > library(partykit) #treeplots  > library(MASS) #breast and pima indian data  > library(ElemStatLearn) #prostate data  > library(randomForest) #random forests  > library(xgboost) #gradient boosting  > library(caret) #tune hyper-parameters

We will first do regression with the prostate data and prepare it, as we did in Chapter 4, Advanced Feature Selection in Linear Models. This involves calling the dataset, coding the gleason score as an indicator variable using the ifelse() function, and creating ...

Get Mastering Machine Learning with R - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.