-
-
Notifications
You must be signed in to change notification settings - Fork 69
Forward model argument to add_fit_to_inference_data in find_MAP #543
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
Forward model argument to add_fit_to_inference_data in find_MAP #543
Conversation
Does this superseed: #538 ? |
How comes PyPI CI is failing with import? |
Yes. I didn't check if anything else was open before I did this. Sorry @OriolAbril
I think this will be fixed by #541 ? |
Can we also add the correct pin for pytensor? The map and laplace functionality needs newer pytensor than what is currently allowed. Don't worry about my PR |
It's actually not map and laplace needing the new pytensor, it's the INLA function. I think we could move that specific import inside this function? It shouldn't effect 99% of users. |
@jessegrabowski this is the dependency problem I encountered before conda create --name test-pymc-extras python=3.12
conda activate test-pymc-extras
conda install -c conda-forge pymc-extras
python import pymc_extras
pymc.__version__, pytensor.__version__
# ('5.23.0', '2.31.3') and the pymc_extras I got installed was 0.3.1 If I do conda install -c conda-forge "pytensor=2.31.7"
python import pymc_extras
pymc_extras.__version__
# '0.3.1' I think the correct pin for pytensor is |
Thanks Tomi. I updated the pins. I didn't add an upper pin -- I don't really like them, and @maresb said he doesn't either, so that's confirmation bias :D |
e7b3e31
to
1d75f75
Compare
I moved the version pin and dependency stuff to #542 , they didn't seem appropriate in this PR |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #543 +/- ##
===========================================
+ Coverage 51.83% 64.15% +12.32%
===========================================
Files 55 65 +10
Lines 6048 6487 +439
===========================================
+ Hits 3135 4162 +1027
+ Misses 2913 2325 -588
🚀 New features to boost your workflow:
|
Makes sense! |
1d75f75
to
2ebff6f
Compare
assert hasattr(idata, "posterior") | ||
assert hasattr(idata, "fit") | ||
assert hasattr(idata, "optimizer_result") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it relevant / worth checking the presence of any data group? I see above a call like the following within find_MAP
idata = add_data_to_inference_data(
idata=idata, progressbar=False, model=model, compile_kwargs=compile_kwargs
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crap yes it is, but I just clicked merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, well another thing I just saw:
Is it necessary to compute deterministics within add_data_to_inference_data
? See
pymc-extras/pymc_extras/inference/laplace_approx/idata.py
Lines 211 to 224 in fd2933f
if model.deterministics: | |
expand_dims = {} | |
if "chain" not in idata.posterior.coords: | |
expand_dims["chain"] = [0] | |
if "draw" not in idata.posterior.coords: | |
expand_dims["draw"] = [0] | |
idata.posterior = pm.compute_deterministics( | |
idata.posterior.expand_dims(expand_dims), | |
model=model, | |
merge_dataset=True, | |
progressbar=progressbar, | |
compile_kwargs=compile_kwargs, | |
) |
I guess that function is not exposed to the user, but I just wanted to raise that potentially silent side effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not necessary, but that's what pm.sample does right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see now why it's included
Bugfix for find_MAP. The following code currently errors:
Because the model argument is not correctly forwarded everywhere it is needed inside find_MAP. This patches the bug and adds a regression test.