View source: R/predict_boots.R
predict_boots | R Documentation |
Generate a prediction interval from arbitrary model types using bootstrap
resampling. predict_boots()
generates n
bootstrap resamples, fits a model
to each resample (creating n
models), then creates n
predictions for each
observation in new_data
.
predict_boots( workflow, n = 2000, training_data, new_data, interval = c("prediction", "confidence"), verbose = FALSE, ... )
workflow |
An un-fitted workflow object. |
n |
An integer for the number of bootstrap resampled models that will be created. |
training_data |
A tibble or dataframe of data to be resampled and used for training. |
new_data |
A tibble or dataframe used to make predictions. |
interval |
One of |
verbose |
A logical. Defaults to |
... |
Additional params passed to |
Since predict_boots()
fits a new model to each resample, the
argument workflow
must not yet be fit. Any tuned hyperparameters must be
finalized prior to calling predict_boots()
.
A tibble with a column indicating the row index of each observation in
new_data
and a nested list of the model predictions for each observation.
## Not run: library(tidymodels) # setup a workflow without fitting wf <- workflow() %>% add_recipe(recipe(qsec ~ wt, data = mtcars)) %>% add_model(linear_reg()) # fit and predict 2000 bootstrap resampled models to mtcars set.seed(123) wf %>% predict_boots(n = 2000, training_data = mtcars, new_data = mtcars) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.