pymc-labs/pymc-marketing
Bayesian marketing toolbox in PyMC. Media Mix (MMM), customer lifetime value (CLV), buy-till-you-die (BTYD) models and more.
PyMC-Marketing is an open-source Python library for marketing analytics, built by PyMC Labs. It uses Bayesian statistics to help businesses make data-driven decisions about marketing spend and customer behavior.
What it does:
- Marketing Mix Modeling (MMM): Analyzes how different marketing channels (e.g., ads, campaigns) contribute to sales. It handles carry-over effects (adstock), diminishing returns (saturation), and lets you set custom priors based on domain knowledge. It can also optimize budget allocation across channels for maximum ROI.
- Customer Lifetime Value (CLV): Predicts how much a customer is worth over time. Supports several models (BG/NBD, Pareto/NBD, Gamma-Gamma, Shifted BG, Modified BG/NBD) for both contractual (subscriptions) and non-contractual (one-off purchases) settings.
- Customer Choice Analysis: Models how customers choose between products. Includes discrete choice models (multinomial, nested, mixed logit), MaxDiff (best-worst scaling), and Bayesian BLP. Also has MVITS for analyzing the impact of new product launches on market share.
- Other tools: Bass Diffusion (product adoption over time) and Predicted Incrementality by Experimentation (PIE) for measuring the causal effect of marketing experiments.
Key features:
- Built on PyMC (>= 6.0) and ArviZ (>= 1.2), so it integrates with the broader Bayesian ecosystem.
- Supports GPU acceleration and multiple sampling backends (e.g., BlackJax, NumPyro, Nutpie).
- Includes visualization and model diagnostics.
- Can incorporate causal identification via directed acyclic graphs (DAGs).
- Offers out-of-sample predictions and experiment calibration (e.g., ROAS or cost-per-acquisition adjustments).
Installation:
pip install pymc-marketing
Optional extras: [dag] for causal tooling, [pie] for PIE (requires pymc-bart), [var] for long-term brand effects (requires impulso). Requires Python >= 3.12. A Dockerfile is also provided.
Who it's for: Marketers, data scientists, and analysts who want to apply Bayesian methods to marketing problems. The project is supported by PyMC Labs, which offers consulting and training.
License: Apache 2.0.
Related
- Project
- Project
- Project
- Project
- Project