Description Usage Arguments Examples
View source: R/rsample_utils.R
This function facilitates extracting, baking, and predicting assessment
data from a nested
split object created with rolling_origin_nested
. Baking requires a recipe
object
and predicting requires a fitted model object.
1 2 3 4 5 6 7 8 9 | predict_rsample_nested(
split,
recipe,
fit,
id_vars = "all",
predict_options = NULL,
new_steps = NULL,
strings_as_factors = FALSE
)
|
split |
An |
recipe |
An untrained recipe object. |
fit |
A fitted model object. |
id_vars |
A character vector of variables names to be returned along with the predictions. Default is to keep all variables. |
predict_options |
A named list of arguments passed to |
new_steps |
A sequence of steps created using |
strings_as_factors |
A logical: should character columns be converted to factors? This
affects the preprocessed training set (when retain = TRUE) as well as the results of
bake.recipe. Unlike |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## Not run:
data(airquality2)
roll <- rolling_origin_nested(
data = airquality2,
time_var = "date",
unit = "week",
round_fun = lubridate::round_date
)
rec <-
recipe(data = airquality2 %>% slice(0), ozone ~ temp + ozone_sample + ozone_sample_date) %>%
update_role(ozone_sample_date, new_role = "id")
roll2 <- roll %>% mutate(recipe = list(rec))
roll2$fits <-
map2(roll2$splits, roll2$recipe, fit_rsample_nested, model_func = lm)
roll2$predictions <-
pmap(
lst(
split = roll2$splits,
recipe = roll2$recipe,
fit = roll2$fits
),
predict_rsample_nested,
new_steps = exprs(
step_mutate_at(
ozone_sample,
fn = ~ if_else(ozone_sample_date < pred_date, ozone_sample, as.numeric(NA))),
step_meanimpute(ozone_sample))
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.