Regression Trees Chapter2
Regression Trees Chapter2
regression trees
MA CH IN E LEA RN IN G W ITH TREE-BA S ED MODELS IN R
Erin LeDell
Instructor
Train a Regression Tree in R
rpart(formula = ___,
data = ___,
method = ___)
validation set
test set
Erin LeDell
Instructor
Common metrics for regression
Mean Absolute Error (MAE)
1
MAE = ∑ ∣ actual − predicted ∣
n
Root Mean Square Error (RMSE)
library(Metrics)
2.278249
Erin LeDell
Instructor
Decision tree hyperparameters
?rpart.control
Erin LeDell
Instructor
Grid Search
What is a model hyperparameter?
What is a "grid"?
minsplit maxdepth
splits <- seq(1, 30, 5)
1 1 5
depths <- seq(5, 40, 10)
2 6 5
3 11 5
# Create a data frame containing 4 16 5
# all combinations 5 21 5
6 26 5
hyper_grid <- expand.grid( 7 1 15
minsplit = splits 8 6 15
maxdepth = depths 9 11 15
10 16 15