鉴于具有三个不同因素的数据框,我想使用库caret
中的confusionMatrix函数计算精度。对于我给出的例子,我希望类“正”的精度(= Pos Pred Value
)为1。但是,我得到的是“NA”。我在某个地方犯了错误吗?
> temp
Source: local data frame [12 x 2]
ref pred
(fctr) (fctr)
1 positive positive
2 positive positive
3 positive neutral
4 positive positive
5 positive positive
6 positive positive
7 positive positive
8 positive positive
9 positive positive
10 positive positive
11 positive positive
12 positive positive
> confusionMatrix(temp$pred, temp$ref)$byClass
Sensitivity Specificity Pos Pred Value ...
Class: negative NA 1.0000000 NA ...
Class: neutral NA 0.9166667 NA ...
Class: positive 0.9166667 NA NA ...