Skip to content

Support alternate point estimate functions#65

Merged
huddlej merged 12 commits intomainfrom
support-alternate-point-estimate-functions
Feb 9, 2026
Merged

Support alternate point estimate functions#65
huddlej merged 12 commits intomainfrom
support-alternate-point-estimate-functions

Conversation

@huddlej
Copy link
Collaborator

@huddlej huddlej commented Feb 6, 2026

Adds logic to calculate the mean of posterior distributions along with the existing calculations of median and user-specified percentiles (ps) and exposes a new user configuration option (ps_point_estimator) to allow users to specify which point estimator function should be used by tools that consume the model JSONs. This option passes through to the model JSON's metadata section allowing downstream tools to choose the data entries that match the requested point estimator function.

The following is an example of the new configuration one can provide to the evofr run-model command:

export:
  export_path: "test/output/results"
  sites: ["freq", "ga"]
  dated: [True, False]
  forecasts: [False, False]
  ps_point_estimator: "mean"

These changes are backward compatible, but they will produce a slightly larger JSON file by adding entries for mean frequencies and GAs to all outputs. Tools that consume the model JSONs like evofr-viz will need their own updates to support the new ps_point_estimator metadata key.

Required for nextstrain/forecasts-flu#32

Updates the CLI test for run-model to check the contents of the
resulting model JSON for a key describing the point estimator function
to use for summarizing the central point of the posterior distributions.
The default estimator is the median.
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 23.52941% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.35%. Comparing base (c44c3d7) to head (7a203bc).

Files with missing lines Patch % Lines
evofr/posterior/posterior_helpers.py 23.52% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
+ Coverage   27.13%   27.35%   +0.21%     
==========================================
  Files          57       57              
  Lines        3213     3228      +15     
==========================================
+ Hits          872      883      +11     
- Misses       2341     2345       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Adds support for scalar values in the metadata dictionaries passed to
the `combine_sites_tidy` function and adds a test for this support. This
function is not used internally by evofr, but it is used externally by
forecasts-flu and forecasts-ncov. Without this change, the new
"ps_point_estimator" key gets converted from a string like "mean" to a
list of single characters like `['m', 'e', 'a', 'n']`.
huddlej added a commit to nextstrain/forecasts-flu that referenced this pull request Feb 6, 2026
Adds logic to parse a `ps_point_estimator` function name from the model
config YAML and pass that estimator name to the evofr function for
generating tidy data frames. This interface allows users to choose one
of the available point estimates generated by evofr as the
representative value to plot in evofr-viz and other downstream tools.

Updates the configs for all three subtypes to use the "mean" instead of
the "median" for reporting frequencies and GAs. Updates the local JSON
parsing script to export mean along with median in the data frame
output.

Closes #32
Requires blab/evofr#65
Requires nextstrain/forecasts-viz#33
huddlej added a commit to nextstrain/forecasts-flu that referenced this pull request Feb 6, 2026
Adds logic to parse a `ps_point_estimator` function name from the model
config YAML and pass that estimator name to the evofr function for
generating tidy data frames. This interface allows users to choose one
of the available point estimates generated by evofr as the
representative value to plot in evofr-viz and other downstream tools.

Updates the configs for all three subtypes to use the "mean" instead of
the "median" for reporting frequencies and GAs. Updates the local JSON
parsing script to export mean along with median in the data frame
output.

Closes #32
Requires blab/evofr#65
Requires nextstrain/forecasts-viz#33
@huddlej huddlej merged commit 9594b11 into main Feb 9, 2026
@huddlej huddlej deleted the support-alternate-point-estimate-functions branch February 9, 2026 19:22
@huddlej huddlej linked an issue Feb 9, 2026 that may be closed by this pull request
@huddlej huddlej mentioned this pull request Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add changelog to repo

1 participant