Combines a model specification and a prepared recipe into a single tidymodels
workflow. This workflow is suitable for species distribution modeling using H3
hexagonal grids and can be directly fitted or cross-validated.
Arguments
- model_spec
A
tidymodelsmodel specification (e.g.,logistic_reg(),rand_forest(), orboost_tree()), describing the model type and engine to use for fitting. Useset_mode("classification")for presence/absence models andset_mode("regression")for count-based models (species richness, detections, or individuals).- recipe
A
tidymodelsrecipe object, typically created withh3sdm_recipe(), which preprocesses the data and defines predictor/response roles. Useresponse_col = "count"inh3sdm_recipe()when working with count data.
Value
A workflow object ready to be used for model fitting with fit()
or cross-validation.
Details
The function creates a workflow that combines preprocessing and modeling
steps. This encapsulation allows consistent model training and evaluation
with tidymodels functions like fit() or fit_resamples(), and is
particularly useful when applying multiple models in parallel.
Choosing the model mode:
For presence/absence data: use
set_mode("classification").For count data (species richness, detections, individuals): use
set_mode("regression").
Examples
if (FALSE) { # \dontrun{
library(parsnip)
# --- Presence/absence model ---
rf_spec_pa <- rand_forest() %>%
set_engine("ranger") %>%
set_mode("classification")
rec_pa <- h3sdm_recipe(combined_data)
wf_pa <- h3sdm_workflow(model_spec = rf_spec_pa, recipe = rec_pa)
# --- Count-based model ---
rf_spec_count <- rand_forest() %>%
set_engine("ranger") %>%
set_mode("regression")
rec_count <- h3sdm_recipe(combined_data, response_col = "count")
wf_count <- h3sdm_workflow(model_spec = rf_spec_count, recipe = rec_count)
} # }