【问题标题】:How to format confusionMatrix caret package如何格式化confusionMatrix插入符号包
【发布时间】:2017-05-08 05:14:08
【问题描述】:

使用 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:

【问题讨论】:

  • 如果你想完全控制打印格式,你可以手动访问元素,即confusionMatrix()$byClass
  • 您使用哪个命令来创建此输出?默认情况下,我通常会垂直对齐。
  • 我清除了会话,重新运行了代码,第二次得到了我正在寻找的输出。我不确定我做了什么,但现在可以了。谢谢!

标签: r r-caret confusion-matrix


【解决方案1】:

试试这个:

t(confusionMatrix()$byClass)

还有这个:

confusionMatrix()$overall

根据数据类别的数量,您可以绑定或不绑定它们

【讨论】:

  • 谢谢!这很好用。我不会清除我的会话并重新运行我的代码,而是实现你的方法
猜你喜欢
  • 1970-01-01
  • 2018-02-22
  • 1970-01-01
  • 1970-01-01
  • 2011-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多