O'Reilly logo

Mastering Machine Learning with R - Second Edition by Cory Lesmeister

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required