@@ -58,10 +58,11 @@ forecaster_fns <- list2(
5858 fcst
5959 }
6060)
61+ indices <- seq_along(forecaster_fns )
6162
6263rlang :: list2(
6364 tar_target(aheads , command = - 1 : 3 ),
64- tar_target(forecasters , command = seq_along( forecaster_fns ) ),
65+ tar_target(forecasters , command = indices ),
6566 tar_target(
6667 download_latest ,
6768 command = {
@@ -121,13 +122,12 @@ rlang::list2(
121122 }
122123 ),
123124 tar_map(
124- values = tidyr :: expand_grid(
125- tibble(
125+ values = tibble(
126126 forecast_date_int = forecast_date ,
127- forecast_generation_date_int = forecast_generation_date
128- )
129- ),
130- names = " forecast_date " ,
127+ forecast_generation_date_int = forecast_generation_date ,
128+ forecast_date_chr = as.character( forecast_date_int )
129+ ),
130+ names = " forecast_date_chr " ,
131131 tar_target(
132132 name = geo_forecasters_weights ,
133133 command = {
@@ -158,11 +158,16 @@ rlang::list2(
158158 } else {
159159 train_data <-
160160 nhsn_latest_data %> %
161+ select(- version ) %> %
161162 data_substitutions(disease = " covid" ) %> %
162- as_epi_df(as_of = as.Date(forecast_date_int ))
163+ as_epi_df(as_of = as.Date(forecast_date_int )) %> %
164+ mutate(time_value = time_value - 3 )
163165 }
164- nssp <- current_nssp_archive %> % epix_as_of(min(forecast_date , current_nssp_archive $ versions_end ))
166+ nssp <- current_nssp_archive %> %
167+ epix_as_of(min(forecast_date , current_nssp_archive $ versions_end )) %> %
168+ mutate(time_value = time_value )
165169 attributes(train_data )$ metadata $ as_of <- as.Date(forecast_date_int )
170+ print(names(forecaster_fns [forecasters ]))
166171 train_data %> %
167172 forecaster_fns [[forecasters ]](ahead = aheads , extra_data = nssp ) %> %
168173 mutate(
@@ -199,7 +204,9 @@ rlang::list2(
199204 ) %> %
200205 filter(geo_value %nin % geo_exclusions ) %> %
201206 ungroup() %> %
202- bind_rows(forecast_res %> % filter(forecaster == " windowed_seasonal_extra_sources" )) %> %
207+ bind_rows(forecast_res %> %
208+ filter(forecaster == " windowed_seasonal_extra_sources" ) %> %
209+ filter(forecast_date < target_end_date )) %> % # don't use for neg aheads
203210 group_by(geo_value , forecast_date , target_end_date , quantile ) %> %
204211 summarize(value = mean(value , na.rm = TRUE ), .groups = " drop" ) %> %
205212 sort_by_quantile()
0 commit comments