Returns the top features that an ML model found to be important for predicting the AMR phenotype of a given pathogen.

extractTopFeats(fit, prop_vi_top_feats = c(0, 1), n_top_feats = NA)

Arguments

fit

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

prop_vi_top_feats

num A vector of length 2 with elements together indicating the proportion of total variable importance the top features should comprise. To get the features that contribute to the top 10 to 20% of total variable importance, for example, set prop_vi_top_feats = c(0.1, 0.2). Returns all features by default.

n_top_feats

num Number of top features to extract

Value

A tibble with a column for top features (Variable), a column for Importance, and a column for Sign (or, for multi-class, a tibble with per-class columns of importance scores for each Variable)

Examples

data(demo_fit)
extractTopFeats(demo_fit, n_top_feats = 10)
#> # A tibble: 10 × 3
#>    Variable    Importance Sign 
#>    <chr>            <dbl> <chr>
#>  1 group_1006        3.50 NEG  
#>  2 group_10051       2.68 POS  
#>  3 group_10040       2.31 POS  
#>  4 group_10013       2.26 POS  
#>  5 group_10033       2.26 NEG  
#>  6 group_10056       1.88 POS  
#>  7 group_10047       1.73 POS  
#>  8 group_10061       1.57 NEG  
#>  9 group_10046       1.39 NEG  
#> 10 group_10001       1.18 NEG