class: center, middle, inverse, title-slide # Boosted Trees in R ### Dr. D’Agostino McGowan --- layout: true <div class="my-footer"> <span> Dr. Lucy D'Agostino McGowan </span> </div> --- ## Boosted trees in R ```r library(tidymodels) ``` ```r *boost_spec <- boost_tree( mode = "classification", tree_depth = 1, trees = 1000, learn_rate = 0.001, ) %>% * set_engine("xgboost") ``` --- ## Boosted trees in R ```r library(tidymodels) ``` ```r 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 --- ## Boosted trees in R ```r library(tidymodels) ``` ```r 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 --- ## Boosted trees in R ```r library(tidymodels) ``` ```r 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` --- ## Boosted trees in R ```r library(tidymodels) ``` ```r boost_spec <- boost_tree( mode = "classification", tree_depth = 1, trees = 1000, * learn_rate = 0.001, ) %>% set_engine("xgboost") ``` * `learn_rate` is `\(\lambda\)` --- ## Fit the model ```r model <- fit(boost_spec, HD ~ Age + Sex + ChestPain + RestBP + Chol + Fbs + RestECG + MaxHR + ExAng + Oldpeak + Slope + Ca + Thal, data = heart) ``` --- class: inverse
03
:
00
## <i class="fas fa-laptop"></i> `Boosting` How would this code change if I wanted to tune `B` the number of bootstrapped training samples? ```r boost_spec <- boost_tree( mode = "classification", tree_depth = 1, trees = 1000, learn_rate = 0.001, ) %>% set_engine("xgboost") ```