如何格式化 confusionMatrix 插入符包

How to format confusionMatrix caret package

使用 R 中 caret 包中的 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:

试试这个:

t(confusionMatrix()$byClass)

还有这个:

confusionMatrix()$overall

取决于 类 数据的数量,您可以绑定或不绑定它们