PyMC-Marketing is an open-source Python library for Bayesian marketing analytics, built and maintained by PyMC Labs. It provides production-ready implementations of Marketing Mix Modeling (MMM) and Customer Lifetime Value (CLV) models, enabling data scientists to measure media effectiveness, optimize marketing spend, and forecast customer value — all with full Bayesian uncertainty quantification. Whether you call it marketing mix modeling or media mix modeling, PyMC-Marketing is the most comprehensive open-source MMM solution available in Python.
Powered by
Trusted in production#
PyMC-Marketing is built and maintained by the core developers of PyMC — the Bayesian modeling library at the heart of the scientific Python stack. Data science teams use it to plan and defend real marketing budgets, with results validated against experiments and lift tests.
750,000+ downloads · 1,100+ GitHub stars · Apache-2.0 licensed — free, open, and auditable
Get started#
PyMC-Marketing is built on top of PyMC >= 6.0 and ArviZ >= 1.2. Since PyMC >= 6, installing with pip is fully supported — no conda environment required (Python >= 3.12).
pip install pymc-marketing
from pymc_marketing.mmm import GeometricAdstock, LogisticSaturation, MMM 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, )
See how PyMC-Marketing compares to Google Meridian, Meta Robyn, and other MMM frameworks, or read the benchmark comparison to Meridian.
Quick links#
Getting Started
Browse our getting started guide to quickly get started with PyMC-Marketing.
Example notebooks
The example notebooks provide examples of using the library in both real case scenarios and synthetic data. They explain how to use the library and showcase its features.
API Reference
The reference guide contains a detailed description of the functions, modules, and objects included in the library. The reference describes how the methods work and which parameters can be used. It assumes that you have an understanding of the key concepts.
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:
Beyond short-term sales response, you can also measure long-term brand effects in MMMs by coupling brand-tracking metrics (e.g., awareness, consideration) with a Bayesian VARX model. See the long-term brand effects notebook for a complete tutorial.
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:
Each of these models is tailored to different types of data and business scenarios:
Customer Choice Analysis#
Analyze the impact of new product launches and understand customer choice behavior with our Multivariate Interrupted Time Series (MVITS) models. Our API supports analysis in both saturated and unsaturated markets to help you:
See our example notebooks for saturated markets and unsaturated markets to learn more about customer choice modeling with PyMC-Marketing.
The customer choice module also includes a full family of discrete choice and preference models:
Bass Diffusion Model#
Forecast the adoption of new products with the Bass Diffusion Model. The model captures how innovators and imitators drive cumulative adoption over time, which is useful for product launch forecasts, demand planning, and growth analysis.
See the Bass Diffusion Model example notebook for a worked example.
Predicted Incrementality by Experimentation (PIE)#
Predict the incremental effect of ad campaigns that never ran an experiment with PIE (alpha). Randomised experiments — geo tests and ghost-ad holdouts — are the gold standard for measuring campaign incrementality, but they are costly and slow. PIE fits a Bayesian BART model on the corpus of campaigns that did run an experiment, learning the map from campaign features to measured incrementality, then predicts a full posterior of incrementality for the campaigns that never did.
The pymc_marketing.pie module is in alpha: the API and defaults may change between releases. See the PIE example notebook for a worked example, including where predictions beat last-click attribution.
Resources#
Bolt’s success story with PyMC-Marketing#
Checkout the video below to see how Bolt leverages PyMC-Marketing to assess the impact of their marketing efforts.
Time-varying parameters in MMMs in PyMC-Marketing#
Customer Lifetime Value Modeling in Marine Industry#
For more videos, webinars and resources, check out the PyMC Labs YouTube channel.
More PyMC Labs Blog Posts and Resources#
Marketing Mix Models#
Customer Lifetime Value#
Case Studies#
Bayesian Media Mix Models: Modelling changes in marketing effectiveness over time
Improving the Speed and Accuracy of Bayesian Media Mix Models
Bayesian inference at scale: Running A/B tests with millions of observations
For more blogposts and resources, check out the PyMC Labs Blog.
Frequently Asked Questions#
What is PyMC-Marketing?#
PyMC-Marketing is an open-source Python library for Bayesian marketing analytics. It includes production-ready implementations of Marketing Mix Modeling (MMM) for measuring media effectiveness and optimizing marketing spend, Customer Lifetime Value (CLV) models for forecasting customer value over time, Customer Choice models for analyzing product launch impacts, and a Bass Diffusion Model for forecasting new product adoption.
How does PyMC-Marketing compare to Google Meridian or Meta Robyn?#
PyMC-Marketing is the only open-source framework that combines MMM, CLV, Customer Choice, and Bass Diffusion models in a single library, with full Bayesian uncertainty quantification via PyMC. Unlike Robyn (frequentist ridge regression) or Meridian (limited to MMM), PyMC-Marketing gives you posterior distributions over all parameters, custom priors for incorporating domain knowledge, and a unified API across all model types. See the full comparison and the benchmark comparison to Meridian.
Is PyMC-Marketing free to use?#
Yes. PyMC-Marketing is completely free and open source under the Apache 2.0 license. You can install it with pip install pymc-marketing.
What Python version does PyMC-Marketing require?#
PyMC-Marketing supports Python 3.12 and above.
Can PyMC-Marketing optimize my marketing budget?#
Yes. PyMC-Marketing includes built-in budget optimization that allocates spend across channels to maximize ROI, accounting for diminishing returns via saturation curves and carry-over effects via adstock transformations.
Need help with PyMC-Marketing?#
Book a free 30-minute strategy session with our experts or send us a message.