Skip to content

Commit 757b2a6

Browse files
committed
fix: covid_hosp_explore with package updates
1 parent afc0fe1 commit 757b2a6

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

R/aux_data_utils.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ daily_to_weekly_archive <- function(epi_arch,
194194
day_of_week = 4L,
195195
day_of_week_end = 7L) {
196196
agg_method <- arg_match(agg_method)
197-
keys <- key_colnames(epi_arch, exclude = "time_value")
197+
keys <- key_colnames(epi_arch, exclude = c("time_value", "version"))
198198
ref_time_values <- epi_arch$DT$version %>%
199199
unique() %>%
200200
sort()
@@ -229,6 +229,7 @@ daily_to_weekly_archive <- function(epi_arch,
229229
) %>%
230230
select(-all_of(agg_columns)) %>%
231231
rename_with(~ gsub("slide_value_", "", .x)) %>%
232+
rename_with(~ gsub("_7dsum", "", .x)) %>%
232233
# only keep 1/week
233234
# group_by week, keep the largest in each week
234235
# alternatively

R/scoring.R

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@ evaluate_predictions <- function(predictions_cards, truth_data) {
1212
must.include = c("geo_value", "target_end_date", "true_value")
1313
)
1414

15-
left_join(predictions_cards, truth_data, by = c("geo_value", "target_end_date")) %>%
16-
scoringutils::score(metrics = c("interval_score", "ae_median", "coverage")) %>%
17-
scoringutils::add_coverage(by = c("model", "geo_value", "forecast_date", "target_end_date"), ranges = c(80)) %>%
18-
scoringutils::summarize_scores(by = c("model", "geo_value", "forecast_date", "target_end_date")) %>%
15+
forecast_obj <- left_join(predictions_cards, truth_data, by = c("geo_value", "target_end_date")) %>%
16+
scoringutils::as_forecast_quantile(
17+
quantile_level = "quantile",
18+
observed = "true_value",
19+
predicted = "prediction",
20+
forecast_unit = c("model", "geo_value", "forecast_date", "target_end_date")
21+
)
22+
23+
scores <- forecast_obj %>%
24+
scoringutils::score(metrics = get_metrics(.)) %>%
1925
as_tibble() %>%
2026
select(
21-
model,
22-
geo_value,
23-
forecast_date,
24-
target_end_date,
25-
wis = interval_score,
27+
model, geo_value, forecast_date, target_end_date,
28+
wis,
2629
ae = ae_median,
27-
coverage_80
30+
coverage_50 = interval_coverage_50,
31+
coverage_90 = interval_coverage_90
2832
) %>%
2933
mutate(ahead = as.numeric(target_end_date - forecast_date))
3034
}

scripts/covid_hosp_explore.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ if (!exists("ref_time_values_")) {
88
# Alternatively you can let slide_forecaster figure out ref_time_values
99
start_date <- as.Date("2023-10-04")
1010
end_date <- as.Date("2024-04-24")
11+
# end_date <- start_date + 7 * 10
1112
date_step <- 7L
12-
# ref_time_values_ <- as.Date(c("2023-11-08", "2023-11-22"))
13+
ref_time_values_ <- seq.Date(as.Date("2023-10-04"), as.Date("2024-04-24"), by = 7L)
1314
}
1415
time_value_adjust <- 3 # this moves the week marker from Saturday to Wednesday
1516

scripts/targets-common.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ main_controller <- crew_controller_local(
2121
seconds_timeout = 7 * 24 * 60 * 60L, # 7 days is probably enough
2222
garbage_collection = TRUE,
2323
options_local = crew_options_local(log_directory = "local_logs"),
24-
tasks_max = 1L,
25-
launch_max = 10000L
24+
# tasks_max = 1L,
25+
# launch_max = 10000L
2626
)
2727
# The external scores processing causes the pipeline to exit with an error,
2828
# apparently due to running out of memory. Set up a non-parallel `crew`
@@ -35,8 +35,8 @@ serial_controller <- crew_controller_local(
3535
seconds_idle = 60L,
3636
seconds_timeout = 7 * 24 * 60 * 60L,
3737
garbage_collection = TRUE,
38-
tasks_max = 1L,
39-
launch_max = 10000L
38+
# tasks_max = 1L,
39+
# launch_max = 10000L
4040
)
4141

4242
# Serial mode is better for debugging.

0 commit comments

Comments
 (0)