Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk authored May 22, 2024
2 parents 8e85102 + 65a7e47 commit b8d3a1c
Show file tree
Hide file tree
Showing 9 changed files with 32,201 additions and 144 deletions.
110 changes: 62 additions & 48 deletions code/ensemble/EuroCOVIDhub/create-weekly-ensemble.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,6 @@ exclude_models <-
filter(forecast_date == !!forecast_date) %>%
pull(model)

# Run weekly automated ensemble -----------------------------------------
hub_ensemble <- run_ensemble(
method = method,
forecast_date = forecast_date,
exclude_models = exclude_models,
min_nmodels = 3,
return_criteria = TRUE
)

# Save in data-processed
vroom_write(hub_ensemble$ensemble,
here("data-processed",
paste0("EuroCOVIDhub-ensemble"),
paste0(hub_ensemble$forecast_date,
"-EuroCOVIDhub-ensemble.csv")),
delim = ",")


# Save criteria + methods -------------------------------------------------
suppressWarnings(
dir.create(here("code", "ensemble", "EuroCOVIDhub", "criteria"))
)
vroom_write(hub_ensemble$criteria,
here("code", "ensemble", "EuroCOVIDhub",
"criteria",
paste0("criteria-", hub_ensemble$forecast_date, ".csv")),
delim = ",")

# Add method to csv
methods_by_date_file <-
here("code", "ensemble", "EuroCOVIDhub", "method-by-date.csv")
if (file.exists(methods_by_date_file)) {
methods_by_date <- vroom(methods_by_date_file)
} else {
methods_by_date <- tibble(forecast_date = as.Date(character(0)),
method = character(0))
}
methods_by_date %>%
add_row(forecast_date = hub_ensemble$forecast_date,
method = method) %>%
## remove all but last entry if dates are multiple
group_by(forecast_date) %>%
slice(n()) %>%
ungroup() %>%
vroom_write(here("code", "ensemble", "EuroCOVIDhub",
"method-by-date.csv"),
delim = ",")

# Create ensemble with all available models -------------------------------
hub_ensemble_all <- run_ensemble(
method = method,
Expand Down Expand Up @@ -100,3 +52,65 @@ vroom_write(hub_ensemble_all$ensemble,
paste0(hub_ensemble_all$forecast_date,
"-EuroCOVIDhub-ensemble_all.csv")),
delim = ",")

# Run weekly automated ensemble -----------------------------------------
hub_ensemble <- run_ensemble(
method = method,
forecast_date = forecast_date,
exclude_models = exclude_models,
min_nmodels = 3,
return_criteria = TRUE
)

if (nrow(hub_ensemble$ensemble) > 0) {
# Save in data-processed
vroom_write(hub_ensemble$ensemble,
here("data-processed",
paste0("EuroCOVIDhub-ensemble"),
paste0(hub_ensemble$forecast_date,
"-EuroCOVIDhub-ensemble.csv")),
delim = ",")

# Save criteria + methods -------------------------------------------------
suppressWarnings(
dir.create(here("code", "ensemble", "EuroCOVIDhub", "criteria"))
)
vroom_write(hub_ensemble$criteria,
here(
"code", "ensemble", "EuroCOVIDhub",
"criteria",
paste0("criteria-", hub_ensemble$forecast_date, ".csv")
),
delim = ","
)

# Add method to csv
methods_by_date_file <-
here("code", "ensemble", "EuroCOVIDhub", "method-by-date.csv")
if (file.exists(methods_by_date_file)) {
methods_by_date <- vroom(methods_by_date_file)
} else {
methods_by_date <- tibble(
forecast_date = as.Date(character(0)),
method = character(0)
)
}
methods_by_date %>%
add_row(
forecast_date = hub_ensemble$forecast_date,
method = method
) %>%
## remove all but last entry if dates are multiple
group_by(forecast_date) %>%
slice(n()) %>%
ungroup() %>%
vroom_write(
here(
"code", "ensemble", "EuroCOVIDhub",
"method-by-date.csv"
),
delim = ","
)
} else {
warning("No ensemble was created.")
}
27 changes: 27 additions & 0 deletions code/validation/check_truth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11043,3 +11043,30 @@ Error(s) in '/home/runner/work/covid19-forecast-hub-europe/covid19-forecast-hub-

- The following locations are missing: ['Czechia'].

Latest check of truth data: 2024-05-22

WARNING
Error(s) in '/home/runner/work/covid19-forecast-hub-europe/covid19-forecast-hub-europe/data-truth/ECDC/truncated_ECDC-Incident Deaths.csv' at 2024-05-11:

- The following locations are missing: ['Austria', 'Belgium', 'Croatia', 'Cyprus', 'Czechia', 'Denmark', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Iceland', 'Ireland', 'Italy', 'Liechtenstein', 'Luxembourg', 'Malta', 'Netherlands', 'Norway', 'Poland', 'Slovakia', 'Slovenia', 'Sweden'].

WARNING
Error(s) in '/home/runner/work/covid19-forecast-hub-europe/covid19-forecast-hub-europe/data-truth/ECDC/truth_ECDC-Incident Cases.csv' at 2024-05-11:

- The following locations are missing: ['Cyprus', 'Denmark', 'Finland', 'France', 'Germany', 'Malta', 'Slovenia'].

WARNING
Error(s) in '/home/runner/work/covid19-forecast-hub-europe/covid19-forecast-hub-europe/data-truth/ECDC/truth_ECDC-Incident Deaths.csv' at 2024-05-11:

- The following locations are missing: ['Austria', 'Belgium', 'Cyprus', 'Denmark', 'Finland', 'France', 'Germany', 'Hungary', 'Iceland', 'Luxembourg', 'Netherlands', 'Norway', 'Poland', 'Slovenia'].

WARNING
Error(s) in '/home/runner/work/covid19-forecast-hub-europe/covid19-forecast-hub-europe/data-truth/ECDC/truncated_ECDC-Incident Cases.csv' at 2024-05-11:

- The following locations are missing: ['Belgium', 'Croatia', 'Cyprus', 'Denmark', 'Finland', 'France', 'Germany', 'Italy', 'Malta', 'Netherlands', 'Norway', 'Slovakia', 'Slovenia'].

WARNING
Error(s) in '/home/runner/work/covid19-forecast-hub-europe/covid19-forecast-hub-europe/data-truth/OWID/truncated_OWID-Incident Hospitalizations.csv' at 2024-05-18:

- The following locations are missing: ['Czechia'].

Loading

0 comments on commit b8d3a1c

Please sign in to comment.