Selects best model by F1 score, AUPRC, MCC, or balanced accuracy.
selectBestModel(tune_res, wflow, select_best_metric = "mcc")Results of grid tuning, such as the output of tuneGrid()
A workflows object, such as the output of buildWflow()
chr Metric to select best model: "f_meas", "pr_auc", "mcc", or "bal_accuracy"
Best model workflow
data(demo_ml_tibble)
data_split <- splitMLInputTibble(demo_ml_tibble, split = c(1, 0), seed = 1)
wflow <- buildWflow(
buildLRModel(),
buildRecipe(rsample::training(data_split))
)
set.seed(1)
tune_res <- tuneGrid(wflow, data_split,
buildTuningGrid("LR", 10^c(-3, -1), c(0, 0.5, 1)),
n_fold = 2
)
selectBestModel(tune_res, wflow, "mcc")
#> ══ Workflow ════════════════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: logistic_reg()
#>
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 2 Recipe Steps
#>
#> • step_zv()
#> • step_normalize()
#>
#> ── Model ───────────────────────────────────────────────────────────────────────
#> Logistic Regression Model Specification (classification)
#>
#> Main Arguments:
#> penalty = 0.001
#> mixture = 0
#>
#> Computational engine: glmnet
#>