CDCgov / multisignal-epi-inference

Python package for statistical inference and forecast of epi models using multiple signals
https://cdcgov.github.io/multisignal-epi-inference/
9 stars 1 forks source link

201 add visualizations using arviz to tutorials #211

Closed sbidari closed 4 days ago

sbidari commented 6 days ago

Added arviz plots to two tutorials

codecov[bot] commented 6 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.47%. Comparing base (99cdf42) to head (101553c).

:exclamation: Current head 101553c differs from pull request most recent head 7bf74c7

Please upload reports for the commit 7bf74c7 to get more accurate results.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #211 +/- ## ======================================= Coverage 92.47% 92.47% ======================================= Files 40 40 Lines 877 877 ======================================= Hits 811 811 Misses 66 66 ``` | [Flag](https://app.codecov.io/gh/CDCgov/multisignal-epi-inference/pull/211/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CDCgov) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/CDCgov/multisignal-epi-inference/pull/211/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CDCgov) | `92.47% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CDCgov#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

dylanhmorris commented 6 days ago

Thanks, @sbidari!

One quick fix to start. The website build in CI is failing:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[8], line 1
----> 1 import arviz as az
      2 idata = az.from_numpyro(model1.mcmc)
      3 az.plot_trace(idata.posterior["Rt"],compact=True);

ModuleNotFoundError: No module named 'arviz'

Adding arviz as a dependency to docs/pyproject.toml should resolve this. Can do that at the command line from the top level project directory with:

poetry add -C docs arviz

https://github.com/CDCgov/multisignal-epi-inference/blob/99cdf4272358d80966ce92007d896245d53d59e2/docs/pyproject.toml#L9-L19

dylanhmorris commented 6 days ago

My mistake; I should've looked more closely at the source yaml for website / render-docs. The rendering of the tutorials uses the dependencies in model/pyproject.toml not those in docs/pyproject.toml. I think we should add arviz as a dev dependency for model in the first instance:

poetry add -C model --group dev arviz

Can remove it from the docs dependencies for now

poetry remove -C docs arviz
sbidari commented 6 days ago
poetry add -C model --group dev arviz

This command is not changing any dependencies in the model

Capture

dylanhmorris commented 6 days ago

what's the output of git diff model/pyproject.toml?

sbidari commented 5 days ago

My bad, the command did work as expected.

sbidari commented 5 days ago

Can we try to make something with plot_hdi? Or at a minimum swap the x and y axes in these plots so they are more readable as a time series?

Yep! Working on it

sbidari commented 5 days ago

I created hdi plots that are more readable to replace the forest plots. Let me know what you think and if there are any other type of plots you'd like to be added @damonbayer

gvegayon commented 4 days ago

This is looking great, @sbidari! Quarto and rst format are picky. I noticed sometimes figures wouldn't render or be added to the website if some conditions were unmet:

image

You have to:

  1. Explicitly plot the figure using plot.show().
  2. Have the code-chunk label with no empty spaces and starting with the fig prefix.
  3. Have a caption.

In your case, the code chunk labelled fig2-trace-Rt should be renamed to something like fig-trace-Rt2 (point 2). I believe that should fix it. For more details, see this PR.

cc @damonbayer @dylanhmorris @AFg6K7h4fhy2

sbidari commented 4 days ago

Thanks for catching this @gvegayon

sbidari commented 4 days ago

ready for review @damonbayer