View source: R/layer_threshold_preds.R
layer_threshold | R Documentation |
This postprocessing step is used to set prediction values that are smaller than the lower threshold or higher than the upper threshold equal to the threshold values.
layer_threshold(
frosting,
...,
lower = 0,
upper = Inf,
id = rand_id("threshold")
)
frosting |
a |
... |
< |
lower |
Lower threshold for the prediction values. That is, any
predictions that are less than this lower bound are set to it.
Default value is |
upper |
Upper threshold for the prediction values. That is, any
predictions that are greater than this upper bound are set to it.
Default value is |
id |
a random id string |
an updated frosting
postprocessor
jhu <- covid_case_death_rates %>%
filter(time_value < "2021-03-08", geo_value %in% c("ak", "ca", "ar"))
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)
f <- frosting() %>%
layer_predict() %>%
layer_threshold(.pred, lower = 0.180, upper = 0.310)
wf <- wf %>% add_frosting(f)
p <- forecast(wf)
p
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.