Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predicted/actual epiweekly plots #222

Merged
merged 124 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
9e9c427
Depend on public azuretools
dylanhmorris Dec 9, 2024
c31e36a
Tweak make_forecast_figure docs
dylanhmorris Dec 10, 2024
60e3c17
Modularize process_state_forecast, add basic test for training/test c…
dylanhmorris Dec 10, 2024
d8844c5
Add more helper functions to process_state_forecast.R
dylanhmorris Dec 10, 2024
54096d6
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 10, 2024
6695e2e
Add checkmate to suggests
dylanhmorris Dec 10, 2024
e1ff3d7
Add helper function for combining observed and forecast to create syn…
dylanhmorris Dec 10, 2024
579dd6f
Fix old variable names
dylanhmorris Dec 10, 2024
a8c2629
Fix docs typos
dylanhmorris Dec 11, 2024
19dbfd3
Fix bug
dylanhmorris Dec 11, 2024
c0136a9
Add basic test for to_tidy_draws_timeseries
dylanhmorris Dec 11, 2024
8b93cce
Switch back to using combined_dat, with comment for clarity
dylanhmorris Dec 11, 2024
8b6bd47
Merge main
dylanhmorris Dec 11, 2024
67eca2e
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 11, 2024
7b2c05e
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 12, 2024
fdfcb4a
Separate scoreable table prep from scoring
dylanhmorris Dec 12, 2024
8aaf7c9
Expose to_scoreable_table, rename source file
dylanhmorris Dec 12, 2024
2e18c7e
First pass predicted actual plots
dylanhmorris Dec 12, 2024
8bd6903
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 12, 2024
8c9517b
Fixup hewr docs
dylanhmorris Dec 12, 2024
64643d9
Rename functions in score_hubverse and lint
dylanhmorris Dec 12, 2024
ed80a86
Depend on quantile_table_to_scoreable from forecasttools
dylanhmorris Dec 13, 2024
c9c45aa
Fix docs
dylanhmorris Dec 13, 2024
1db06a6
Remove windows files
dylanhmorris Dec 13, 2024
844c2ad
Use forecasttools in score_hubverse, add explicit include functionali…
dylanhmorris Dec 16, 2024
387109b
Make n training and exclude last n command line configuraturable in s…
dylanhmorris Dec 16, 2024
82460d4
Fix missing varnames in format call
dylanhmorris Dec 16, 2024
5db8bca
Create score_location.py
dylanhmorris Dec 19, 2024
c49461c
Remove extra code from score_location
dylanhmorris Dec 19, 2024
dbcddc4
Add eval_data_path to cli
dylanhmorris Dec 19, 2024
2dae8c1
Fix import of strptime
dylanhmorris Dec 19, 2024
d1d6f44
Merge main
dylanhmorris Dec 19, 2024
d548bdc
Fix imports in utils
dylanhmorris Dec 19, 2024
45176e4
Add regeneration of latest_comprehensive to pipeline as backup to aut…
dylanhmorris Dec 19, 2024
ba69a7e
Remove print debug
dylanhmorris Dec 19, 2024
1e3f25e
Create setup_score_job.py
dylanhmorris Dec 19, 2024
40d6f8c
Fix fstring typo
dylanhmorris Dec 19, 2024
715b0d1
Within container path to model_batch_dir
dylanhmorris Dec 19, 2024
edda29f
Within container path to model_batch_dir tweak
dylanhmorris Dec 19, 2024
6699dee
Add collate_real_time_scores.R
dylanhmorris Dec 19, 2024
cea20fe
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 19, 2024
e43d821
Create maintenance folder, add to_archival_format helper
dylanhmorris Dec 20, 2024
65ec58c
Scoring and archiving improvements
dylanhmorris Dec 21, 2024
08a5c44
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 21, 2024
89fe86a
Add basic wis component plot
dylanhmorris Dec 23, 2024
7d37056
add batch dir level transformation
dylanhmorris Dec 23, 2024
d74e3ab
Add CLI for to_archival_format
dylanhmorris Dec 23, 2024
0076b4f
Working archival helper, better plot collation
dylanhmorris Dec 26, 2024
8c4c67e
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 26, 2024
e3a36a7
pointeintervals instead of ribbons by horizon
dylanhmorris Dec 26, 2024
798e86c
load ggdist
dylanhmorris Dec 26, 2024
8fbdee2
Styling
dylanhmorris Dec 26, 2024
beb6c58
More styling
dylanhmorris Dec 26, 2024
a09798b
Real time eval plot tweaks
dylanhmorris Dec 26, 2024
bd86d59
Update module names in score_location.py
dylanhmorris Dec 27, 2024
f148732
Add init.py
dylanhmorris Dec 27, 2024
dc0cd2f
Use poetry
dylanhmorris Dec 27, 2024
451a41a
Revert batch setup
dylanhmorris Dec 27, 2024
ca74c3b
Fix namespacing
dylanhmorris Dec 27, 2024
50dfeab
Add blank line
dylanhmorris Dec 27, 2024
a28be56
Fix bug in collate_real_time_scores with NA save dir
dylanhmorris Dec 28, 2024
af7053f
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 28, 2024
726e98c
Do not try to compute baseline if it's absent, better collation
dylanhmorris Dec 30, 2024
d72ec7c
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 30, 2024
e893b13
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Dec 30, 2024
b3e1469
update reference to forecasttools function
dylanhmorris Dec 31, 2024
f9e7186
Standardize on scorable
dylanhmorris Dec 31, 2024
5cd66b1
Run pre-commit
dylanhmorris Dec 31, 2024
d99b813
Update tests
dylanhmorris Dec 31, 2024
52c93e4
merge main
dylanhmorris Jan 4, 2025
08d898b
Harmonize hubverse score tests with move of scoring functionality to …
dylanhmorris Jan 4, 2025
313f8b3
Run roxygen
dylanhmorris Jan 4, 2025
bb0db01
Clean up score_location.py and add docstrings
dylanhmorris Jan 4, 2025
7d3310c
Update score_location.py invocation in batch/setup_score_job.py
dylanhmorris Jan 4, 2025
c555293
use forecasttools plot_pred_obs_by_forecast_date in hubverse_score.R
dylanhmorris Jan 6, 2025
eb84f7b
Depend on later forecasttools
dylanhmorris Jan 6, 2025
e9567f0
pred-actual plots by forecast date
dylanhmorris Jan 6, 2025
56f3655
Organize by disease, then by location
dylanhmorris Jan 6, 2025
1884f9f
Tweak horizon handling in hubverse_score
dylanhmorris Jan 11, 2025
2a5a569
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Jan 11, 2025
94996f2
Update score_location call to save_eval_data
dylanhmorris Jan 17, 2025
9245873
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Jan 17, 2025
b7983a1
make generate epiweekly conditional
dylanhmorris Jan 17, 2025
4f93f54
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Jan 21, 2025
1bedb9b
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Jan 23, 2025
0b257c9
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Jan 24, 2025
53bcede
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Jan 29, 2025
d7c5b18
Remove unneeded column
dylanhmorris Feb 5, 2025
9be65fb
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Feb 5, 2025
356e78c
Merge main
dylanhmorris Feb 10, 2025
840ad2c
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Feb 10, 2025
d72f176
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Feb 11, 2025
63bedf3
Narrow scope of PR
dylanhmorris Feb 11, 2025
8c2943f
Further narrow scope
dylanhmorris Feb 11, 2025
69b87d6
Remove unneeded addition
dylanhmorris Feb 11, 2025
b14dbbf
Prune collate_score_tables
dylanhmorris Feb 11, 2025
a949b30
Merge branch 'main' into dhm-predicted-actual
damonbayer Feb 12, 2025
4770d36
Merge branch 'main' into dhm-predicted-actual
dylanhmorris Feb 13, 2025
014651e
Remove save_scores
dylanhmorris Feb 13, 2025
b0631e9
Move def of y in aesthetic mapping
dylanhmorris Feb 13, 2025
0984d2c
DRY horizon filtering
dylanhmorris Feb 13, 2025
ade726f
Better disease parsing
dylanhmorris Feb 13, 2025
f7d8875
Fix function call
dylanhmorris Feb 13, 2025
dea9b2d
pmap -> map
dylanhmorris Feb 13, 2025
095ec8a
Use group_map
dylanhmorris Feb 13, 2025
e635171
Fix missing pipe
dylanhmorris Feb 13, 2025
8c00d62
index column
dylanhmorris Feb 13, 2025
50a7edf
Fix unnaming
dylanhmorris Feb 13, 2025
0a84444
Tweak
dylanhmorris Feb 13, 2025
b5733d9
Another tweak
dylanhmorris Feb 13, 2025
9505812
Correct output handling
dylanhmorris Feb 13, 2025
70030f3
Correct observe column name
dylanhmorris Feb 13, 2025
7517a35
group_map -> group_modify
dylanhmorris Feb 13, 2025
1fb3067
Suppress messages in reading
dylanhmorris Feb 13, 2025
834724d
Typo
dylanhmorris Feb 13, 2025
40cdd4c
tidyverse style in plot_pred_act_by_horizon
dylanhmorris Feb 13, 2025
7198350
Print debug
dylanhmorris Feb 13, 2025
c7dbe8e
Working refactored scoring
dylanhmorris Feb 13, 2025
4b5ccae
Omit default
dylanhmorris Feb 13, 2025
679e77e
Scale call before label call
dylanhmorris Feb 13, 2025
ece90dc
positive column selection
dylanhmorris Feb 13, 2025
e4c0635
Fix unwanted revert
dylanhmorris Feb 13, 2025
128696a
Fix additional unwanted revert
dylanhmorris Feb 13, 2025
f1b03df
Fix fn name
dylanhmorris Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hewr/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Imports:
fable,
feasts,
forcats,
forecasttools (>= 0.0.0.9000),
forecasttools (>= 0.1.1),
fs,
ggdist,
ggnewscale,
Expand Down
2 changes: 1 addition & 1 deletion hewr/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export(parse_pyrenew_model_name)
export(parse_variable_name)
export(process_state_forecast)
export(read_and_combine_data)
export(score_hubverse)
export(score_hewr)
export(to_epiweekly_quantile_table)
importFrom(rlang,":=")
importFrom(rlang,.data)
104 changes: 0 additions & 104 deletions hewr/R/score_hubverse.R

This file was deleted.

53 changes: 53 additions & 0 deletions hewr/R/scoring.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#' Default scoring function for `pyrenew-hew`.
#'
#' Simple wrapper of [scoringutils::transform_forecasts()]
#' and [scoringutils::score()] with reasonable defaults for
#' `pyrenew-hew` production.
#'
#' @param scorable_table Table to score, as the output
#' of [forecasttools::quantile_table_to_scorable()].
#' @param transform transformation passed as the
#' `fun` argument to [scoringutils::transform_forecasts()].
#' Default [scoringutils::log_shift()].
#' @param offset Offset for the transformation, passed to
#' [scoringutils::transform_forecasts()]. Default 1.
#' @param append_transformed When calling
#' [scoringutils::transform_forecasts()], append
#' the transformed scale forecasts to the base scale forecasts
#' or keep only the transformed scale forecasts? Passed as the
#' `append` argument to [scoringutils::transform_forecasts()].
#' Boolean, default `FALSE` (keep only transformed scale).
#' @param ... Other keyword arguments passed to
#' [scoringutils::transform_forecasts()].
#' @return A table of scores, as the output of
#' [scoringutils::score()], filtered to include only the
#' transformed_scale.
#' @export
score_hewr <- function(scorable_table,
transform = scoringutils::log_shift,
append_transformed = FALSE,
offset = 1,
...) {
to_score <- scorable_table |>
scoringutils::transform_forecasts(
fun = transform,
append = append_transformed,
offset = offset,
...
)

interval_coverage_95 <- purrr::partial(
scoringutils::interval_coverage,
interval_range = 95
)

scored <- to_score |>
scoringutils::score(
metrics = c(
scoringutils::get_metrics(to_score),
interval_coverage_95 = interval_coverage_95
)
)

return(scored)
}
45 changes: 45 additions & 0 deletions hewr/man/score_hewr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 0 additions & 78 deletions hewr/man/score_hubverse.Rd

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ testthat::test_that("score_hubverse works as expected with valid inputs", {
length(date_range) * length(locations)
)

scored <- score_hubverse(forecast, observed)
expect_setequal(forecast$location, scored$location)
expect_setequal(scored$horizon, c(0, 1))
scored <- forecasttools::quantile_table_to_scorable(
forecast,
observed,
obs_date_column = "reference_date"
) |>
score_hewr()

scored_all_horizon <- score_hubverse(
forecast, observed,
horizons = c(0, 1, 2)
)
expect_setequal(forecast$location, scored_all_horizon$location)
expect_setequal(forecast$horizon, scored_all_horizon$horizon)
expect_setequal(forecast$location, scored$location)
expect_setequal(forecast$horizon, scored$horizon)
})


Expand All @@ -68,13 +67,18 @@ testthat::test_that("score_hubverse handles missing location data", {
locations = c("loc1")
)

result <- score_hubverse(forecast, observed)
result <- forecasttools::quantile_table_to_scorable(
forecast,
observed,
obs_date_column = "reference_date"
) |>
score_hewr()
expect_false("loc2" %in% result$location)
expect_setequal(observed$location, result$location)
})


testthat::test_that("score_hubverse handles zero length forecast table", {
testthat::test_that("score_hewr handles zero length forecast table", {
forecast <- tibble::tibble(
reference_date = as.Date(character(0)),
horizon = integer(0),
Expand All @@ -95,7 +99,15 @@ testthat::test_that("score_hubverse handles zero length forecast table", {
)

expect_error(
result <- score_hubverse(forecast, observed),
"Assertion on 'data' failed: Must have at least 1 rows, but has 0 rows."
forecasttools::quantile_table_to_scorable(
forecast,
observed,
obs_date_column = "reference_date"
) |>
score_hewr(),
paste0(
"Assertion on 'data' failed: ",
"Must have at least 1 rows, but has 0 rows."
)
)
})
Loading
Loading