-
Notifications
You must be signed in to change notification settings - Fork 324
Notebook: PyMC-Marketing GAM capabilities #1985
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
base: main
Are you sure you want to change the base?
Notebook: PyMC-Marketing GAM capabilities #1985
Conversation
Added a new notebook 'mmm_gam_options.ipynb' demonstrating custom Bayesian GAMs with PyMC-Marketing. Updated the gallery to include a link to this new example.
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
View / edit / reply to this conversation on ReviewNB juanitorduz commented on 2025-10-08T11:36:22Z Line #1. seed: int = sum(map(ord, "pymc-marketing is more than just a marketing model")) This can be on the "setting the notebook section" |
View / edit / reply to this conversation on ReviewNB juanitorduz commented on 2025-10-08T11:36:23Z Provide some storytelling on what type of series and how many we plan to generate, and what's the objective. cetagostini commented on 2025-10-08T16:42:36Z Added above in the data generation process title. |
View / edit / reply to this conversation on ReviewNB juanitorduz commented on 2025-10-08T11:36:23Z Line #1. countries = ["Venezuela", "Colombia", "Ecuardo", "Panama"] Typo "Ecuador" cetagostini commented on 2025-10-08T16:43:14Z Done! |
View / edit / reply to this conversation on ReviewNB juanitorduz commented on 2025-10-08T11:36:24Z super title overlaps with some subtitles cetagostini commented on 2025-10-08T16:46:15Z Done! |
View / edit / reply to this conversation on ReviewNB juanitorduz commented on 2025-10-08T11:36:25Z Line #19. & (multi_country_df["product_type"] == product_type) Tip: using strings with query can look more readable https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html |
View / edit / reply to this conversation on ReviewNB juanitorduz commented on 2025-10-08T11:36:25Z Same here for the titles |
View / edit / reply to this conversation on ReviewNB juanitorduz commented on 2025-10-08T11:36:26Z Add a subsection "multidimensional model" just to separate sections better? cetagostini commented on 2025-10-08T16:47:43Z Done! |
This notebook is fantastic @cetagostini ! 🚀 ! I left some minor comments. Overall, I suggest we work out a better story telling and motivate at the beginning the plan and scope of the notebook (I think Claude Code can be suer helpful for this as the code is nicely written) |
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.
typo
|
||
### Fundamentals | ||
|
||
::::{grid} 1 2 3 3 |
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.
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.
There are some rendering issues 🤔
|
||
## Marketing Mix Models (MMM) | ||
|
||
### Fundamentals |
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.
Maybe we do not put in into Fundamental but in a new "Custom Models" section (with the ../notebooks/mmm/mmm_components.html
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.
I agree but that section should be for custom models with our modularity, I added but move custom models. Instead this notebook use the capabilities in the API MMM, we are never doing a custom pymc model with the building blocks, we are integrating blocks or stuff into the main API and that should be in the fundamentals (people learn our API).
Happy to move it to the new section, but thats my take!
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.
Idea
Added above in the data generation process title. View entire conversation on ReviewNB |
Done! View entire conversation on ReviewNB |
Done! View entire conversation on ReviewNB |
Done! View entire conversation on ReviewNB |
Maybe reference this in the https://www.pymc-marketing.io/en/latest/notebooks/mmm/mmm_components.html notebook. Maybe at the top |
Two suggestions:
What do we think about retitling and refocusing the current components notebook to be "How to model seasonality and special events." @williambdean? |
@daniel-saunders-phil agree with second point, regarding the first not fully sure. Because, as I see it MMM can indeed be viewed as a subclass or applied form of a GAM. My view is this:
If you want spine lines, thats definitely possible to implement. I could create customization to implement both Probably adding this as comment could be enough, no? Will show the point and close the main idea. |
@juanitorduz render checks done. But the error in the test looks unrelated. |
@carlosagostini According to Copilot: The job failed because the GitHub Actions runner was terminated before all tests finished, as indicated by the error: "The runner has received a shutdown signal... The operation was canceled." This is not a code failure, but an infrastructure/runtime issue. The logs also show warnings about leaked semaphore, semlock, and folder objects, which are common when jobs are forcefully stopped. Solution:
Ensure the notebooks (like mmm_components.ipynb and mmm_time_slice_cross_validation.ipynb) do not run overly long or consume excessive resources. Optimize their code if possible. Can you try solution 2, adding the |
Was this reference added? |
@cetagostini , Copilot suggests we modify the runner.py script
maybe worth a try? |
It's just misleading to label the notebook as being about GAMs if it only presents linear and non-linear regressions. As a reader, I would expect at least one GAM in the GAM notebook. |
This is a fair point @daniel-saunders-phil . I also imagine we are targeting MMM practitioners, so instead of GAMS we could have something more explicit like MMM with custom additive components (or something along those lines but more sexy XD) |
@cetagostini maybe this can help #1986 |
@daniel-saunders-phil really agree with you, we should not say GAMs without one! I build a non parametric form for Saturation and Adstock, as consequence the model with trend, season, and non parametric trasnformations can be considered a GAM. So, this precisely show the point about how to jump from linear models, traditional MMMs, semi-parametric GAM models to fully MMM-GAMs like models. What do we think? @juanitorduz |
How do you leave in-text comments a PR on the notebook reader website thing? I can see the new GAM content but it won't let me comment on it. regardless, it looked good to me. Only a typo "our Generative Additive Media Mix Model is alive and sampling" -> "our Generalized Additive Media Mix Model is alive and sampling" |
I would be careful here. A user may be tempted to think that they can call optimize on top of whatever custom MMM they define, and this is not the case. |
What do you mean? If they follow the wrapper, they could do. What are cases where that's not true? 🤔 @PabloRoque |
@juanitorduz found issue. The approximate fit method (advi) for large models was taking 2 minutes, I take it out and keep example but only with the simple model. |
Description
Added a new notebook 'mmm_gam_options.ipynb' demonstrating custom Bayesian GAMs with PyMC-Marketing. Updated the gallery to include a link to this new example.
Related Issue
Checklist
pre-commit.ci autofix
to auto-fix.📚 Documentation preview 📚: https://pymc-marketing--1985.org.readthedocs.build/en/1985/