Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Data Analytics for Marketing

You're reading from   Data Analytics for Marketing A practical guide to analyzing marketing data using Python

Arrow left icon
Product type Paperback
Published in May 2024
Publisher Packt
ISBN-13 9781803241609
Length 452 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Guilherme Diaz-Bérrio Guilherme Diaz-Bérrio
Author Profile Icon Guilherme Diaz-Bérrio
Guilherme Diaz-Bérrio
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Part 1: Fundamentals of Analytics
2. Chapter 1: What is Marketing Analytics? FREE CHAPTER 3. Chapter 2: Extracting and Exploring Data with Singer and pandas 4. Chapter 3: Design Principles and Presenting Results with Streamlit 5. Chapter 4: Econometrics and Causal Inference with Statsmodels and PyMC 6. Part 2: Planning Ahead
7. Chapter 5: Forecasting with Prophet, ARIMA, and Other Models Using StatsForecast 8. Chapter 6: Anomaly Detection with StatsForecast and PyMC 9. Part 3: Who and What to Target
10. Chapter 7: Customer Insights – Segmentation and RFM 11. Chapter 8: Customer Lifetime Value with PyMC Marketing 12. Chapter 9: Customer Survey Analysis 13. Chapter 10: Conjoint Analysis with pandas and Statsmodels 14. Part 4: Measuring Effectiveness
15. Chapter 11: Multi-Touch Digital Attribution 16. Chapter 12: Media Mix Modeling with PyMC Marketing 17. Chapter 13: Running Experiments with PyMC 18. Index 19. Other Books You May Enjoy

A synthetic data example of MMM

First, we’ll begin with the necessary imports and setup:

import warnings
import arviz as az
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pymc as pm
import seaborn as sns
from pymc_marketing.mmm.transformers import geometric_adstock, 
    logistic_saturation
from pymc_marketing.mmm.delayed_saturated_mmm import 
    DelayedSaturatedMMM
warnings.filterwarnings("ignore")
az.style.use("arviz-darkgrid")
plt.rcParams["figure.figsize"] = [12, 7]
plt.rcParams["figure.dpi"] = 100
%load_ext autoreload
%autoreload 2
%config InlineBackend.figure_format = "retina"

Synthetic data generation

Let’s generate some synthetic data to test the model. We will generate data for two media channels, with adstock and saturation effects, and a trend and seasonality component. We’ll start by generating a DataFrame containing weekly...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime