> library(metrica)
> library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
> library(purrr)
> library(ggplot2)
> library(tidyr)
>
> binomial_case <- [Link](labels = sample(c("Pos","Neg"), 100, replace = TRUE),
+ predictions = sample(c("Pos","Neg"), 100, replace = TRUE)) %>%
+ mutate(predictions = [Link](predictions), labels = [Link](labels))
>
> multinomial_case <- [Link](labels = sample(c("Red","Green", "Blue"), 100, replace = TRUE),
+ predictions = sample(c("Red","Green", "Blue"), 100, replace = TRUE) ) %>%
+ mutate(predictions = [Link](predictions), labels = [Link](labels))
>
> binomial_case %>% accuracy(data = ., obs = labels, pred = predictions, tidy=TRUE)
accuracy
1 0.43
> binomial_case %>% metrics_summary(data = ., obs = labels, pred = predictions, type =
"classification")
Metric Score
1 accuracy 0.4300000
2 error_rate 0.5700000
3 precision 0.4313725
4 recall 0.4400000
5 specificity 0.4200000
6 balacc 0.4300000
7 fscore 0.4356436
8 agf 0.4356513
9 gmean 0.4298837
10 khat -0.1400000
11 mcc -0.1400280
12 fmi 0.4356649
13 bmi -0.1400000
14 csi 0.3055556
15 deltap -0.1400560
16 posLr 0.7586207
17 negLr 1.3333333
18 dor 0.5689655
19 npv 0.4285714
20 FPR 0.5800000
21 FNR 0.5600000
22 FDR 0.5686275
23 FOR 0.5714286
24 preval 0.5000000
25 preval_t 0.4941853
26 AUC_roc 0.5014280