Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pymc-marketing

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pymc-marketing

Marketing Statistical Models in PyMC

  • 0.10.0
  • PyPI
  • Socket score

Maintainers
2

PyMC-Marketing Logo


Build Test Notebook codecov Ruff docs PyPI Version PyPI - Downloads License

PyMC-Marketing: Bayesian Marketing Mix Modeling (MMM) & Customer Lifetime Value (CLV)

Marketing Analytics Tools from PyMC Labs

Unlock the power of Marketing Mix Modeling (MMM) and Customer Lifetime Value (CLV) analytics with PyMC-Marketing. This open-source marketing analytics tool empowers businesses to make smarter, data-driven decisions for maximizing ROI in marketing campaigns.


This repository is supported by PyMC Labs.

For businesses looking to integrate PyMC-Marketing into their operational framework, PyMC Labs offers expert consulting and training. Our team is proficient in state-of-the-art Bayesian modeling techniques, with a focus on Marketing Mix Models (MMMs) and Customer Lifetime Value (CLV). For more information see here.

Explore these topics further by watching our video on Bayesian Marketing Mix Models: State of the Art.

Community Resources

Quick Installation Guide for Marketing Mix Modeling (MMM) & CLV

To dive into MMM and CLV analytics, set up a specialized Python environment, marketing_env, via conda-forge:

conda create -c conda-forge -n marketing_env pymc-marketing
conda activate marketing_env

For a comprehensive installation guide, refer to the official PyMC installation documentation.

Docker

We provide a Dockerfile to build a Docker image for PyMC-Marketing so that is accessible from a Jupyter Notebook. See here for more details.

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), and extending it by integrating the expertise from core PyMC developers, our API provides:

FeatureDescription
Custom Priors and LikelihoodsTailor your model to your specific business needs by including domain knowledge via prior distributions.
Adstock TransformationOptimize the carry-over effects in your marketing channels.
Saturation EffectsUnderstand the diminishing returns in media investments.
Customize adstock and saturation functionsYou can select from a variety of adstock and saturation functions. You can even implement your own custom functions. See documentation guide.
Time-varying InterceptCapture time-varying baseline contributions in your model (using modern and efficient Gaussian processes approximation methods). See guide notebook.
Time-varying Media ContributionCapture time-varying media efficiency in your model (using modern and efficient Gaussian processes approximation methods). See the guide notebook.
Visualization and Model DiagnosticsGet a comprehensive view of your model's performance and insights.
Choose among many inference algorithmsWe provide the option to choose between various NUTS samplers (e.g. BlackJax, NumPyro and Nutpie). See the example notebook for more details.
Out-of-sample PredictionsForecast future marketing performance with credible intervals. Use this for simulations and scenario planning.
Budget OptimizationAllocate your marketing spend efficiently across various channels for maximum ROI. See the budget optimization example notebook
Experiment CalibrationFine-tune your model based on empirical experiments for a more unified view of marketing. See the lift test integration explanation for more details. Here you can find a Case Study: Unobserved Confounders, ROAS and Lift Tests.

MMM Quickstart

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,
)

Initiate fitting and get a visualization of some of the outputs with:

X = data.drop("y",axis=1)
y = data["y"]
mmm.fit(X,y)
mmm.plot_components_contributions();

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.

Explore a hands-on simulated example for more insights into MMM with PyMC-Marketing.

Essential Reading for Marketing Mix Modeling (MMM)

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 package:

Examples

Non-contractualContractual
Continuousonline purchasesad conversion time
Discreteconcerts & sports eventsrecurring subscriptions

CLV Quickstart

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from pymc_marketing import clv

data_url = "https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/data/clv_quickstart.csv"
data = pd.read_csv(data_url)
data["customer_id"] = data.index

beta_geo_model = clv.BetaGeoModel(data=data)

beta_geo_model.fit()

Once fitted, we can use the model to predict the number of future purchases for known customers, the probability that they are still alive, and get various visualizations plotted.

See the Examples section for more on this.

Why PyMC-Marketing vs other solutions?

PyMC-Marketing is and will always be free for commercial use, licensed under Apache 2.0. Developed by core developers behind the popular PyMC package and marketing experts, it provides state-of-the-art measurements and analytics for marketing teams.

Due to its open-source nature and active contributor base, new features are constantly added. Are you missing a feature or want to contribute? Fork our repository and submit a pull request. If you have any questions, feel free to open an issue.

Thanks to our contributors!

https://github.com/pymc-labs/pymc-marketing/graphs/contributors

Marketing AI Assistant: MMM-GPT with PyMC-Marketing

Not sure how to start or have questions? MMM-GPT is an AI that answers questions and provides expert advice on marketing analytics using PyMC-Marketing.

Try MMM-GPT here.

📞 Schedule a Free Consultation for MMM & CLV Strategy

Maximize your marketing ROI with a free 30-minute strategy session with our PyMC-Marketing experts. Learn how Bayesian Marketing Mix Modeling and Customer Lifetime Value analytics can boost your organization by making smarter, data-driven decisions.

We provide the following professional services:

  • Custom Models: We tailor niche marketing analytics models to fit your organization's unique needs.
  • Build Within PyMC-Marketing: Our team members are experts leveraging the capabilities of PyMC-Marketing to create robust marketing models for precise insights.
  • SLA & Coaching: Get guaranteed support levels and personalized coaching to ensure your team is well-equipped and confident in using our tools and approaches.
  • SaaS Solutions: Harness the power of our state-of-the-art software solutions to streamline your data-driven marketing initiatives.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc