Returns the confusion matrix based on the AMR phenotype predictions by an ML model compared against the actual values.

getConfusionMatrix(test_data_plus_predictions)

Arguments

test_data_plus_predictions

Test data (tibble) with an added column for predicted phenotype labels, such as the output of predictML()

Value

Confusion matrix of class conf_mat

Examples

preds <- tibble::tibble(
  genome_id = paste0("g", 1:8),
  genome_drug.resistant_phenotype = factor(
    rep(c("Resistant", "Susceptible"), each = 4),
    levels = c("Resistant", "Susceptible")
  ),
  .pred_class = factor(
    c(
      "Resistant", "Resistant", "Susceptible", "Resistant",
      "Susceptible", "Resistant", "Susceptible", "Susceptible"
    ),
    levels = c("Resistant", "Susceptible")
  )
)
getConfusionMatrix(preds)
#>              Truth
#> Prediction    Resistant Susceptible
#>   Resistant           3           1
#>   Susceptible         1           3