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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.