Implement MultiDimensionalMMM with pymc.dims#2204
Implement MultiDimensionalMMM with pymc.dims#2204ricardoV94 wants to merge 6 commits intopymc-labs:mainfrom
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
| name="channel_contribution", | ||
| var=baseline_channel_contribution * media_broadcast, | ||
| dims=("date", *self.dims, "channel"), | ||
| channel_contribution = pmd.Deterministic( |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2204 +/- ##
==========================================
- Coverage 93.15% 93.11% -0.05%
==========================================
Files 79 80 +1
Lines 12646 12708 +62
==========================================
+ Hits 11781 11833 +52
- Misses 865 875 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cetagostini
left a comment
There was a problem hiding this comment.
Hey! I found a few typos while reviewing the pymc.dims implementation. See inline comments below 👇
cetagostini
left a comment
There was a problem hiding this comment.
A few more inconsistencies I noticed - some return type annotations say TensorVariable but the code actually returns XTensorVariable 🤔
Function Equivalence Testing Results 🧪I tested the transformation functions to verify they produce equivalent outputs with the new ✅ All Functions Pass Numerical Equivalence
|
|
Yes order doesn't matter while in xtensor land. You can always transpose explicitly to another order, which you should do if you need to go to tensor land (via .values). Note even if not so relevant, dimension order matches the same as xarray |
2a75405 to
c2193c6
Compare
aa79d7b to
c9a5a89
Compare
| budgets_expanded * self._budget_distribution_over_period_tensor | ||
| ) # Shape: (num_periods, num_optimized_budgets) | ||
| budgets_optimized * self._budget_distribution_over_period_tensor | ||
| ).transpose("date", "budgets_flat") |
d8bfaaa to
872eeec
Compare
It's failing with numba mode, probably that's why you can't repro |
Is there a fundamental problem? We acn also add it into the BLACKLIST in the runner script and create an issue |
|
@juanitorduz it's fixed by pymc-devs/pytensor#1937 Hopefully by the time I cut a release @isofer hasn't finished 20 more PRs and this is still up to date :D |
My goal is to finish 30 PRs in 30 days and for each PR to touch whole the files in the repo :D |
|
Question. Many notebooks use
Do we consider this was mostly for devs, and it's fine to break, or do we want to try and infer dims positionally like The logic would have to be something like: if there are no dims in When core_dim is needed, it would default to the leading dim of I thought it was useful to do it for Prior objects because those are clearly user-facing when they customize models. But transforms feel more internal? Note, this behavior is compatible with the old use (same result), but can be wrong in uses that are now supported (like x broadcasting with arbitrary dimensions of the parameters, that itself does not contain) Somewhat related, these transforms used to accept a Can someone confirm it shouldn't be needed anymore? |
|
Thabnks @ricardoV94 ! From what I have seen, Regarding the "transforms used to accept a dims argument", I would let @williambdean give his input, as I have not used this that much. |
|
The notebooks are already updated |
|
Then even better 😄. |
|
Ci is passing. I didn't add the deprecation of Can add in this PR or a quick follow up. What do you think? |
|
For review, the notebook changes are separate, so you don't have to worry about "19k LOC". Each commit is logically consistent, so it can also be merged with rebase to avoid the same issue of putting those nb changes together |
juanitorduz
left a comment
There was a problem hiding this comment.
@ricardoV94 This looks great! I left some minor comments.
All in all, I think we should merge this one soon!
|
TODO:
Closes #1981
Closes #1514
Closes #1630 (just a regression test, it worked fine before)
related to #2017
📚 Documentation preview 📚: https://pymc-marketing--2204.org.readthedocs.build/en/2204/