View source: R/layer_predict.R
layer_predict | R Documentation |
Implements prediction on a fitted epi_workflow
. One may want different
types of prediction, and to potentially apply this after some amount of
postprocessing. This would typically be the first layer in a frosting
postprocessor.
layer_predict(
frosting,
type = NULL,
opts = list(),
...,
id = rand_id("predict_default")
)
frosting |
a frosting object |
type |
A single character value or |
opts |
A list of optional arguments to the underlying
predict function that will be used when |
... |
Additional
|
id |
a string identifying the layer |
An updated frosting
object
parsnip::predict.model_fit()
jhu <- covid_case_death_rates %>%
filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
r <- epi_recipe(jhu) %>%
step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
step_epi_ahead(death_rate, ahead = 7) %>%
step_epi_naomit()
wf <- epi_workflow(r, linear_reg()) %>% fit(jhu)
latest <- jhu %>% filter(time_value >= max(time_value) - 14)
# Predict layer alone
f <- frosting() %>% layer_predict()
wf1 <- wf %>% add_frosting(f)
p1 <- predict(wf1, latest)
p1
# Prediction with interval
f <- frosting() %>% layer_predict(type = "pred_int")
wf2 <- wf %>% add_frosting(f)
p2 <- predict(wf2, latest)
p2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.