topepo/caret

(maybe) the argument confusionMatrix() wrong

gosmah opened this issue · 0 comments

Hello, i think the confusionMatrix() have wrong formula or argument.

dat2 <- data.frame(real = as.factor(c(1,1,1,0,0,1,1,1,1)), pred = as.factor(c(1,1,0,1,0,1,1,1,0)))
dat2
real pred
1 1 1
2 1 1
3 1 0
4 0 1
5 0 0
6 1 1
7 1 1
8 1 1
9 1 0

the precision of class "0" should be TP÷(TP+FP) right? so it should be 1÷(1+1)=0.5 but when i run using confusionMatrix() command the precision become like this below

image

i follow it like the guide confusionMatrix(data =....., reference=.....,) where data is predictive & reference is true result.
maybe some formula wrong or maybe the table made by confusionMatrix() command is wrong by swapping the FP & FN value

Please let me know it i wrong or right