+ - 0:00:00
Notes for current slide
Notes for next slide

Boosted Trees in R

Dr. D’Agostino McGowan

1 / 8

Boosted trees in R

library(tidymodels)
boost_spec <- boost_tree(
mode = "classification",
tree_depth = 1,
trees = 1000,
learn_rate = 0.001,
) %>%
set_engine("xgboost")
2 / 8

Boosted trees in R

library(tidymodels)
boost_spec <- boost_tree(
mode = "classification",
tree_depth = 1,
trees = 1000,
learn_rate = 0.001,
) %>%
set_engine("xgboost")
  • Set the mode as you would with a bagged tree or random forest
3 / 8

Boosted trees in R

library(tidymodels)
boost_spec <- boost_tree(
mode = "classification",
tree_depth = 1,
trees = 1000,
learn_rate = 0.001,
) %>%
set_engine("xgboost")
  • tree_depth here is the depth of each tree, let's set that to 1
4 / 8

Boosted trees in R

library(tidymodels)
boost_spec <- boost_tree(
mode = "classification",
tree_depth = 1,
trees = 1000,
learn_rate = 0.001,
) %>%
set_engine("xgboost")
  • trees is the number of trees that are fit, this is equivalent to B
5 / 8

Boosted trees in R

library(tidymodels)
boost_spec <- boost_tree(
mode = "classification",
tree_depth = 1,
trees = 1000,
learn_rate = 0.001,
) %>%
set_engine("xgboost")
  • learn_rate is \(\lambda\)
6 / 8

Fit the model

model <- fit(boost_spec,
HD ~ Age + Sex + ChestPain + RestBP + Chol + Fbs +
RestECG + MaxHR + ExAng + Oldpeak + Slope + Ca + Thal,
data = heart)
7 / 8
03:00

Boosting

How would this code change if I wanted to tune B the number of bootstrapped training samples?

boost_spec <- boost_tree(
mode = "classification",
tree_depth = 1,
trees = 1000,
learn_rate = 0.001,
) %>%
set_engine("xgboost")
8 / 8

Boosted trees in R

library(tidymodels)
boost_spec <- boost_tree(
mode = "classification",
tree_depth = 1,
trees = 1000,
learn_rate = 0.001,
) %>%
set_engine("xgboost")
2 / 8
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow