I've recently been using tidymodels to run models and select parameters that best satisfy some objective function. For example using a hypothetical regression on mtcars data (using the regression examples from the bottom answer of this question as an example)
library(tidymodels)
library(tidyverse)
#some regression model
cars_recipe <- recipe(mpg ~ disp + drat, data = mtcars)
wf <- workflow() %>%
add_recipe(cars_recipe)
(roughly using syntax from this blog post for comparison; I'm not doing various steps like splitting test/train just for clarity in this example)
I can then run many models and get the metrics from those models (in this case for various penalties for some elastic nets) thusly
#run over a parameter space and find metrics as an objective
mtcars_bootstrap <- bootstraps(mtcars)
tune_spec <- linear_reg(penalty = tune(), mixture = 1) %>%
set_engine("glmnet")
lambda_grid <- grid_regular(penalty(), levels = 50)
lasso_grid <- tune_grid(
wf %>% add_model(tune_spec),
resamples = mtcars_bootstrap,
grid = lambda_grid
)
but lets say I have good reason to think there are two separate models which may best capture the effect on (e.g.) mpg of a car so I create a second model as a recipe
cars_recipe2 <- recipe(mpg ~ I(disp + drat), data = mtcars)
now I could just also run this recipe through the above pipeline using lapply or the purrr family of functions, however, I wondered if there is some built-in way to run multiple recipes through tidymodels?
It seems like there should be though I also thought it might be precluded by design to prevent p-hacking