pymc-devs / pymc

Bayesian Modeling and Probabilistic Programming in Python
https://docs.pymc.io/
Other
8.49k stars 1.97k forks source link

Add var_names argument to sample #7206

Closed fonnesbeck closed 3 months ago

fonnesbeck commented 3 months ago

Description

Allow for filtering of variables included in sampled trace via an optional var_names argument, similar to what is done for plotting.

Related Issue

Checklist

Type of change


📚 Documentation preview 📚: https://pymc--7206.org.readthedocs.build/en/7206/

fonnesbeck commented 3 months ago

Just getting started here. Testing to see if this is the right approach.

ricardoV94 commented 3 months ago

Apologies, I didn't see it was in draft :)

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 50.00000% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 90.29%. Comparing base (aa679f3) to head (13a5d31). Report is 14 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pymc-devs/pymc/pull/7206/graphs/tree.svg?width=650&height=150&src=pr&token=JFuXtOJ4Cb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs)](https://app.codecov.io/gh/pymc-devs/pymc/pull/7206?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs) ```diff @@ Coverage Diff @@ ## main #7206 +/- ## ========================================== - Coverage 92.29% 90.29% -2.01% ========================================== Files 100 100 Lines 16875 16896 +21 ========================================== - Hits 15575 15256 -319 - Misses 1300 1640 +340 ``` | [Files](https://app.codecov.io/gh/pymc-devs/pymc/pull/7206?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs) | Coverage Δ | | |---|---|---| | [pymc/backends/\_\_init\_\_.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7206?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9iYWNrZW5kcy9fX2luaXRfXy5weQ==) | `92.10% <100.00%> (+0.21%)` | :arrow_up: | | [pymc/sampling/mcmc.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7206?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9zYW1wbGluZy9tY21jLnB5) | `85.96% <66.66%> (-2.04%)` | :arrow_down: | | [pymc/sampling/jax.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7206?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9zYW1wbGluZy9qYXgucHk=) | `0.00% <0.00%> (-94.10%)` | :arrow_down: | ... and [6 files with indirect coverage changes](https://app.codecov.io/gh/pymc-devs/pymc/pull/7206/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs)
fonnesbeck commented 3 months ago

No worries, feedback welcome at all stages! (earlier the better, in fact)

fonnesbeck commented 3 months ago

Should probably enforce that all stochastic variables be included.

ricardoV94 commented 3 months ago

Should probably enforce that all stochastic variables be included.

Maybe it's fine not to?

fonnesbeck commented 3 months ago

The numpyro sampler does not appear to do the right thing with the passed var names.

ricardoV94 commented 3 months ago

The numpyro sampler does not appear to do the right thing with the passed var names.

What does it do? Checking the source code, it looks like it should if you pass just the strings?

fonnesbeck commented 3 months ago

Seems like at some point the names don't get converted vars.

fonnesbeck commented 3 months ago

(ok, fixed)

fonnesbeck commented 3 months ago

Not sure how code coverage drops when I've added two tests.

ricardoV94 commented 3 months ago

Not sure how code coverage drops when I've added two tests.

Cov is flaky, not always up to date or comparing with the right commit

ricardoV94 commented 3 months ago

Thanks @fonnesbeck !