类别概率与预测

在 R 中使用 caret 的机器学习

Zach Mayer

Data Scientist at DataRobot and co-author of caret

不同阈值

  • 不限于50%阈值
    • 10%:捕获更多水雷,但把握更低
    • 90%:捕获更少水雷,但把握更高
  • 平衡真正例率与假正例率
  • 成本收益分析
在 R 中使用 caret 的机器学习

混淆矩阵

# Use a larger cutoff
p_class <- ifelse(p > 0.99, "M", "R")
table(p_class)
p_class
 M  R 
41 42 
# Make simple 2-way frequency table
table(p_class, test[["Class"]])
p_class  M  R
      M 13 28
      R 30 12
在 R 中使用 caret 的机器学习

使用caret的混淆矩阵

# Use caret to produce confusion matrix
confusionMatrix(p_class, test[["Class"]])
          Reference
Prediction  M  R
         M 13 28
         R 30 12

               Accuracy : 0.3012          
                 95% CI : (0.2053, 0.4118)
    No Information Rate : 0.5181          
    P-Value [Acc > NIR] : 1.0000          

                  Kappa : -0.397          
 Mcnemar's Test P-Value : 0.8955          

            Sensitivity : 0.3023          
            Specificity : 0.3000          
         Pos Pred Value : 0.3171          
         Neg Pred Value : 0.2857
在 R 中使用 caret 的机器学习

开始练习!

在 R 中使用 caret 的机器学习

Preparing Video For Download...