Registry / ai-ml / pymc-marketing

pymc-marketing

JSON →
library0.19.4pypypi✓ verified 87d ago

A Python library for marketing statistical models built on top of PyMC. It provides Bayesian approaches to marketing mix modeling (MMM), customer lifetime value (CLV), and other marketing analytics. Current version 0.19.3, requires Python >=3.12. Released under active development with frequent updates.

pip install pymc-marketing
INSTALL
IMPORT
SIG · PYMC-MARKETING
P
pymc-marketing
ai-mlpythonv0.19.4
Install
29.1s avg
Import
12317ms
Disk
687MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.15.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 29.1s · import 9.854s · 694MB
687MB installed
● package 687MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MMM
from pymc_marketing.mmm import MMM
from pymc_marketing import MMM
MMM is in the mmm submodule, not the top-level package.
CLVModel
from pymc_marketing.clv import CLVModel

Fits a Bayesian Marketing Mix Model using PyMC.

import pandas as pd from pymc_marketing.mmm import MMM # Load some data (replace with real data) data = pd.DataFrame({ 'date': pd.date_range('2022-01-01', periods=100), 'spend': np.random.uniform(100, 1000, 100), 'sales': np.random.normal(5000, 500, 100) }) # Create model with dummy priors mmm = MMM( date_column='date', channel_columns=['spend'], control_columns=[], adstock_max_lag=4, yearly_seasonality=2 ) # Sample (small draws for quick demo) mmm.fit(data, draws=100, tune=100, chains=1) print(mmm.summary())
Debug
Known issues
breakingVersion 0.19.x introduced breaking changes in the MMM API: the `adstock_max_lag` and `yearly_seasonality` parameters are now required and the default prior distributions changed.
fix
Update code to include explicit adstock_max_lag and yearly_seasonality parameters; review prior specifications.
affects: <0.19
gotchaThe MMM model requires a DataFrame with a date column; the column must be in datetime format. Passing strings will cause an error.
fix
Ensure date column is converted to datetime: data['date'] = pd.to_datetime(data['date'])
affects: all
gotchaWhen using the CLV module, the `CLVModel` expects a specific data shape with columns 'frequency', 'recency', 'T', and 'monetary_value'. Missing columns will raise a KeyError.
fix
Verify data has the required columns before fitting.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pymc_marketing'
Package not installed or installed under a different name.
fix
Run: pip install pymc-marketing
AttributeError: module 'pymc_marketing' has no attribute 'MMM'
MMM is not imported directly from the top-level package; it's in a submodule.
fix
Use: from pymc_marketing.mmm import MMM
ValueError: Date column must be datetime64[ns] dtype
The date column is not in datetime format.
fix
Convert the column to datetime: data['date'] = pd.to_datetime(data['date'])
Upgrade
Version history
0.19.4latest on PyPI · released May 6, 2026
Audit
Dependencies
pymcrequiredCore probabilistic programming framework
arvizrequiredBayesian model diagnostics and visualization
xarrayrequiredData structures for MCMC samples
pandasrequiredData manipulation
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
pymc-marketing — pip install pymc-marketing · libregistry