【问题标题】:Creating a Confusion Matrix using caret使用插入符号创建混淆矩阵
【发布时间】:2021-04-16 19:32:53
【问题描述】:

我想创建一个混淆矩阵,并需要使用以下示例将 Precision 提取为向量:

true_values <- sample(c("Dog", "Cat"), 10000, replace = TRUE,
prob = c(0.3, 0.7))
predicted_values <- true_values
predicted_values[sample.int(10000, 4000)] <-
sample(c("Dog", "Cat"), 4000, replace = TRUE, prob = c(0.3, 0.7))

【问题讨论】:

    标签: r precision prediction r-caret confusion-matrix


    【解决方案1】:

    你可以这样做,假设正类是Dog

    cm = confusionMatrix(table(predicted_values,true_values),
    positive="Dog",mode="prec_recall")
    
    cm$byClass["Precision"]
    Precision 
    0.7264901 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-20
      • 2018-09-07
      • 2021-03-02
      • 1970-01-01
      • 2013-11-21
      • 2014-07-16
      • 2020-10-28
      • 1970-01-01
      相关资源
      最近更新 更多