library(parsnip)
library(rsample)
library(workflowsets)
set.seed(1)
folds <- vfold_cv(mtcars, v = 5)
# \donttest{
mpg_models <-
workflow_set(
preproc = list(
small = mpg ~ wt,
medium = mpg ~ wt + hp,
large = mpg ~ .
),
models = list(lm = linear_reg())
) |>
workflow_map("fit_resamples", resamples = folds, seed = 2)
set.seed(4321)
mpg_post <- perf_mod(mpg_models, metric = "rmse", refresh = 0, chains = 2)
mpg_res <- compare_to_leader(mpg_post, size = 0.5, seed = 2)
autoplot(mpg_res)
# Spell the metric out and give it units:
autoplot(mpg_res, metric_label = "RMSE (miles per gallon)")
# }
Run the code above in your browser using DataLab