Skip to content

Commit 4680e05

Browse files
committed
fix
1 parent a624f65 commit 4680e05

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

R/aux_data_utils.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,8 @@ get_health_data <- function(as_of, disease = c("covid", "flu")) {
314314

315315
most_recent_row <- meta_data %>%
316316
# update_date is actually a time, so we need to filter for the day after.
317-
filter(update_date <= as_of + 1) %>%
318-
arrange(desc(update_date)) %>%
319-
slice(1)
317+
filter(update_date <= as.Date(as_of) + 1) %>%
318+
slice_max(update_date)
320319

321320
if (nrow(most_recent_row) == 0) {
322321
cli::cli_abort("No data available for the given date.")
@@ -332,9 +331,7 @@ get_health_data <- function(as_of, disease = c("covid", "flu")) {
332331
if (disease == "covid") {
333332
data %<>% mutate(
334333
hhs = previous_day_admission_adult_covid_confirmed +
335-
previous_day_admission_adult_covid_suspected +
336-
previous_day_admission_pediatric_covid_confirmed +
337-
previous_day_admission_pediatric_covid_suspected
334+
previous_day_admission_pediatric_covid_confirmed
338335
)
339336
} else if (disease == "flu") {
340337
data %<>% mutate(hhs = previous_day_admission_influenza_confirmed)

R/forecasters/epipredict_utilities.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ run_workflow_and_format <- function(preproc,
125125
# keeping only the last time_value for any given location/key
126126
pred %<>%
127127
group_by(across(all_of(key_colnames(train_data, exclude = "time_value")))) %>%
128-
# TODO: slice_max(time_value)?
129-
arrange(time_value) %>%
130-
filter(row_number() == n()) %>%
128+
slice_max(time_value) %>%
131129
ungroup()
132130
return(format_storage(pred, as_of))
133131
}

R/forecasters/forecaster_scaled_pop.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ scaled_pop <- function(epi_data,
141141
by = c("geo_value" = "abbr")
142142
)
143143
}
144+
144145
# with all the setup done, we execute and format
145146
pred <- run_workflow_and_format(preproc, postproc, trainer, season_data, epi_data)
146147
# now pred has the columns
@@ -155,6 +156,15 @@ scaled_pop <- function(epi_data,
155156
if (adding_source) {
156157
pred_final %<>% select(-source)
157158
}
159+
browser()
160+
res %>%
161+
group_by(geo_value, forecast_date, target_end_date) %>%
162+
summarize(increasing = all(hhs - shift(hhs, 1, -Inf) > 0)) %>%
163+
ungroup() %>%
164+
filter(!increasing)
165+
166+
res %>%
167+
filter(geo_value == "ma", forecast_date == "2023-10-18", target_end_date == "2023-10-18")
158168
gc()
159169
return(pred_final)
160170
}

scripts/covid_hosp_explore.R

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,14 @@ if (!exists("ref_time_values_")) {
1010
end_date <- as.Date("2024-04-24")
1111
# end_date <- start_date + 7 * 10
1212
date_step <- 7L
13-
ref_time_values_ <- seq.Date(as.Date("2023-10-21"), as.Date("2024-04-24"), by = 7L)[1]
13+
ref_time_values_ <- seq.Date(start_date, end_date, by = 7L)[3]
1414
}
1515
time_value_adjust <- 3 # this moves the week marker from Saturday to Wednesday
1616

1717
# Debug mode will replace all forecasters with a fast dummy forecaster. Helps
1818
# with prototyping the pipeline.
1919
dummy_mode <- as.logical(Sys.getenv("DUMMY_MODE", FALSE))
2020

21-
# these are for datasets which have some locations with extreme latency; currently that's only nwss
22-
# note that this has a vector of names first, and then the list of things to
23-
# exclude, because targets hates named lists and strips their names
24-
very_latent_locations <- list(list(
25-
c("geo_value"),
26-
c("la", "ms", "nd")
27-
))
28-
# TODO decide on this, nwss is latent in these locations by ~56 days. might be ok
2921

3022
# Human-readable object to be used for inspecting the forecasters in the pipeline.
3123
forecaster_parameter_combinations_ <- rlang::list2(

scripts/targets-exploration-common.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ make_forecasts_and_scores <- function() {
155155
name = forecast,
156156
command = {
157157
debugonce(scaled_pop)
158+
debugonce(slide_forecaster)
158159
browser()
159160
slid <- slide_forecaster(
160161
epi_archive = joined_archive_data,

0 commit comments

Comments
 (0)