Marketing Science in Python
A Practical Guide to Causal Inference, CLV, Pricing, Forecasting, and MMM
Preface

Draft version
Last updated: May 2026
Last month’s campaign drove a spike in sales, and the team is celebrating. But before we take the credit, it’s worth asking: was it really the campaign that made the difference?
Temperatures rose at the same time. A competitor ran out of stock. An influencer posted about our product on social media. Maybe one of these factors mattered more than we think, or maybe it was a mix of all of them. And even if sales went up, did the campaign actually bring in valuable new customers?
We handed out coupons and saw a bump in sales, but were we just pulling forward purchases that would have happened anyway? We spent millions on TV and CTV ads, but can we really call that a success?
Even in 2026, answering these questions directly is still hard. AI has made the creative side of marketing—generating ad copy, producing banners, building landing pages—much faster. But when it comes to measurement and decision making, questions like “Did it work?” and “What should we do next?” are still tough. This is where human judgment matters most.
This book is a practical guide for working on that frontier. I’ll show you how to use tools like causal inference, Marketing Mix Modeling (MMM), pricing analysis, and Customer Lifetime Value (CLV) analysis to make marketing decisions more reliable, even when the data is messy. We’ll cover both the theory and the code, always with an eye on what actually helps in practice.
Who This Book Is For
This book is mainly for data scientists, analysts, and engineers who know the basics—statistics, Python, some machine learning—but haven’t yet applied those skills to real marketing problems.
Each chapter comes with Python code and notebooks. The idea is for you to get hands-on as you go, so you can apply these techniques to your own data right away.
I also wrote this for technically-minded business professionals—marketers, product managers, and executives. You can skip the formulas and code if you want. If you focus on the problem framing at the start of each chapter, you’ll still get the key analytical thinking and decision-making frameworks.
Structure of This Book
| Part | Theme | Contents |
|---|---|---|
| 1 | The Big Picture of Marketing Science | Definition, how it differs from general DS, industry characteristics |
| 2 | Analysis for Better Decisions | Analysis design, business questions, KPI trees, storytelling (SCR) |
| 3 | Causal Inference | A/B testing, quasi-experiments, causal machine learning, Uplift Modeling |
| 4 | Customer Analytics | Segmentation, CLV |
| 5 | Commercial Analytics | Price elasticity, assortment optimization, demand forecasting |
| 6 | Media Investment and Optimization | Attribution, MMM, budget optimization |