add_frosting: Add frosting to a workflow

View source: R/frosting.R

add_frostingR Documentation

Add frosting to a workflow

Description

Add frosting to a workflow

Usage

add_frosting(x, frosting, ...)

remove_frosting(x)

update_frosting(x, frosting, ...)

Arguments

x

A workflow

frosting

A frosting object created using frosting().

...

Not used.

Value

x, updated with a new frosting postprocessor

Examples

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)

wf <- epi_workflow(r, linear_reg()) %>% fit(jhu)
latest <- jhu %>%
  filter(time_value >= max(time_value) - 14)

# Add frosting to a workflow and predict
f <- frosting() %>%
  layer_predict() %>%
  layer_naomit(.pred)
wf1 <- wf %>% add_frosting(f)
p1 <- predict(wf1, latest)
p1

# Update frosting in a workflow and predict
f2 <- frosting() %>% layer_predict()
wf2 <- wf1 %>% update_frosting(f2)
p2 <- predict(wf2, latest)
p2

# Remove frosting from the workflow and predict
wf3 <- wf2 %>% remove_frosting()
p3 <- predict(wf3, latest)
p3


cmu-delphi/epipredict documentation built on March 5, 2025, 12:17 p.m.