Skip to content

Commit

Permalink
Enhance MMM intro material (pymc-labs#1017)
Browse files Browse the repository at this point in the history
* init

* data sources and actionability

* more content
  • Loading branch information
juanitorduz authored Sep 10, 2024
1 parent d0f1fd6 commit 40dee1d
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/source/guide/mmm/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Given the popularity of the Media Mix Modelling (MMM) approach, there are many p
| Model | 🏗️ Build | 🏗️ Build | 🏗️ Build | 🏗️ Build | 🛒 Buy |
| Budget optimizer ||||||
| Time-varying intercept ||||||
| Time-varying coefficients | coming soon |||||
| Time-varying coefficients | |||||
| Custom priors ||||||
| Lift-test calibration ||||||
| Out of sample predictions ||||||
Expand Down
141 changes: 134 additions & 7 deletions docs/source/guide/mmm/mmm_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,61 @@ Fortunately, with Bayesian modeling, we can do better than this! So-called Media

## What can you do with Media Mix Modeling?

Media Mix Modeling gives rich insights and is used in many ways, but here are some of the highlights:
Media Mix Modeling (MMM) is a powerful tool that provides actionable insights for businesses. Here are some key ways you can leverage MMM to drive strategic decisions and improve your marketing ROI:

1. Understand the effectiveness of different media channels in driving customer acquisition. Not only can you learn from data about the most influential media channels for your business, but you can update this understanding over time. By incorporating new marketing and customer acquisition data on an ongoing basis, you can learn about the changing effectiveness of each channel over time.
2. Avoid being misled by other factors. If the rate of customer acquisitions dramatically changes, was this caused by changes in marketing spend across media channels? Or was it caused by other factors such as changes in seasonality, consumer sentiment, economic factors, pricing changes, etc.?
3. Inform media spending decisions. Having gained an understanding of the effectiveness of different media channels, such as knowing the customer acquisition cost per channel or the degree of channel saturation, this could be used to inform future marketing spend across channels.
4. Optimize future marketing decisions. Rather than just inform future budget spending decisions, it is actually possible to optimize these spending decisions. For example, it is possible to calculate budgets across media channels that maximize our KPI for a given total budget. See this blog post on Bayesian decision-making for more information.
5. Inspire marketing experiments. If there is uncertainty about the effectiveness or saturation of channels, we can intelligently respond to this by running lift or incrementality tests to resolve some of this uncertainty.
6. Validate your understanding through predictions. We gain confidence in our knowledge of the world by making predictions and comparing them to what happens. MMM also generates forecasts that we can check against reality. As a result, we can improve our understanding and modeling iteratively to become more accurate over time.

2. Optimize Budget Allocation: Use MMM to determine the most effective distribution of your marketing budget across different channels. By understanding the impact of each channel on your KPIs, you can allocate resources where they'll generate the highest return.

3. Enhance ROI Forecasting: Develop more accurate forecasts of expected returns for different marketing scenarios. This allows you to set realistic goals and make data-driven decisions about future campaigns.

4. Identify Synergies Between Channels: Uncover how different marketing channels interact and complement each other. This insight can help you create more cohesive, integrated marketing strategies that leverage cross-channel effects.

5. Adapt to Market Changes: Continuously update your model with new data to track changes in channel effectiveness over time. This allows you to quickly adapt your strategy to evolving market conditions, consumer behaviors, or competitive landscapes.

6. Justify Marketing Investments: Use concrete data to demonstrate the value of marketing activities to stakeholders. MMM provides a quantitative basis for marketing budget discussions and helps align marketing goals with overall business objectives.

7. Optimize Timing and Frequency: Determine the optimal timing and frequency of your marketing efforts across different channels. This can help you avoid oversaturation and maximize the impact of your campaigns.

8. Scenario Planning: Run "what-if" analyses to evaluate potential outcomes of different marketing strategies before implementing them. This can help mitigate risks and identify the most promising opportunities.

9. Personalize Marketing Strategies: Use insights from MMM to tailor your marketing approach for different customer segments or geographic regions, maximizing relevance and effectiveness.

10. Benchmark Performance: Compare your marketing performance against industry standards or historical data to identify areas for improvement and set competitive targets.

11. Guide Long-term Strategy: Use MMM insights to inform long-term marketing and business strategies, ensuring that your marketing efforts align with and support your company's broader goals and vision.

By leveraging these actionable insights from Media Mix Modeling, businesses can make more informed, data-driven decisions that lead to improved marketing effectiveness, increased ROI, and sustainable growth.

![](bayesian_mmm_workflow2.png)

## Brief history of Media Mix Models

Media Mix Models (MMMs) have a rich history dating back to the 1950s and 1960s when they were first developed by marketing pioneers. Here's a brief overview of their evolution:

1. 1950s-1960s: The concept of MMMs emerged as marketers sought to quantify the impact of different advertising channels on sales.

2. 1970s-1980s: With the advent of more sophisticated statistical techniques and computing power, MMMs became more widespread in the advertising industry.

3. 1990s: The rise of scanner data and loyalty card programs provided more granular data, allowing for more detailed and accurate models.

4. 2000s: The digital revolution introduced new challenges and opportunities. MMMs had to adapt to incorporate digital channels and deal with the increased complexity of the media landscape.

5. 2010s: Big data and machine learning techniques began to be incorporated into MMMs, allowing for more complex models and real-time optimization.

6. Present day: Modern Bayesian approaches, like those used in PyMC-Marketing. These offer several advantages, including the ability to incorporate prior knowledge, handle uncertainty more robustly, calibrate the models through lift tests, and provide more interpretable results.

Throughout this evolution, the core goal of MMMs has remained the same: to help marketers understand and optimize the effectiveness of their marketing spend across different channels. As the media landscape continues to evolve, so too will the techniques and applications of Media Mix Modeling.


## How does Media Mix Modeling work?

In simple terms, we can understand MMMs as regression modeling applied to business data. The goal is to estimate the impact of marketing activities and other drivers on a metric of interest, such as the number of new customers per week.

To do this, we use two main types of predictor variables:

1. The level of spend for each media channel over time.

2. A set of control measurements that could capture seasonality or economic indicators.
The basic approach to MMMs uses linear regression to estimate a set of coefficients for the relative importance of each of these predictors, but real-world MMMs commonly incorporate also non-linear factors to more accurately capture the effect of marketing activities on consumer behaviour:

Expand All @@ -45,6 +82,96 @@ Thus we can summarize the full MMM with this image:

![](bayesian_mmm.png)

## Putting it all together
## Data Requirements

To effectively implement a Media Mix Model (MMM), you need to gather specific types of data. Here are the key data requirements:

1. Sales or KPI Data:
- Time series data of your target variable (e.g., sales, conversions, new customers)
- Typically at a weekly or daily granularity
- Should cover a sufficient time period (ideally 2-3 years) to capture seasonality and trends

2. Marketing Spend Data:
- Time series data of marketing expenditures (or impressions) for each channel (e.g., TV, radio, digital, print)
- Should match the granularity of your sales data
- Include all significant marketing channels used during the period

3. Control Variables:
- Economic indicators (e.g., GDP, unemployment rate)
- Competitor activities (if available)
- Seasonal factors (e.g., holidays, special events)
- Price changes or promotions

4. External Factors:
- Weather data (if relevant to your business)
- Industry-specific factors

5. Geographic Data:
- If running regional campaigns, include location information

6. Ideally, you have some lift tests or other experiments that you can use to calibrate your model.

Remember, the quality and completeness of your data directly impact the accuracy and usefulness of your Media Mix Model. It's crucial to ensure data consistency, handle missing values appropriately, and validate data quality before building your model.


## PyMC-Marketing Media Mix Modeling features

PyMC-Marketing offers a comprehensive suite of features for Media Mix Modeling:

• Custom Priors and Likelihoods: Incorporate domain-specific knowledge into your model through customizable prior distributions, allowing you to tailor the model to your unique business needs.

• Adstock Transformation: Optimize the carry-over effects in your marketing channels to better understand how past marketing efforts impact current performance.

• Saturation Effects: Model and analyze the diminishing returns on media investments, helping you identify the point of optimal spending for each channel.

• Customizable Adstock and Saturation Functions: Choose from a variety of pre-built functions or implement your own custom functions to model adstock and saturation effects. Refer to the documentation guide for more details.

• Time-varying Intercept: Capture baseline contributions that change over time using advanced Gaussian process approximation methods. This allows for more accurate modeling of underlying trends in your data.

• Time-varying Media Contribution: Model the efficiency of media channels as it changes over time, again utilizing efficient Gaussian process approximation methods. This feature provides insights into how the effectiveness of different channels evolves.

• Visualization and Model Diagnostics: Get a comprehensive view of your model's performance through various visualization tools and diagnostic metrics, helping you interpret results and validate your model.

• Flexible Inference Algorithms: Choose from multiple NUTS (No-U-Turn Sampler) implementations, including BlackJax, NumPyro, and Nutpie, to best suit your inference needs.

• Out-of-sample Predictions: Generate forecasts for future marketing performance, complete with credible intervals. This feature is invaluable for simulations and scenario planning.

• Budget Optimization: Efficiently allocate your marketing budget across various channels to maximize ROI. The package includes tools to help you determine the optimal spend for each channel.

• Experiment Calibration: Fine-tune your model based on empirical experiments, such as lift tests, to create a more unified and accurate view of your marketing efforts. This feature helps bridge the gap between model predictions and real-world results.

Each of these features is supported by extensive documentation and example notebooks, allowing you to dive deeper into their implementation and use cases.


## PyMC-Marketing in Production

PyMC-Marketing can be seamlessly integrated into production environments using modern PyData stack MLOps tools. This allows for automated, scalable, and reproducible media mix modeling workflows. Here are some key aspects of running PyMC-Marketing in production:

1. Containerization with Docker:
- Encapsulate your PyMC-Marketing environment and dependencies in a Docker container.
- Ensure consistency across different environments (development, testing, production).
- Simplify deployment and scaling of your MMM pipelines.

2. Experiment Tracking with MLflow:
- Log model parameters, metrics, and artifacts using MLflow.
- Compare different model versions and track experiments over time.
- Easily reproduce results and share insights with team members.

3. Workflow Orchestration:
- Use tools like Apache Airflow or Prefect, for example, to schedule and orchestrate your MMM pipelines.
- Automate data ingestion, model training, and result generation on a regular basis.

4. Monitoring and Alerting:
- Implement monitoring for model performance and data drift.
- Set up alerts for unexpected changes in model outputs or data quality issues.

By leveraging these tools, you can create a robust, automated MMM pipeline that continuously provides insights for your marketing strategies.

For more information on these tools, visit:
- Docker: [https://www.docker.com/](https://www.docker.com/)
- MLflow: [https://mlflow.org/](https://mlflow.org/)


## How to get started?

To see how all these different components come together, you can review the {ref}`MMM Example notebook <mmm_example>`.
1 change: 1 addition & 0 deletions docs/source/guide/mmm/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ To add more substance to our session and ensure it's not just informative but al
* Juan Orduz: [Media Effect Estimation with PyMC: Adstock, Saturation & Diminishing Returns](https://juanitorduz.github.io/pymc_mmm/)
* Juan Orduz: [Media Mix Model and Experimental Calibration: A Simulation Study](https://juanitorduz.github.io/mmm_roas/)
* Dr. Robert Kübler: [Convenient Bayesian Marketing Mix Modeling with PyMC Marketing](https://towardsdatascience.com/convenient-bayesian-marketing-mix-modeling-with-pymc-marketing-8b02a9a9c4aa)
* Ryan O'Sullivan, [Is Multi-Collinearity Destroying Your Causal Inferences In Marketing Mix Modelling?](https://towardsdatascience.com/is-multi-collinearity-destroying-your-causal-inferences-in-marketing-mix-modelling-78cb56017c73)

### Tutorials

Expand Down
4 changes: 0 additions & 4 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ mmm = MMM(

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.

<center>
<img src="/docs/source/_static/mmm_plot_plot_channel_contributions_grid.png" width="80%" />
</center>

Explore a hands-on [simulated example](https://pymc-marketing.readthedocs.io/en/stable/notebooks/mmm/mmm_example.html) for more insights into MMM with PyMC-Marketing.


Expand Down

0 comments on commit 40dee1d

Please sign in to comment.