-
Notifications
You must be signed in to change notification settings - Fork 318
Handle new data correctly and extend functionality of MMM posterior predictive methods #482
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
Handle new data correctly and extend functionality of MMM posterior predictive methods #482
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #482 +/- ##
==========================================
+ Coverage 90.83% 91.12% +0.29%
==========================================
Files 21 21
Lines 1974 2018 +44
==========================================
+ Hits 1793 1839 +46
+ Misses 181 179 -2 ☔ View full report in Codecov by Sentry. |
with self.model: # sample with new input data | ||
post_pred = pm.sample_posterior_predictive(self.idata, **kwargs) | ||
if extend_idata: | ||
self.idata.extend(post_pred) # type: ignore |
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.
You need to define join
otherwise calling this method twice will ignore the second run
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.
This applies to prior and fit as well, but maybe it's a good time as any to fix it as it's a pretty serious one.
I had a PR on this but haven't come back to it
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.
Sounds good. This is in the method override. Shall I add to the model_builder method as well?
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.
Yup. Feel free to reuse as much as you can from the PR of the pymc-experimental ModelBuilder (thinking about tests as well). Just add the author as a co-author or mention in the commit if you do that.
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.
Sounds good. I will dive into it more later
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.
I've just added a check that the idata will be the first sample from two method calls to keep it simple. Hope that's what you expected
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.
I think fit is still overriding whatever was there before. Example sample_prior_predictive -> fit removes sample_prior_predictive (if I read the code correctly)
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.
Doesn't need to be done in this PR, just mentioning here for the related issue #459
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.
This looks super nice! Thanks! I just added some comments about the docs and other minor things.
@wd60622 After we merge this one, we need to add (or create) an example to the docs (let's create an issue). This one will be a game-changer feature 🚀 |
Thank you guys for the review! I will have some time tomorrow to make some changes |
I've made edits based on all the comments @juanitorduz and @ricardoV94 |
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.
This is amazing @wd60622 ! From my side, I just wanna push this out and get feedback. My sleep deprivation (👶 ) might make me miss some details so if @ricardoV94 is happy I suggest we merge and release 0.4 🚀
Hi @ricardoV94. Thanks for the feedback. I just went through all of it and made some changes. For the xarray tests, I changed to used check for the second sampling result and am using xr.testing module now for more robust checks. |
LGTM 🚀 ! Let's wait for @ricardoV94 's feedback :) |
@wd60622 everything looks kosher, but there is still this open discussion: #482 (comment) Given how all sampling/fitting methods require x/y anyway I changed my mind and I don't think the |
Perfect. I've changed that back so that the data will not be reset |
Are we ready to merge? 🤞 |
Had the affected tests passing locally. They seem to be waiting to start on GitHub 😢 |
It's green! 💚. I think we just need @ricardoV94 's last approval :) |
Merged, any notebooks that need updating? |
I ran the notebook in my first review and it worked perfectly. I can check tomorrow (@wd60622 do we need an update?). |
Firstly, thank you both for the reviews!
I haven't touched the notebooks. I would like to add an example in docstring / notebook with #494 |
Description
Redo of the support for new mmm data
This brings in the feedback about
include_last_observations
for all predict methods withX_pred
original_scale
keyword that can be passed to all predict methodsRelated Issue
Checklist
Modules affected
Type of change
📚 Documentation preview 📚: https://pymc-marketing--482.org.readthedocs.build/en/482/