Metriky výkonu pro regresní stromy

Machine Learning with Tree-Based Models in R

Sandro Raabe

Data Scientist

Jak měřit výkon?

  • Klasifikace: přesnost (matice záměn)
  • Regrese: „správnost" je relativní, žádná binární správnost

$\Rightarrow$ Měříme, jak daleko jsou předpovědi od skutečnosti

Machine Learning with Tree-Based Models in R

Běžné metriky pro regresi

  • Střední absolutní chyba (MAE)
  • Kořen střední kvadratické chyby (RMSE)

 

Intuice MAE:

graf středních rozdílů

 

 

 

 

 

MAE = průměrná délka červených úseček

Machine Learning with Tree-Based Models in R

Vzorce a intuice

 

$$MAE = \frac{1}{n} \sum_{i=1}^n\left| actual_i - predicted_i \right|$$

 

  • „Součet absolutních odchylek dělený počtem předpovědí"

$$\quad MSE = \quad \frac{1}{n} \sum_{i=1}^n\left( actual_i - predicted_i \right)^2$$

  •                   „Střední kvadratická chyba"
Machine Learning with Tree-Based Models in R

Vzorce a intuice

 

$$MAE = \frac{1}{n} \sum_{i=1}^n\left| actual_i - predicted_i \right|$$

 

  • „Součet absolutních odchylek dělený počtem předpovědí"

$$RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^n\left( actual - predicted \right)^2}$$

  • „Odmocnina střední kvadratické chyby"
  • Velké chyby mají vyšší váhu
Machine Learning with Tree-Based Models in R

Kódování: předpovědi

# parsnip and yardstick are included in tidymodels
library(tidymodels)
# Make predictions and add to test data
predictions <- predict(model, new_data = chocolate_test) %>%

bind_cols(chocolate_test)
# A tibble: 358 x 7
   .pred final_grade review_date cocoa_percent company_location
   <dbl>       <dbl>       <int>         <dbl> <fct>           
 1  2.5         2.75        2013          0.7  France          
 2  3.64        3.25        2014          0.8  France          
 3  3.3         3.5         2012          0.7  France          
 4  3.25        3.5         2011          0.72 Fiji            
# ... with 354 more rows, and 2 more variables: bean_type <fct>, broad_bean_origin <fct>
Machine Learning with Tree-Based Models in R

Kódování: mae() a rmse()

# Evaluate using mae()
mae(predictions,

estimate = .pred,
truth = final_grade)
# A tibble: 1 x 2
  .metric   .estimate
  <chr>         <dbl>
1 mae           0.363
# Evaluate using rmse()
rmse(predictions,
     estimate = .pred,
     truth = final_grade)
# A tibble: 1 x 2
  .metric   .estimate
  <chr>         <dbl>
1 rmse          0.457
Machine Learning with Tree-Based Models in R

Pojďme vyhodnocovat!

Machine Learning with Tree-Based Models in R

Preparing Video For Download...