Returns the confusion matrix and validation scores for a binary reference variable, and a binary prediction variable.
Value
A confusionMatrix
object from caret::confusionMatrix()
.
Details
The values of reference
and prediction
must be 0 or 1. Both variables
can be stored in a data.frame or as vectors of equal length. Can be of type numeric
or factor.
Examples
mtcars$pred <- get_prediction(mtcars, mtcars$am, mtcars$drat)
confuse(mtcars$am, mtcars$pred)
#> Confusion Matrix and Statistics
#>
#>
#> 0 1
#> 0 16 2
#> 1 3 11
#>
#> Accuracy : 0.8438
#> 95% CI : (0.6721, 0.9472)
#> No Information Rate : 0.5938
#> P-Value [Acc > NIR] : 0.002273
#>
#> Kappa : 0.68
#>
#> Mcnemar's Test P-Value : 1.000000
#>
#> Precision : 0.7857
#> Recall : 0.8462
#> F1 : 0.8148
#> Prevalence : 0.4062
#> Detection Rate : 0.3438
#> Detection Prevalence : 0.4375
#> Balanced Accuracy : 0.8441
#>
#> 'Positive' Class : 1
#>