Description Usage Arguments Details Value Author(s) See Also Examples
Conversion functions for class confusionMatrix
1 2 3 4 5 |
x |
an object of class |
what |
data to conver to matrix. Either |
... |
not currently used |
For as.table
, the cross-tabulations are saved. For as.matrix
, the three object types are saved in matrix format.
A matrix or table
Max Kuhn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ###################
## 2 class example
lvs <- c("normal", "abnormal")
truth <- factor(rep(lvs, times = c(86, 258)),
levels = rev(lvs))
pred <- factor(
c(
rep(lvs, times = c(54, 32)),
rep(lvs, times = c(27, 231))),
levels = rev(lvs))
xtab <- table(pred, truth)
results <- confusionMatrix(xtab)
as.table(results)
as.matrix(results)
as.matrix(results, what = "overall")
as.matrix(results, what = "classes")
###################
## 3 class example
xtab <- confusionMatrix(iris$Species, sample(iris$Species))
as.matrix(xtab)
|
Loading required package: lattice
Loading required package: ggplot2
truth
pred abnormal normal
abnormal 231 32
normal 27 54
abnormal normal
abnormal 231 32
normal 27 54
[,1]
Accuracy 0.8284883721
Kappa 0.5335968379
AccuracyLower 0.7844134380
AccuracyUpper 0.8667985207
AccuracyNull 0.7500000000
AccuracyPValue 0.0003096983
McnemarPValue 0.6025370061
[,1]
Sensitivity 0.8953488
Specificity 0.6279070
Pos Pred Value 0.8783270
Neg Pred Value 0.6666667
Precision 0.8783270
Recall 0.8953488
F1 0.8867562
Prevalence 0.7500000
Detection Rate 0.6715116
Detection Prevalence 0.7645349
Balanced Accuracy 0.7616279
setosa versicolor virginica
setosa 15 16 19
versicolor 18 16 16
virginica 17 18 15
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.