Returns the F1 score, area under the precision-recall curve (AUPRC), balanced accuracy, normalized (to a 0 to 1 scale instead of -1 to 1) Matthews correlation coefficient (nMCC), and log2(AUPRC/prior) based on the AMR phenotype predictions by an ML model compared against the actual values.
calculateEvalMets(test_data_plus_predictions)Test data (tibble) with an added column for
predicted phenotype labels, such as the output of predictML()
F1 score, AUPRC, balanced accuracy, nMCC, and log2(AUPRC/prior)
preds <- tibble::tibble(
genome_id = paste0("g", 1:10),
genome_drug.resistant_phenotype = factor(
rep(c("Resistant", "Susceptible"), each = 5),
levels = c("Resistant", "Susceptible")
),
.pred_class = factor(
c(
"Resistant", "Resistant", "Susceptible", "Resistant", "Susceptible",
"Susceptible", "Resistant", "Susceptible", "Susceptible", "Resistant"
),
levels = c("Resistant", "Susceptible")
),
.pred_Resistant = c(0.9, 0.8, 0.4, 0.7, 0.3, 0.2, 0.6, 0.1, 0.2, 0.55),
.pred_Susceptible = c(0.1, 0.2, 0.6, 0.3, 0.7, 0.8, 0.4, 0.9, 0.8, 0.45)
)
calculateEvalMets(preds)
#> Warning: Classes are roughly balanced. Calculation of log2(AUPRC/prior) may be inappropriate.
#> [1] 0.60 0.86 0.60 0.60 0.78