Bagged trees

Machine Learning with Tree-Based Models in R

Sandro Raabe

Data Scientist

Více hlav více ví

moudrost davu

Machine Learning with Tree-Based Models in R

Bootstrap a agregace

  • Bagging = zkratka za Bootstrap Aggregation

 

 1. Bootstrapping

  • Vzorkování s opakováním $\rightarrow$ mnoho upravených trénovacích sad

 

 2. Agregace

  • Předpovědi různých modelů jsou agregovány do výsledné předpovědi:
    • Průměr (v regresi)
    • Hlasování většiny (v klasifikaci)
Machine Learning with Tree-Based Models in R

Krok 1: Bootstrap a trénování

schéma bootstrappingu

Machine Learning with Tree-Based Models in R

Krok 2: Agregace

agregace výsledků

Machine Learning with Tree-Based Models in R

Kód: Specifikace bagged trees

library(baguette)
spec_bagged <- bag_tree() %>%

set_mode("classification") %>%
set_engine("rpart", times = 100)
Bagged Decision Tree Model Specification (classification)

Main Arguments:
  cost_complexity = 0
  min_n = 2

Engine-Specific Arguments:
  times = 100

Computational engine: rpart
Machine Learning with Tree-Based Models in R

Trénování všech stromů

model_bagged <- fit(spec_bagged, formula = still_customer ~ ., data = customers_train)
parsnip model object

Fit time:  23.9s

Bagged CART (classification with 100 members)
Variable importance scores include: # A tibble: 19 x 4 term value std.error used <chr> <dbl> <dbl> <int> 1 total_trans_ct 876. 3.93 100 2 total_trans_amt 800. 4.54 100 3 total_revolving_bal 491. 3.67 100
Machine Learning with Tree-Based Models in R

Pojďme bootstrapovat!

Machine Learning with Tree-Based Models in R

Preparing Video For Download...