:::{image} _static/marketing-logo-dark.jpg :align: center :class: only-dark ::: :::{image} _static/marketing-logo-light.jpg :align: center :class: only-light ::: # PyMC-Marketing - Open Source Marketing Analytics Solution **Unlock the power of marketing analytics with PyMC-Marketing – the python based open source solution for smarter decision-making.** Marketing mix modeling and customer lifetime value modules allow businesses to make data-driven decisions about their marketing campaigns. Optimize your marketing strategy and unlock the full potential of your customer data. **Checkout the video below to see how Bolt leverages PyMC Marketing to assess the impact of their marketing efforts.** ## Quick links :::::{grid} 1 1 2 2 :gutter: 2 ::::{grid-item-card} Example notebooks :class-header: sd-text-center no-border :class-title: sd-text-center :class-footer: no-border {material-outlined}`menu_book;5em` ^^^^^^^^^^^^^^^ 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. +++ :::{button-ref} notebooks/index :expand: :color: secondary :click-parent: :ref-type: doc To the example notebooks ::: :::: ::::{grid-item-card} API Reference :class-header: sd-text-center no-border :class-title: sd-text-center :class-footer: no-border {material-outlined}`data_object;5em` ^^^^^^^^^^^^^^^ 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. +++ :::{button-ref} api/index :expand: :color: secondary :click-parent: :ref-type: doc To the reference guide ::: :::: ::::: ## In-depth 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)](https://research.google/pubs/pub46001/), and extending it by integrating the expertise from core PyMC developers, our API provides: | Feature | Description | | ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Custom Priors and Likelihoods | Tailor your model to your specific business needs by including domain knowledge via prior distributions. | | Adstock Transformation | Optimize the carry-over effects in your marketing channels. | | Saturation Effects | Understand the diminishing returns in media investments. | | Customize adstock and saturation functions | You can select from a variety of adstock and saturation functions. You can even implement your own custom functions. See [documentation guide](https://www.pymc-marketing.io/en/stable/notebooks/mmm/mmm_components.html). | | Time-varying Intercept | Capture time-varying baseline contributions in your model (using modern and efficient Gaussian processes approximation methods). See [guide notebook](https://www.pymc-marketing.io/en/stable/notebooks/mmm/mmm_time_varying_media_example.html). | | Time-varying Media Contribution | Capture time-varying media efficiency in your model (using modern and efficient Gaussian processes approximation methods). See the [guide notebook](https://www.pymc-marketing.io/en/stable/notebooks/mmm/mmm_tvp_example.html). | | Visualization and Model Diagnostics | Get a comprehensive view of your model's performance and insights. | | Choose among many inference algorithms | We provide the option to choose between various NUTS samplers (e.g. BlackJax, NumPyro and Nutpie). See the [example notebook](https://www.pymc-marketing.io/en/stable/notebooks/general/other_nuts_samplers.html) for more details. | | Out-of-sample Predictions | Forecast future marketing performance with credible intervals. Use this for simulations and scenario planning. | | Budget Optimization | Allocate your marketing spend efficiently across various channels for maximum ROI. See the [budget optimization example notebook](https://www.pymc-marketing.io/en/stable/notebooks/mmm/mmm_budget_allocation_example.html) | | Experiment Calibration | Fine-tune your model based on empirical experiments for a more unified view of marketing. See the [lift test integration explanation](https://www.pymc-marketing.io/en/stable/notebooks/mmm/mmm_lift_test.html) for more details. [Here](https://www.pymc-marketing.io/en/stable/notebooks/mmm/mmm_roas.html) you can find a *Case Study: Unobserved Confounders, ROAS and Lift Tests*. | ## 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. Explore our detailed CLV examples using data from the [`lifetimes`](https://github.com/CamDavidsonPilon/lifetimes) package: - [CLV Quickstart](https://pymc-marketing.readthedocs.io/en/stable/notebooks/clv/clv_quickstart.html) - [BG/NBD model](https://pymc-marketing.readthedocs.io/en/stable/notebooks/clv/bg_nbd.html) - [Pareto/NBD model](https://pymc-marketing.readthedocs.io/en/stable/notebooks/clv/pareto_nbd.html) - [Gamma-Gamma model](https://pymc-marketing.readthedocs.io/en/stable/notebooks/clv/gamma_gamma.html) ### Examples | | **Non-contractual** | **Contractual** | | -------------- | ------------------------ | ----------------------- | | **Continuous** | online purchases | ad conversion time | | **Discrete** | concerts & sports events | recurring subscriptions | ## Installation PyMC-Marketing requires **Python 3.10 or greater**. Install and activate an environment (e.g. `marketing_env`) with the `pymc-marketing` package from [conda-forge](https://conda-forge.org). It may look something like the following: ```bash conda create -c conda-forge -n marketing_env pymc-marketing conda activate marketing_env ``` ### Installation for developers If you are a developer of pymc-marketing, or want to start contributing, [refer to the contributing guide](https://github.com/pymc-labs/pymc-marketing/blob/main/CONTRIBUTING.md) to get started. See the official [PyMC installation guide](https://www.pymc.io/projects/docs/en/latest/installation.html) if more detail is needed. ## Quickstart Create a new Jupyter notebook with either JupyterLab or VS Code. ### JupyterLab Notebook After installing the `pymc-marketing` package (see above), run the following with `marketing_env` activated: ```bash conda install -c conda-forge jupyterlab jupyter lab ``` ### VS Code Notebook After installing the `pymc-marketing` package (see above), run the following with `marketing_env` activated: ```bash conda install -c conda-forge ipykernel ``` Start VS Code and ensure that the "Jupyter" extension is installed. Press Ctrl + Shift + P and type "Python: Select Interpreter". Ensure that `marketing_env` is selected. Press Ctrl + Shift + P and type "Create: New Jupyter Notebook". ### MMM Quickstart ```python import pandas as pd from pymc_marketing.mmm import ( GeometricAdstock, LogisticSaturation, MMM, ) data_url = "https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/data/mmm_example.csv" data = pd.read_csv(data_url, parse_dates=["date_week"]) 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, ) ``` Once the model is fitted, we can further optimize our budget allocation as we are including diminishing returns and carry-over effects in our model.