Fits the best model (output of selectBestModel()).

fitBestModel(final_mod, train_data)

Arguments

final_mod

Best model workflow (output of selectBestModel())

train_data

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

Value

Best model fit

Examples

data(demo_ml_tibble)
data_split <- splitMLInputTibble(demo_ml_tibble, split = c(1, 0), seed = 1)
train <- rsample::training(data_split)
wflow <- buildWflow(buildLRModel(), buildRecipe(train))
set.seed(1)
tune_res <- tuneGrid(wflow, data_split,
  buildTuningGrid("LR", 10^c(-3, -1), c(0, 0.5, 1)),
  n_fold = 2
)
best_wflow <- selectBestModel(tune_res, wflow, "mcc")
fitBestModel(best_wflow, train)
#> ══ Workflow [trained] ══════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: logistic_reg()
#> 
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 2 Recipe Steps
#> 
#> • step_zv()
#> • step_normalize()
#> 
#> ── Model ───────────────────────────────────────────────────────────────────────
#> 
#> Call:  glmnet::glmnet(x = maybe_matrix(x), y = y, family = "binomial",      alpha = ~0) 
#> 
#>     Df  %Dev  Lambda
#> 1   41  0.00 206.600
#> 2   41  0.25 188.200
#> 3   41  0.27 171.500
#> 4   41  0.30 156.300
#> 5   41  0.33 142.400
#> 6   41  0.36 129.700
#> 7   41  0.39 118.200
#> 8   41  0.43 107.700
#> 9   41  0.47  98.150
#> 10  41  0.51  89.430
#> 11  41  0.56  81.490
#> 12  41  0.62  74.250
#> 13  41  0.67  67.650
#> 14  41  0.74  61.640
#> 15  41  0.81  56.170
#> 16  41  0.88  51.180
#> 17  41  0.97  46.630
#> 18  41  1.06  42.490
#> 19  41  1.15  38.710
#> 20  41  1.26  35.270
#> 21  41  1.37  32.140
#> 22  41  1.50  29.280
#> 23  41  1.64  26.680
#> 24  41  1.78  24.310
#> 25  41  1.94  22.150
#> 26  41  2.12  20.180
#> 27  41  2.30  18.390
#> 28  41  2.50  16.760
#> 29  41  2.72  15.270
#> 30  41  2.96  13.910
#> 31  41  3.21  12.680
#> 32  41  3.48  11.550
#> 33  41  3.77  10.520
#> 34  41  4.08   9.589
#> 35  41  4.41   8.738
#> 36  41  4.77   7.961
#> 37  41  5.14   7.254
#> 38  41  5.55   6.610
#> 39  41  5.97   6.022
#> 40  41  6.43   5.487
#> 41  41  6.91   5.000
#> 42  41  7.42   4.556
#> 43  41  7.96   4.151
#> 44  41  8.53   3.782
#> 45  41  9.13   3.446
#> 46  41  9.77   3.140
#> 
#> ...
#> and 54 more lines.