Predicts the AMR phenotype in the test data set based on the best fit ML model.

predictML(fit, test_data)

Arguments

fit

Best model fit, such as the output of fitBestModel()

test_data

The part of the pangenome data designated for ML model testing. This can be the output of rsample::testing(splitMLInputTibble(ml_input_tibble)).

Value

Test data (tibble) with an added column for predicted phenotype labels

Examples

data(demo_ml_tibble)
data(demo_fit)
data_split <- splitMLInputTibble(demo_ml_tibble, split = c(1, 0), seed = 1)
predictML(demo_fit, rsample::testing(data_split))
#> # A tibble: 12 × 85
#>    .pred_class .pred_Resistant .pred_Susceptible genome_id
#>    <fct>                 <dbl>             <dbl> <chr>    
#>  1 Susceptible      0.00000330             1.000 623.1384 
#>  2 Susceptible      0.00245                0.998 623.1309 
#>  3 Resistant        0.715                  0.285 623.1284 
#>  4 Resistant        0.715                  0.285 623.1393 
#>  5 Resistant        0.715                  0.285 623.1334 
#>  6 Resistant        0.715                  0.285 623.1281 
#>  7 Resistant        0.715                  0.285 623.1696 
#>  8 Resistant        0.715                  0.285 623.1686 
#>  9 Susceptible      0.00688                0.993 623.1827 
#> 10 Resistant        0.715                  0.285 623.1297 
#> 11 Susceptible      0.00485                0.995 623.1372 
#> 12 Susceptible      0.00198                0.998 623.1812 
#> # ℹ 81 more variables: genome_drug.resistant_phenotype <fct>, group_100 <dbl>,
#> #   group_10000 <dbl>, group_10001 <dbl>, group_10002 <dbl>, group_10003 <dbl>,
#> #   group_10004 <dbl>, group_10005 <dbl>, group_10006 <dbl>, group_10007 <dbl>,
#> #   group_10008 <dbl>, group_10009 <dbl>, group_10010 <dbl>, group_10011 <dbl>,
#> #   group_10012 <dbl>, group_10013 <dbl>, group_10014 <dbl>, group_10015 <dbl>,
#> #   group_10016 <dbl>, group_10017 <dbl>, group_10018 <dbl>, group_10019 <dbl>,
#> #   group_10020 <dbl>, group_10021 <dbl>, group_10022 <dbl>, …