A step-by-step web application for Marketing Mix Modelling that attributes sales/revenue to marketing channels using configurable transforms and multiple model types. All saturation transforms follow the law of diminishing marginal returns.
- Step 1: Brand name, model type, data source, column mapping (date, target, channels, segments, controls)
- Step 2: Per-channel transformation type, curvature, adstock parameters, model fit
- Sample dataset – Built-in synthetic MMM data
- Upload CSV – Your own dataset with flexible column mapping
- Generate dataset – Create synthetic data with custom frequency (daily/weekly/monthly/yearly) and channel names
| Transform | Formula | Default |
|---|---|---|
| Negative exponential | ( 1 - e^{-x/k} ) | ✓ |
| Hill | ( x^\alpha / (k^\alpha + x^\alpha) ) | |
| Log | ( \log(1 + x/k) ) | |
| Linear | ( x / (k + x) ) | |
| Power | ( x^\alpha / (k^\alpha + x^\alpha) ), α ∈ (0,1) |
- Linear – OLS with optional constraints
- Ridge – L2 regularization
- Lasso – L1 regularization
- Bayesian – PyMC with priors
- Hierarchical – PyMC with partial pooling
- Positive coefficients – Channel effects ≥ 0
- Lag sum range – Sum of channel coefficients within [lower, upper]
MMM-Marketing-Mix-Modelling/
├── mmm/ # Core MMM package
│ ├── __init__.py
│ ├── config.py # MMMConfig, column inference
│ ├── transforms.py # Adstock, saturation (5 types)
│ ├── pipeline.py # Orchestrator
│ └── models/
│ ├── base.py
│ ├── linear.py
│ ├── ridge_lasso.py
│ ├── bayesian.py # PyMC
│ └── hierarchical.py # PyMC
├── mmm_app.py # Streamlit step-by-step UI
├── create_mmm_dataset.py # Synthetic data generator (CLI)
├── data/
│ └── marketing_mix_weekly.csv
├── requirements.txt
├── .streamlit/config.toml
└── README.md
# Clone
git clone https://github.com/ananttripathi/MMM-Marketing-Mix-Modelling.git
cd MMM-Marketing-Mix-Modelling
# Install
pip install -r requirements.txt
# Run app
streamlit run mmm_app.py# Weekly data, default channels
python create_mmm_dataset.py
# Monthly with custom channels
python create_mmm_dataset.py --freq monthly --channels "TV,Digital,Radio,Brand"
# Daily, negative exponential transform
python create_mmm_dataset.py --freq daily --transform negative_exponential -o my_data.csvThe app supports dynamic column mapping – works with any dataset. Map:
| Column | Description |
|---|---|
| Date | Time period (week, month, etc.) |
| Target | Sales, revenue, or conversions |
| Channels | Marketing spend columns (TV, digital, etc.) |
| Segments | Optional – for segment-level modelling |
| Controls | Covariates (seasonality, holidays, promotions) |
- Fork or use this repo
- Go to share.streamlit.io
- New app → Select repo, branch
main - Main file path:
mmm_app.py - Deploy
streamlit– Web UIpandas,numpy– Datascipy– Optimizationplotly– Chartspymc,arviz– Bayesian/Hierarchical models (optional – remove for faster deploy if only using Linear/Ridge/Lasso)
MIT