Skip to content

MMM Multi-Dimensional Example #1521

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

Merged
merged 26 commits into from
Mar 22, 2025
Merged

MMM Multi-Dimensional Example #1521

merged 26 commits into from
Mar 22, 2025

Conversation

juanitorduz
Copy link
Collaborator

@juanitorduz juanitorduz commented Feb 25, 2025

Intro notebook to the new (experimental) MMM class.


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

@juanitorduz juanitorduz self-assigned this Feb 25, 2025
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@juanitorduz juanitorduz added the docs Improvements or additions to documentation label Feb 25, 2025
@github-actions github-actions bot added the MMM label Feb 25, 2025
@juanitorduz juanitorduz marked this pull request as draft February 25, 2025 20:03
Copy link

review-notebook-app bot commented Feb 27, 2025

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2025-02-27T19:04:57Z
----------------------------------------------------------------

This plot looks very weird


Copy link

review-notebook-app bot commented Feb 27, 2025

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2025-02-27T19:04:57Z
----------------------------------------------------------------

The posterior predictive distribution is very off the true values, it seems its totally missing the channel contributions.


wd60622 commented on 2025-02-28T11:36:20Z
----------------------------------------------------------------

The model seems to scale by the max value across all of the targets.

self.scalers = self.xarray_dataset.max(dim=["date", *self.dims])

Copy link

review-notebook-app bot commented Feb 28, 2025

View / edit / reply to this conversation on ReviewNB

wd60622 commented on 2025-02-28T11:16:46Z
----------------------------------------------------------------

Line #5.        "likelihood": Prior("Normal", sigma=Prior("HalfNormal", sigma=6)),

The intercept is by geo. Should the sigma be by geo as well

`Prior("Normal", sigma=Prior("HalfNormal", sigma=6, dims="geo"), dims=("date", "geo"))

Also, sigma=6 is quite large in the scaled domain


Copy link
Contributor

The model seems to scale by the max value across all of the targets.

self.scalers = self.xarray_dataset.max(dim=["date", *self.dims])


View entire conversation on ReviewNB

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

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

Project coverage is 92.87%. Comparing base (0a165fd) to head (d70ff3f).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pymc_marketing/mmm/multidimensional.py 60.00% 2 Missing ⚠️
pymc_marketing/mmm/plot.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1521      +/-   ##
==========================================
- Coverage   92.88%   92.87%   -0.02%     
==========================================
  Files          54       54              
  Lines        6270     6272       +2     
==========================================
+ Hits         5824     5825       +1     
- Misses        446      447       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@juanitorduz
Copy link
Collaborator Author

The model seems to scale by the max value across all of the targets.

self.scalers = self.xarray_dataset.max(dim=["date", *self.dims])

View entire conversation on ReviewNB

@carlosagostini is this a feature or a bug 😅 ?

@juanitorduz
Copy link
Collaborator Author

Waiting for some improvements from #1551 :)

@juanitorduz
Copy link
Collaborator Author

Thanks @carlosagostini ! Your fixes worked!

image

image

I am unblocked now :)

@williambdean
Copy link
Contributor

Awesome!

@juanitorduz
Copy link
Collaborator Author

@carlosagostini @wd60622 I am having examples with the out-of-sample predictions (see a93dcf8) I think it's a coords dim update mismatch. I will try to debug but let me know if you have ideas of where this can happen 🙏

@juanitorduz
Copy link
Collaborator Author

juanitorduz commented Mar 16, 2025

I think 3f802a5 solves it (we might need to provide the coordinates for the time varying intercept)

@williambdean
Copy link
Contributor

@carlosagostini @wd60622 I am having examples with the out-of-sample predictions (see a93dcf8) I think it's a coords dim update mismatch. I will try to debug but let me know if you have ideas of where this can happen 🙏

I had a similar fix here

if "_target" in dataset_xarray:
data["target_data"] = dataset_xarray._target.transpose("date", *self.dims)

In this commit: 9bb4df1

@juanitorduz juanitorduz marked this pull request as ready for review March 18, 2025 20:16
@juanitorduz
Copy link
Collaborator Author

@wd60622 @carlosagostini This one is ready for review! I think we can iterate on this notebook as we add more features. Let's merge this one (after your feedback) and engage with the users to get feedback! 🚀 Really AMAZING job you guys have done here!

@cetagostini
Copy link
Contributor

This is great mate, amazing work! I'll take a look tonight 🔥

Copy link
Contributor

@cetagostini cetagostini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good from my side!

@juanitorduz juanitorduz merged commit 4cdd5b8 into main Mar 22, 2025
32 of 33 checks passed
@juanitorduz juanitorduz deleted the mmm_multidimensional_example branch March 22, 2025 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation MMM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants