Marketing Statistical Models in PyMC
Project description
PyMC-Marketing: Bayesian Marketing Mix Modeling (MMM) & Customer Lifetime Value (CLV)
Marketing Analytics Tools from PyMC Labs
Unlock the power of Marketing Mix Modeling (MMM) and Customer Lifetime Value (CLV) analytics with PyMC-Marketing. This open-source marketing analytics tool empowers businesses to make smarter, data-driven decisions for maximizing ROI in marketing campaigns.
This repository is supported by PyMC Labs.
For businesses looking to integrate PyMC-Marketing into their operational framework, PyMC Labs offers expert consulting and training. Our team is proficient in state-of-the-art Bayesian modeling techniques, with a focus on Marketing Mix Models (MMMs) and Customer Lifetime Value (CLV). For more information see here.
Explore these topics further by watching our video on Bayesian Marketing Mix Models: State of the Art.
Community Resources
Quick Installation Guide for Marketing Mix Modeling (MMM) & CLV
To dive into MMM and CLV analytics, set up a specialized environment, marketing_env
, via conda-forge:
conda create -c conda-forge -n marketing_env pymc-marketing
conda activate marketing_env
For a comprehensive installation guide, refer to the official PyMC installation documentation.
Docker
We provide a Dockerfile
to build a Docker image for PyMC-Marketing so that is accessible from a Jupyter Notebook. See here for more details.
In-depth Bayesian Marketing Mix Modeling (MMM) in PyMC
Leverage our Bayesian MMM API to tailor your marketing strategies effectively. Leveraging on top of the research article Jin, Yuxue, et al. “Bayesian methods for media mix modeling with carryover and shape effects.” (2017), and extending it by integrating the expertise from core PyMC developers, our API provides:
- Custom Priors and Likelihoods: Tailor your model to your specific business needs by including domain knowledge via prior distributions.
- Adstock Transformation: Optimize the carry-over effects in your marketing channels.
- Saturation Effects: Understand the diminishing returns in media investments.
- Customize adstock and saturation functions: You can select from a variety of adstock and saturation functions. You can even implement your own custom functions.
- Time-varying Intercept: Capture time-varying baseline contributions in your model (using modern and efficient Gaussian processes approximation methods).
- Time-varying Media Contribution: Capture time-varying media efficiency in your model (using modern and efficient Gaussian processes approximation methods).
- Visualization and Model Diagnostics: Get a comprehensive view of your model's performance and insights.
- Choose among many inference algorithms: We provide the option to choose between various NUTS samplers (e.g. BlackJax, NumPyro and Nutpie). See the example notebook for more details.
- Out-of-sample Predictions: Forecast future marketing performance with credible intervals. Use this for simulations and scenario planning.
- Budget Optimization: Allocate your marketing spend efficiently across various channels for maximum ROI.
- Experiment Calibration: Fine-tune your model based on empirical experiments for a more unified view of marketing.
MMM Quickstart
import pandas as pd
from pymc_marketing.mmm import (
GeometricAdstock,
LogisticSaturation,
MMM,
)
data_url = "https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/data/mmm_example.csv"
data = pd.read_csv(data_url, parse_dates=["date_week"])
mmm = MMM(
adstock=GeometricAdstock(l_max=8),
saturation=LogisticSaturation(),
date_column="date_week",
channel_columns=["x1", "x2"],
control_columns=[
"event_1",
"event_2",
"t",
],
yearly_seasonality=2,
)
Initiate fitting and get a visualization of some of the outputs with:
X = data.drop("y",axis=1)
y = data["y"]
mmm.fit(X,y)
mmm.plot_components_contributions();
Once the model is fitted, we can further optimize our budget allocation as we are including diminishing returns and carry-over effects in our model.
Explore a hands-on simulated example for more insights into MMM with PyMC-Marketing.
Essential Reading for Marketing Mix Modeling (MMM)
- Bayesian Media Mix Modeling for Marketing Optimization
- Improving the Speed and Accuracy of Bayesian Marketing Mix Models
- Johns, Michael and Wang, Zhenyu. "A Bayesian Approach to Media Mix Modeling"
- Orduz, Juan. "Media Effect Estimation with PyMC: Adstock, Saturation & Diminishing Returns"
- A Comprehensive Guide to Bayesian Marketing Mix Modeling
Unlock Customer Lifetime Value (CLV) with PyMC
Understand and optimize your customer's value with our CLV models. Our API supports various types of CLV models, catering to both contractual and non-contractual settings, as well as continuous and discrete transaction modes.
Explore our detailed CLV examples using data from the lifetimes
package:
Examples
Non-contractual | Contractual | |
---|---|---|
Continuous | online purchases | ad conversion time |
Discrete | concerts & sports events | recurring subscriptions |
CLV Quickstart
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from pymc_marketing import clv
data_url = "https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/data/clv_quickstart.csv"
data = pd.read_csv(data_url)
data["customer_id"] = data.index
beta_geo_model = clv.BetaGeoModel(data=data)
beta_geo_model.fit()
Once fitted, we can use the model to predict the number of future purchases for known customers, the probability that they are still alive, and get various visualizations plotted.
See the Examples section for more on this.
Why PyMC-Marketing vs other solutions?
PyMC-Marketing is and will always be free for commercial use, licensed under Apache 2.0. Developed by core developers behind the popular PyMC package and marketing experts, it provides state-of-the-art measurements and analytics for marketing teams.
Due to its open-source nature and active contributor base, new features are constantly added. Are you missing a feature or want to contribute? Fork our repository and submit a pull request. If you have any questions, feel free to open an issue.
Thanks to our contributors!
Marketing AI Assistant: MMM-GPT with PyMC-Marketing
Not sure how to start or have questions? MMM-GPT is an AI that answers questions and provides expert advice on marketing analytics using PyMC-Marketing.
📞 Schedule a Free Consultation for MMM & CLV Strategy
Maximize your marketing ROI with a free 30-minute strategy session with our PyMC-Marketing experts. Learn how Bayesian Marketing Mix Modeling and Customer Lifetime Value analytics can boost your organization by making smarter, data-driven decisions.
We provide the following professional services:
- Custom Models: We tailor niche marketing analytics models to fit your organization's unique needs.
- Build Within PyMC-Marketing: Our team members are experts leveraging the capabilities of PyMC-Marketing to create robust marketing models for precise insights.
- SLA & Coaching: Get guaranteed support levels and personalized coaching to ensure your team is well-equipped and confident in using our tools and approaches.
- SaaS Solutions: Harness the power of our state-of-the-art software solutions to streamline your data-driven marketing initiatives.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pymc_marketing-0.8.0.tar.gz
.
File metadata
- Download URL: pymc_marketing-0.8.0.tar.gz
- Upload date:
- Size: 132.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4e204e6dec2d414083fe473c54d5f24e07934a888dad1d3fa9fc0380f6a438f |
|
MD5 | 101d4fa07ec2bb4e949fa61915292f64 |
|
BLAKE2b-256 | 93797100ec54b1fd2719ffb83530829b432445e9f3c75f939e7e91a8ba0ebcb2 |
File details
Details for the file pymc_marketing-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: pymc_marketing-0.8.0-py3-none-any.whl
- Upload date:
- Size: 146.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d915db286f3a116350cdc7023876d99a387c3d2b680e798b96db0a05fcb56451 |
|
MD5 | bcd2db8f3f7814b271e2836860784b6b |
|
BLAKE2b-256 | de14c247ea9309cb10b9a6de5236964a6d516521fb16b976bb0d60c3ac5e7d73 |