Fit multiple workflows for model stacking
Source:R/h3sdm_fit_models_stack.R
h3sdm_fit_models_stack.Rd
Fits a set of tidymodels workflows using resampling with fit_resamples()
and control_stack_resamples()
to generate objects suitable for stacking.
For each workflow, both the resampled model (cv_model
) and the original
workflow are returned. This is intended as a helper function for creating
ensembles of multiple models in the h3sdm
workflow.
Arguments
- workflows
A named list of tidymodels workflows. Each element should be a workflow object.
- data_split
A resampling object, e.g., generated by
rsample::vfold_cv()
.- presence_data
(Optional) A data frame containing the data to fit the workflows on.
Value
A list with one element models
. Each element of models
is itself
a list with:
cv_model
: the resampled model (tune_results
object)workflow
: the original workflow object
Examples
if (FALSE) { # \dontrun{
# Example requires prepared workflows and resampling object:
# wfs <- list(random_forest = my_workflow_rf, glmnet = my_workflow_glm)
# scv <- rsample::vfold_cv(my_data, v = 5)
results <- h3sdm_fit_models_stack(workflows = wfs, data_split = scv)
results$models$random_forest$cv_model
results$models$random_forest$workflow
} # }