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

Connect scoringutils To forecasttools #21

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
57 changes: 57 additions & 0 deletions forecasttools/to_scoringutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
Takes differently formatted forecast objects
and converts them into a format ready for R's
`scoringutils`. A FluSight submission has all
necessary content already present save for
the observation (both for the fitting and
forecast period). An InferenceData object can
have the observations available
"""

import arviz as az
import polars as pl


def from_flusight_to_scoringutils(
submission: pl.DataFrame, observations: list[float]
) -> None:
""" """

pass


def from_idata_to_scoringutils(
save_path: str,
idata: az.InferenceData,
observations: list[float],
idata_samp_param: str,
idata_obs_param: str,
overwrite: str = False,
) -> None:
"""
Take a InferenceData object generated
from NumPyro posterior and posterior
predictive samples along with observations
and generate a parquet file with the
correct columns for use in `scoringutils`.

Parameters
----------
save_path
The save path for the generated
parquet file.
idata
An InferenceData object containing
a forecast made using NumPyro.
observations
An array of observations corresponding
to the
overwrite
Whether to overwrite an existing file
of the same name.

Returns
-------
None
A parquet file.
"""
6 changes: 6 additions & 0 deletions notebooks/notebook-references.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@article{bosse2022evaluating,
title={Evaluating Forecasts with scoringutils in R},
author={Bosse, Nikos I and Gruson, Hugo and Cori, Anne and van Leeuwen, Edwin and Funk, Sebastian and Abbott, Sam},
journal={arXiv preprint arXiv:2205.07090},
year={2022}
}
Loading
Loading