pymc-marketing
pymc-marketing copied to clipboard
v0 Streamlit MMM Explainer App
A Streamlit app to illustrate saturation, adstock and prior concepts in an intuitive, visual way to stakeholders and new MMMers
Description
I've added a v0 Streamlit app to allow people to visualise and understand important MMM concepts more easily. One page of the app address adstock and has interactive charts of Geometric, Delayed Geometric, Weibull CDF and Weibull PDF adstock, along with LaTex for the transformations and a bit of documentation/explanation. Another page does something similar, but for the most common MMM saturation functions. The entry page visualises common prior distributions used in MMM, allowing users to see how we can encode prior knowledge into our MMMs. A proof of concept deployment can be found here. We can very easily redeploy it using a pymc-marketing email when/if the PR is approved :)
Related Issue
- [x] Closes #613
- [ ] Related to #
Checklist
- [x] Checked that the pre-commit linting/style checks pass
- [x] Included tests that prove the fix is effective or that the new feature works
- [x] Added necessary documentation (docstrings and/or example notebooks)
- [ ] If you are a pro: each commit corresponds to a relevant logical change
Modules affected
- [ ] MMM
- [ ] CLV
Type of change
- [x] New feature / enhancement
- [ ] Bug fix
- [ ] Documentation
- [ ] Maintenance
- [ ] Other (please specify):
π Documentation preview π: https://pymc-marketing--614.org.readthedocs.build/en/614/
@iruar @carlosagostini @wd60622 @cetagostini
Lemme know what you guys think! π
Seems like a pretty cool idea! How do you expect users to work with it? It seems like the repo would have to be cloned to used. Seems like this would have to be added into the python package (pymc_marketing) folder. Maybe a user could install pymc-marketing and kick this off from the commandline? How do you imagine this workflow?
Hey @wd60622 ! Thanks for your comments - I actually don't think the users would need to install the package or clone the repo or anything! Streamlit support app deployments, so if you click on the link in the PR description you can see that the app is already live and deployed (or a POC anyway) π
I'd picture this more just being linked in the documentation and referred to a bit in the repository. I moved the code here because I'm keen to transfer it to open source pymc-marketing, but I don't mind so much where the code lives just so long as others can have access to it and the app.
This looks great @louismagowan! Is there a link where we can check it out?
I agree with @wd60622 that being able to execute this after installation would be nice. Usually for this an executable .py file would be placed in a scripts folder.
A proof of concept deployment can be found here. We can very easily redeploy it using a pymc-marketing email when/if the PR is approved :)
Here is the link @twiecki
Oh I see! Yep so it can be run locally super easily too - it'd just be streamlit run Visualise_Priors.py and it would automatically open up in your browser (provided you've installed the dependencies / activated the MMM venv etc)
Happy to move the code around wherever it needs to go though.
One thing to be aware of, however, is that there are some rules you have to meet to deploy with Streamlit (e.g. the requirements.txt added in the folder when we already have an environment.yml). My current code satisfies those rules, but they might have an impact on where you want to move code etc
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 91.62%. Comparing base (
6e37d3b) to head (42a1315).
:exclamation: Current head 42a1315 differs from pull request most recent head 38cd448
Please upload reports for the commit 38cd448 to get more accurate results.
Additional details and impacted files
@@ Coverage Diff @@
## main #614 +/- ##
==========================================
- Coverage 92.25% 91.62% -0.63%
==========================================
Files 24 24
Lines 2414 2388 -26
==========================================
- Hits 2227 2188 -39
- Misses 187 200 +13
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
How feasible is it to deploy streamlit under the section of the current website? @twiecki
Maybe under the same domain? i.e.https://www.pymc-marketing.io/en/stable/...
Maybe something like the "About PyMC-Labs" would work as well.
@louismagowan Is the deployment a manual process? Is it supported with a GitHub action? The easier to maintain, the better in my mind!
Hey @wd60622 - it's a managed deployment by Streamlit, so super easy (but also slightly less control perhaps). Basically, you just need to specify a repo or a folder within a repo that contains your app code, a requirements.txt and maybe some config - Streamlit just takes that folder/repo and does all the hosting stuff for you. There's no CI/CD or anything, just if you need to make changes to the app you make them, commit and Streamlit updates the app. Nothing to maintain really π
Streamlit make it all super hands-off and easy!
If you want to make changes and test things, they recommend just running the app locally and making the changes vs the local app. Anything that works locally will work in the deployment
Hey @wd60622 - it's a managed deployment by Streamlit, so super easy (but also slightly less control perhaps). Basically, you just need to specify a repo or a folder within a repo that contains your app code, a requirements.txt and maybe some config - Streamlit just takes that folder/repo and does all the hosting stuff for you. There's no CI/CD or anything, just if you need to make changes to the app you make them, commit and Streamlit updates the app. Nothing to maintain really π
Streamlit make it all super hands-off and easy!
Sure. I understand that. However, if we make changes to this files, does streamlit watch the repo? How does it know to redeploy. We'd want this to be the least hand-ons as possible and likely kickoff deployment from our side
Streamlit watches the repo indeed! Any changes that are made to the repo are reflected in the app immediately and automatically βΊοΈ
Check out this pull request onΒ ![]()
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
Great initiative! I feel it's a very cool tool to add our repo!
cc: @juanitorduz
Hi! Apologies for the late reply, but we were focusing on the 0.5.0 release π. This PR is next on our review list... Please bare with us π
pre-commit.ci autofix
pre-commit.ci autofix
Ok! This PR is next in my to-do ππ
pre-commit.ci autofix
What if we had this as a separate project that would fix a certain pymc-marketing version as a dependency?
What if we had this as a separate project that would fix a certain pymc-marketing version as a dependency?
I think it is worth waiting to merge https://github.com/pymc-labs/pymc-marketing/pull/632 as there will be many changes on the transformations API. That being said, after merging https://github.com/pymc-labs/pymc-marketing/pull/632 we can then use these new functions to feed the streamlit app and have it as an experimental contribution (it is on a different folder). Moving it to a different repo will probably delay making this accessible to the public because here we can reuse the linters and test suite. I agree it would be better to have it as a separate repo for the midterm. WDTY?
What if we had this as a separate project that would fix a certain pymc-marketing version as a dependency?
I think it is worth waiting to merge #632 as there will be many changes on the transformations API. That being said, after merging #632 we can then use these new functions to feed the streamlit app and have it as an experimental contribution (it is on a different folder). Moving it to a different repo will probably delay making this accessible to the public because here we can reuse the linters and test suite. I agree it would be better to have it as a separate repo for the midterm. WDTY?
OK, I think we can incubate it here where it will also be easier to discover and see how that goes.
Thanks for the comments and feedback team! All super useful and I agree with it. I was on holiday but will work on addressing the comments ASAP π
@juanitorduz @cetagostini @wd60622 How do you guys think it looks now then?
Apologies for the multiple tags- you had all commented so I was unsure who was best βΊοΈ
Also - FYI, I had to update the Python version of the app to avoid a dependency conflict. So I had to redeploy - the URL of the app is now here. I updated the link in my original message too.
Great! I'll take a look at it on Tuesday morning (Monday is bank holiday in Berlin). Thanks for the updates! π€π€
Have a great weekend!
Thanks @juanitorduz! π That's great news - is someone else going to merge it then? I don't have the permissions to merge it I believe
FYI as well, I might redeploy it once it's merged into master - just so that then the deployment points to the main branch rather than my streamlit_explainer branch. The code will be unchanged
This is a great addition, thanks @louismagowan!
Amazing, thank you @twiecki π