{"id":21764,"library":"pymc-marketing","title":"PyMC-Marketing","description":"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.","status":"active","version":"0.19.3","language":"python","source_language":"en","source_url":"https://github.com/pymc-labs/pymc-marketing","tags":["marketing","bayesian","pymc","mmm","clv"],"install":[{"cmd":"pip install pymc-marketing","lang":"bash","label":"default"},{"cmd":"pip install 'pymc-marketing[all]'","lang":"bash","label":"with extras"}],"dependencies":[{"reason":"Core probabilistic programming framework","package":"pymc","optional":false},{"reason":"Bayesian model diagnostics and visualization","package":"arviz","optional":false},{"reason":"Data structures for MCMC samples","package":"xarray","optional":false},{"reason":"Data manipulation","package":"pandas","optional":false}],"imports":[{"note":"MMM is in the mmm submodule, not the top-level package.","wrong":"from pymc_marketing import MMM","symbol":"MMM","correct":"from pymc_marketing.mmm import MMM"},{"note":"","wrong":null,"symbol":"CLVModel","correct":"from pymc_marketing.clv import CLVModel"}],"quickstart":{"code":"import pandas as pd\nfrom pymc_marketing.mmm import MMM\n\n# Load some data (replace with real data)\ndata = pd.DataFrame({\n    'date': pd.date_range('2022-01-01', periods=100),\n    'spend': np.random.uniform(100, 1000, 100),\n    'sales': np.random.normal(5000, 500, 100)\n})\n# Create model with dummy priors\nmmm = MMM(\n    date_column='date',\n    channel_columns=['spend'],\n    control_columns=[],\n    adstock_max_lag=4,\n    yearly_seasonality=2\n)\n# Sample (small draws for quick demo)\nmmm.fit(data, draws=100, tune=100, chains=1)\nprint(mmm.summary())","lang":"python","description":"Fits a Bayesian Marketing Mix Model using PyMC."},"warnings":[{"fix":"Update code to include explicit adstock_max_lag and yearly_seasonality parameters; review prior specifications.","message":"Version 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.","severity":"breaking","affected_versions":"<0.19"},{"fix":"Ensure date column is converted to datetime: data['date'] = pd.to_datetime(data['date'])","message":"The MMM model requires a DataFrame with a date column; the column must be in datetime format. Passing strings will cause an error.","severity":"gotcha","affected_versions":"all"},{"fix":"Verify data has the required columns before fitting.","message":"When 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install pymc-marketing","cause":"Package not installed or installed under a different name.","error":"ModuleNotFoundError: No module named 'pymc_marketing'"},{"fix":"Use: from pymc_marketing.mmm import MMM","cause":"MMM is not imported directly from the top-level package; it's in a submodule.","error":"AttributeError: module 'pymc_marketing' has no attribute 'MMM'"},{"fix":"Convert the column to datetime: data['date'] = pd.to_datetime(data['date'])","cause":"The date column is not in datetime format.","error":"ValueError: Date column must be datetime64[ns] dtype"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}