如何格式化confusionMatrix插入符号包

时间:2016-12-22 14:33:29

标签: r r-caret confusion-matrix

使用R中插入符号包中的confusionMatrix()函数,如何垂直格式化输出?

我目前的输出如下:

$positive
[1] "spam"

$table
          Reference
Prediction  ham spam
      ham  1201   30
      spam    6  153

$overall
      Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull AccuracyPValue 
  9.741007e-01   8.800535e-01   9.643235e-01   9.817960e-01   8.683453e-01   5.647960e-44 
 McnemarPValue 
  1.264185e-04 

$byClass
         Sensitivity          Specificity       Pos Pred Value       Neg Pred Value 
           0.8360656            0.9950290            0.9622642            0.9756296 
           Precision               Recall                   F1           Prevalence 
           0.9622642            0.8360656            0.8947368            0.1316547 
      Detection Rate Detection Prevalence    Balanced Accuracy 
           0.1100719            0.1143885            0.9155473 

$mode
[1] "sens_spec"

我想要像:

Accuracy:
95% CI
No Information Rate:
P-Value [Acc > NIR]:

Kappa:
Mcnemar's Test P-Value:

Sensitivity:
Specificity:
Pos Pred Value:
Neg Pred Value:
Prevalence:
Detection Rate:
Detection Prevalence:
Balanced Accuracy:

1 个答案:

答案 0 :(得分:1)

试试这个:

t(confusionMatrix()$byClass)

和此:

confusionMatrix()$overall

根据您的数据类别数量,您可以对其进行判断