8.42 Final evaluation

Confusion matrix (train, best model)

augment(class_tree_final_fit, new_data = carseats_train) %>% 
     conf_mat(truth = High, estimate = .pred_class)
##           Truth
## Prediction  No Yes
##        No  160  24
##        Yes  17  99
augment(class_tree_final_fit, new_data = carseats_train) %>% 
     accuracy(truth = High, estimate = .pred_class)
## # A tibble: 1 × 3
##   .metric  .estimator .estimate
##   <chr>    <chr>          <dbl>
## 1 accuracy binary         0.863

Training accuracy: 86.3%

Confusion matrix (test, best model)

augment(class_tree_final_fit, new_data = carseats_test) %>%
  conf_mat(truth = High, estimate = .pred_class)
##           Truth
## Prediction No Yes
##        No  39   9
##        Yes 20  32
augment(class_tree_final_fit, new_data = carseats_test) %>% 
     accuracy(truth = High, estimate = .pred_class)
## # A tibble: 1 × 3
##   .metric  .estimator .estimate
##   <chr>    <chr>          <dbl>
## 1 accuracy binary          0.71

Testing accuracy: 71%