Machine Learning với Mô hình Dựa trên Cây trong R
Sandro Raabe
Data Scientist
no có thể đạt 98% accuracy→ Có thể xảy ra với dữ liệu mất cân bằng có 98% mẫu âm






predictions
# A tibble: 153 x 2
.pred_class true_class
<fct> <fct>
1 yes no
2 no no
3 no yes
4 yes yes
# Tính độ nhạy tại một ngưỡng
sens(predictions,
estimate = .pred_class,
truth = true_class)
# A tibble: 1 x 2
.metric .estimate
<chr> <dbl>
1 sensitivity 0.872
accuracy() và conf_mat()# Dự đoán xác suất trên tập kiểm tra predictions <- predict(model, data_test,type = "prob") %>%bind_cols(data_test)
# A tibble: 9,116 x 13
.pred_yes still_customer age gender ...
<dbl> <fct> <int> <fct> ...
1 0.0557 no 45 M ...
2 0.0625 no 49 F ...
3 0.330 no 51 M ...
4 ...
...
# Tính đường cong ROC cho mọi ngưỡng roc <- roc_curve(predictions,estimate = .pred_yes,truth = still_customer)# Vẽ đường cong ROC autoplot(roc)

# Tính diện tích dưới đường cong
roc_auc(predictions,
estimate = .pred_yes,
truth = still_customer)
# A tibble: 1 x 3
.metric .estimator .estimate
<chr> <chr> <dbl>
1 roc_auc binary 0.872
Machine Learning với Mô hình Dựa trên Cây trong R