@@ -27,8 +27,8 @@ forecast_dates <- forecast_dates[1:10]
2727# Human-readable object to be used for inspecting the forecasters in the pipeline.
2828forecaster_parameter_combinations <- rlang :: list2(
2929 scaled_pop_main = tidyr :: expand_grid(
30- forecaster = list ( scaled_pop ) ,
31- trainer = list (linreg , quantreg ),
30+ forecaster = " scaled_pop" ,
31+ trainer = list (" linreg" , " quantreg" ),
3232 lags = list (
3333 c(0 , 7 ),
3434 c(0 , 7 , 14 ),
@@ -39,13 +39,13 @@ forecaster_parameter_combinations <- rlang::list2(
3939 n_training = Inf
4040 ),
4141 flatline_forecaster = tidyr :: expand_grid(
42- forecaster = list ( flatline_fc ) ,
42+ forecaster = " flatline_fc" ,
4343 ),
4444 # using exogenous variables
4545 scaled_pop_exogenous = bind_rows(
4646 expand_grid(
47- forecaster = list ( scaled_pop ) ,
48- trainer = list ( quantreg ) ,
47+ forecaster = " scaled_pop" ,
48+ trainer = " quantreg" ,
4949 # since it's a list, this gets expanded out to a single one in each row
5050 extra_sources = list2(" nssp" , " google_symptoms_4_bronchitis" , " google_symptoms" , " nwss" , " nwss_region" ),
5151 lags = list2(
@@ -68,8 +68,8 @@ forecaster_parameter_combinations <- rlang::list2(
6868 drop_non_seasons = FALSE ,
6969 ),
7070 expand_grid(
71- forecaster = list ( scaled_pop ) ,
72- trainer = list ( quantreg ) ,
71+ forecaster = " scaled_pop" ,
72+ trainer = " quantreg" ,
7373 extra_sources = list2(
7474 # # c("dr_visits", "google_symptoms"),
7575 # # c("dr_visits", "nssp"),
@@ -99,8 +99,8 @@ forecaster_parameter_combinations <- rlang::list2(
9999 drop_non_seasons = FALSE ,
100100 ),
101101 expand_grid(
102- forecaster = list ( scaled_pop ) ,
103- trainer = list ( quantreg ) ,
102+ forecaster = " scaled_pop" ,
103+ trainer = " quantreg" ,
104104 extra_sources = list2(
105105 c(" nssp" , " google_symptoms" , " nwss" , " nwss_region" ),
106106 ),
@@ -131,8 +131,8 @@ forecaster_parameter_combinations <- rlang::list2(
131131 )
132132 ),
133133 scaled_pop_season = tidyr :: expand_grid(
134- forecaster = list ( scaled_pop_seasonal ) ,
135- trainer = list ( quantreg ) ,
134+ forecaster = " scaled_pop_seasonal" ,
135+ trainer = " quantreg" ,
136136 lags = list (
137137 c(0 , 7 , 14 , 21 ),
138138 c(0 , 7 )
@@ -144,7 +144,7 @@ forecaster_parameter_combinations <- rlang::list2(
144144) %> %
145145 map(function (x ) {
146146 if (dummy_mode ) {
147- x $ forecaster <- list ( dummy_forecaster )
147+ x $ forecaster <- " dummy_forecaster"
148148 }
149149 x
150150 }) %> %
@@ -193,17 +193,21 @@ get_partially_applied_forecaster <- function(id) {
193193 !!! params_list [[id ]],
194194 .homonyms = " last"
195195 )
196- rlang :: inject(forecaster_functions_list [[id ]](epi_data = epi_data , !!! forecaster_args ))
196+ # This uses string lookup to get the function.
197+ forecaster_fn <- get(forecaster_functions_list [[id ]])
198+ rlang :: inject(forecaster_fn(epi_data = epi_data , !!! forecaster_args ))
197199 }
198200}
199201
200202# ================================ TARGETS =================================
201203# ================================ PARAMETERS TARGETS ======================
202204parameter_targets <- list2(
203- # tar_target(name = forecaster_names, command = forecaster_functions_list %>% names()),
204205 tar_target(name = aheads , command = c(0 , 7 , 14 , 21 )),
206+ tar_target(name = ref_time_values , command = forecast_dates ),
207+ # This is used for parameter lookup.
208+ tar_target(name = forecaster_parameter_grid , command = forecaster_parameter_combinations ),
209+ # This is used for generating notebooks.
205210 tar_target(name = forecaster_families , command = forecaster_parameter_combinations %> % names()),
206- tar_target(name = ref_time_values , command = forecast_dates )
207211)
208212# ================================ DATA TARGETS ==============================
209213data_targets <- list2(
0 commit comments