- Notifications
You must be signed in to change notification settings - Fork325
Bayesian marketing toolbox in PyMC. Media Mix (MMM), customer lifetime value (CLV), buy-till-you-die (BTYD) models and more.
License
pymc-labs/pymc-marketing
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Marketing Analytics Tools fromPyMC Labs
Unlock the power ofMarketing Mix Modeling (MMM),Customer Lifetime Value (CLV) andCustomer Choice Analysis (CSA) 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 byPyMC 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 seehere.
Explore these topics further by watching our video onBayesian Marketing Mix Models: State of the Art.
To dive into PyMC-Marketing, set up a specialized Python environment,marketing_env
, via conda-forge:
conda create -c conda-forge -n marketing_env pymc-marketingconda activate marketing_env
For a comprehensive installation guide, refer to theofficial PyMC installation documentation.
We provide aDockerfile
to build a Docker image for PyMC-Marketing so that is accessible from a Jupyter Notebook. Seehere for more details.
Leverage our Bayesian MMM API to tailor your marketing strategies effectively. Leveraging on top of the research articleJin, 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:
Feature | Benefit |
---|---|
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. Seedocumentation guide. |
Time-varying Intercept | Capture time-varying baseline contributions in your model (using modern and efficient Gaussian processes approximation methods). Seeguide notebook. |
Time-varying Media Contribution | Capture time-varying media efficiency in your model (using modern and efficient Gaussian processes approximation methods). See theguide notebook. |
Visualization and Model Diagnostics | Get a comprehensive view of your model's performance and insights. |
Causal Identification | Input a business driven directed acyclic graph to identify the meaningful variables to include into the model to be able to draw causal conclusions. For a concrete example see theguide notebook. |
Choose among many inference algorithms | We provide the option to choose between various NUTS samplers (e.g. BlackJax, NumPyro and Nutpie). See theexample notebook for more details. |
GPU Support | PyMC's multiple backends allow for GPU acceleration. |
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 thebudget optimization example notebook |
Experiment Calibration | Fine-tune your model based on empirical experiments for a more unified view of marketing. See thelift test integration explanation for more details.Here you can find aCase Study: Unobserved Confounders, ROAS and Lift Tests. |
importpandasaspdfrompymc_marketing.mmmimport (GeometricAdstock,LogisticSaturation,MMM,)frompymc_marketing.pathsimportdata_dirfile_path=data_dir/"mmm_example.csv"data=pd.read_csv(file_path,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 insightful plots and summaries. For example, we can plot the components contributions:
X=data.drop("y",axis=1)y=data["y"]mmm.fit(X,y)mmm.plot_components_contributions()
You can compute channels efficienty and compare them with the estimated return on ad spend (ROAS).
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 ourquickstart guide and more completesimulated example for more insights into MMM with PyMC-Marketing.
- Get started with a complete end-to-end analysis: from model specification to budget allocation. See theguide notebook.
- Bayesian Media Mix Modeling for Marketing Optimization
- Improving the Speed and Accuracy of Bayesian Marketing Mix Models
- Johns, Michael and Wang, Zhenyu. "A Bayesian Approach to Media Mix Modeling"
- Orduz, Juan. "Media Effect Estimation with PyMC: Adstock, Saturation & Diminishing Returns"
- A Comprehensive Guide to Bayesian Marketing Mix Modeling
Dynamic and interactive visualization of key Marketing Mix Modeling (MMM) concepts, including adstock, saturation, and the use of Bayesian priors. This app aims to help marketers, data scientists, and anyone interested in understanding MMM more deeply.
Understand and optimize your customer's value with ourCLV 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.
- CLV Quickstart
- BG/NBD model
- Pareto/NBD model
- Gamma-Gamma model
- Shifted Beta-Geo model
- Modified BG/NBD model
Non-contractual | Contractual | |
---|---|---|
Continuous | online purchases | ad conversion time |
Discrete | concerts & sports events | recurring subscriptions |
importmatplotlib.pyplotaspltimportpandasaspdimportseabornassnsfrompymc_marketingimportclvfrompymc_marketing.pathsimportdata_dirfile_path=data_dir/"clv_quickstart.csv"data=pd.read_csv(data_path)data["customer_id"]=data.indexbeta_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.
Analyze the impact of new product launches and understand customer choice behavior with ourMultivariate Interrupted Time Series (MVITS) models. Our API supports analysis in both saturated and unsaturated markets to help you:
Feature | Benefit |
---|---|
Market Share Analysis | Understand how new products affect existing product market shares |
Causal Impact Assessment | Measure the true causal effect of product launches on sales |
Saturated Market Analysis | Model scenarios where total market size remains constant |
Unsaturated Market Analysis | Handle cases where new products grow the total market size |
Visualization Tools | Plot market shares, causal impacts, and counterfactuals |
Bayesian Inference | Get uncertainty estimates around all predictions |
importpandasaspdfrompymc_marketing.customer_choiceimportMVITS,plot_product# Define existing productsexisting_products= ["competitor","own"]# Create MVITS modelmvits=MVITS(existing_sales=existing_products,saturated_market=True,# Set False for unsaturated markets)# Fit modelmvits.fit(X,y)# Plot causal impact on market sharemvits.plot_causal_impact_market_share()# Plot counterfactualsmvits.plot_counterfactual()
See our example notebooks forsaturated markets andunsaturated markets to learn more about customer choice modeling with PyMC-Marketing.
The Bass Diffusion Model is a popular model for predicting the adoption of new products. It is a type of product life cycle model that describes the market penetration of a new product as a function of time. PyMC-Marketing provides a flexible implementation of the Bass Diffusion Model, allowing you to customize the model parameters and fit the model to your specific data (many products).
Discrete choice models come in various forms, but each aims to show how choosing between a set of alternatives can be understood as a function of the observable attributes of the alternatives at hand. This type of modelling drives insight into the "must-have" features of a product, and can be used to assess the success or failure of product launches or re-launches. The PyMC-marketing implementation offers a formula based model specification, for estimating the relative utility of each good in a market and identifying their most important features.
PyMC-Marketing is and will always be free for commercial use, licensed underApache 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 toopen an issue.
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.
Maximize your marketing ROI with afree 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.
About
Bayesian marketing toolbox in PyMC. Media Mix (MMM), customer lifetime value (CLV), buy-till-you-die (BTYD) models and more.
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.