Compare predictions and labels
Usage
compare(
predictions,
labels,
partition = TRUE,
names = c(specificity = 0, sensitivity = 1)
)
Arguments
- predictions
(numeric | character)
vector of class predictions, class and unique values+ need to match those oflabels
.- labels
(numeric | character)
vector of true class labels (reference standard)- partition
(logical)
should result be split into one matrix per class (TRUE; default) or not (FALSE)- names
(character | NULL)
named character. Values specify data values, names specify class names. Ifnames=NULL
, the values and names are defined asunique(labels)
Value
(list | matrix)
list of matrices (one for each unique value of labels
) with
values 1 (correct prediction) and 0 (false prediction).
If partition=TRUE
, the matrices are combined in a single matrix with rbind
.
Examples
pred <- matrix(c(1, 1, 0), 5, 3)
labels <- c(1, 1, 0, 0, 1)
compare(pred, labels, FALSE)
#> V1 V2 V3
#> 1 1 0 1
#> 2 1 1 0
#> 3 1 0 0
#> 4 0 1 0
#> 5 1 1 0
compare(pred, labels, TRUE)
#> $specificity
#> V1 V2 V3
#> 3 1 0 0
#> 4 0 1 0
#>
#> $sensitivity
#> V1 V2 V3
#> 1 1 0 1
#> 2 1 1 0
#> 5 1 1 0
#>