I have a large fitted random forest model, created in a tidymodels framework. It is a large (~1Gb) object of class workflow
.
My question: How do a save/ reload this object to disk?
Here is a simple reprex using everyone's fav dataset:
library(ranger)
library(dplyr)
library(rsample)
library(recipes)
library(parsnip)
library(workflows)
split_mtcars <- rsample::initial_split(mtcars, .75)
train_mtcars <- rsample::training(split_mtcars)
test_mtcars <- rsample::testing(split_mtcars)
mtcars_recipe <- recipes::recipe(mpg ~ hp + wt, data = train_mtcars)
# specify random forest model
rf_mod_mtcars <- parsnip::rand_forest() %>%
parsnip::set_engine("ranger") %>%
parsnip::set_mode("regression")
rf_wflow_mtcars <- workflows::workflow() %>%
workflows::add_recipe(mtcars_recipe) %>%
workflows::add_model(rf_mod_mtcars)
rf_model_fit_mtcars <- rf_wflow_mtcars %>%
generics::fit(data = train_mtcars)
predict(rf_model_fit_mtcars, test_mtcars) %>%
cbind(select(test_mtcars, mpg))
####### THE QUESTION: HOW TO SAVE rf_model_fit_mtcars #######
Thank you