Description Usage Arguments Value Examples
Create an ensemble model from a list of base pipelines and a meta-model specification
1 2 |
base_pipelines |
named list of pipeline objects to use as the base models |
meta_model |
parsnip model specification to use as the meta learning model |
cv |
rsample resampling partial function. By default this is set to vfold_cv(v = 3) |
pass_predictors |
logical, optionally pass the predictors to the meta model as well as the predictions from the base pipeline models |
ensemble object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
library(tidymodels)
library(tidycrossval)
library(magrittr)
data <- iris
rec <- data %>% recipe(Species ~ .) %>%
step_scale(all_predictors()) %>%
step_center(all_predictors())
rf_pipeline <- pipeline(rec, rand_forest(mode = "classification") %>% set_engine("ranger"))
boost_pipeline <- pipeline(rec, boost_tree(mode = "classification") %>% set_engine("xgboost"))
base_pipelines <- list(rf = rf_pipeline, boost = boost_pipeline)
final_model <- mlp(mode = "classification") %>% set_engine("nnet")
object <- ensemble(base_pipelines, final_model, cv = . %>% vfold_cv(v = 3))
ensemble_fitted <- fit(object, data = iris)
preds <- predict(ensemble_fitted, data)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.