脱字符号R包中的混淆矩阵

时间:2019-01-23 15:09:43

标签: r confusion-matrix

我注意到,在插入符号R包中,混淆矩阵的定义看起来很奇怪。为了说明这一点,我使用包装中的示例:

library(caret)
    lvs <- c("normal", "abnormal")
    truth <- factor(rep(lvs, times = c(86, 258)),
                    levels = rev(lvs))
    pred <- factor(
        c(
            rep(lvs, times = c(54, 32)),
            rep(lvs, times = c(27, 231))),
        levels = rev(lvs))


    confusionMatrix(pred, truth)


Confusion Matrix and Statistics

          Reference
Prediction abnormal normal
  abnormal      231     32
  normal         27     54

               Accuracy : 0.8285          
                 95% CI : (0.7844, 0.8668)
    No Information Rate : 0.75            
    P-Value [Acc > NIR] : 0.0003097       

                  Kappa : 0.5336          
 Mcnemar's Test P-Value : 0.6025370       

            Sensitivity : 0.8953          
            Specificity : 0.6279          
         Pos Pred Value : 0.8783          
         Neg Pred Value : 0.6667          
             Prevalence : 0.7500          
         Detection Rate : 0.6715          
   Detection Prevalence : 0.7645          
      Balanced Accuracy : 0.7616          

       'Positive' Class : abnormal 

根据混淆矩阵:灵敏度= 231/(231+27)= 0.8953488和特异性= 54/(54+32)=0.627907,但是,我认为灵敏度必须为231/(231+32)=0.878327和特异性= 54/(54+27)=0.666667

有人可以解释吗?

0 个答案:

没有答案