Causal Inference for Real-World ML: Uplift Modeling, Counterfactuals, Treatment Effects & LLM Integration

Episode 6 68 min

Aleksander Molak Independent machine learning researcher

Episode 6 · Causal Inference for Real-World ML: Uplift Modeling, Counterfactuals, Treatment Effects & LLM Integration

68 min

What we talked about

Aleksander Molak is a machine learning researcher, educator and consultant who has designed large-scale ML systems for companies in Europe, the United States and Israel. He is the author of Causal Inference and Discovery in Python and works on bringing causal thinking to practitioners. Alexey invites him to explain why causality matters for machine learning, and the conversation moves from predictions to decisions, counterfactuals and the uplift models used in marketing.

Aleksander explains that most machine learning models learn associations, which can mislead when a hidden variable drives both sides of a correlation. His standard example is ice cream sales and drownings, which are both driven by temperature. Predictive models can work well for prediction, but decisions need counterfactuals, such as what a customer would have done without a campaign. He recalls that Zillow's house-buying model failed when the market changed, because machine learning models assume that new data looks like the training data. A T-learner, which trains one model on treated customers and one on untreated customers, estimates the conditional average treatment effect. Targeting then goes only to customers whose predicted outcome improves with the campaign. Aleksander says that the estimates are only trustworthy when the data is unconfounded, which requires a randomized experiment or careful causal feature selection.

A listener asks how to evaluate these models. Aleksander separates three levels: whether the causal assumptions hold, whether the policy beats a baseline using a business metric, and whether the estimators are accurate. Traditional cross-validation alone does not reveal causal bias. He recommends deploying to part of the customer base and comparing against a baseline, and he mentions refutation tests, which can falsify a causal model but never prove it correct. He also says that causal models add complexity, so teams should decide whether a decision problem justifies the extra model. A colleague's analysis showed that a company's marketing had lost money for three years, which Aleksander cites as a reason to examine causal models.

On LLMs, Aleksander describes text as an outcome, a treatment or a confounder in an experiment. A model can score the clarity of essays written after a workshop, or extract style from marketing copy. He also mentions using an LLM as a feature extractor for unobserved factors, while noting that labeling those factors is difficult.

For further reading, he recommends The Book of Why by Judea Pearl as a starting point, and his own book for practical Python examples, aimed at people with three to five years of experience.

Chapters

  1. 1:22 Guest Intro: Aleksander Molak & book overview 1 min
  2. 2:06 Career highlights and dyslexia prediction project 4 min
  3. 6:15 Causal advocacy: democratizing causal thinking 1 min
  4. 7:31 Association vs causation: limits of correlational reasoning 1 min
  5. 8:55 Illustrative confounders: race example and ice cream–drowning 4 min
  6. 12:41 Predictive ML vs decision-making: Zillow and IID assumptions 3 min
  7. 15:36 Counterfactuals in practice: marketing and recommender systems 3 min
  8. 18:15 Counterfactuals defined and Judea Pearl’s intervention view 3 min
  9. 21:22 Meta-learners overview: T-learner and counterfactual estimation 3 min
  10. 24:24 Conditional Average Treatment Effect (CATE) estimation 2 min
  11. 26:16 Achieving unconfoundedness: A/B tests vs causal feature selection 2 min
  12. 27:52 Targeting decisions from uplift estimates 1 min
  13. 29:17 Deployment risks and debiasing estimators (double/triple ML) 3 min
  14. 32:40 Uplift modeling: policy evaluation and business metrics 1 min
  15. 33:14 Evaluating causal models: refutation tests and estimator quality 4 min
  16. 37:37 Causal discovery and heterogeneous treatment effects (book coverage) 1 min
  17. 38:54 Cost–benefit of causal models: complexity vs value 2 min
  18. 41:14 Real-world impact: discovering wasted marketing spend 2 min
  19. 43:25 Incremental rollout: A/B testing as validation baseline 1 min
  20. 44:26 LLMs in causal workflows: feature extraction and scoring 2 min
  21. 46:54 Text as outcome: using LLMs to score experimental text 2 min
  22. 49:17 Text as treatment/confounder: style extraction and embeddings 5 min
  23. 54:38 Inferring unobserved variables (e.g., gender/style) with LLMs 4 min
  24. 58:14 CausalBert demo and code note (PyData Berlin talk) 1 min
  25. 59:33 Causal ML without experiments: partial identification & sensitivity 4 min
  26. 1:04:03 Causal graphs and nonparametric identification: minimal observables 2 min
  27. 1:06:07 Recommended resources: The Book of Why, Molak’s book & GitHub 1 min
  28. 1:07:28 Closing remarks and next steps 1 min

Aleksander Molak Independent machine learning researcher

Aleksander Molak is an independent machine learning researcher, author, consultant, educator, and entrepreneur specializing in causality, natural language processing, and AI strategy. He helps practitioners and organizations apply causal inference, uplift modeling, and causal discovery to real world machine learning systems, and he is known for turning complex ideas into clear, practical lessons.

Topics in this episode

The wiki pages this conversation is filed under, the strongest first.

Causal Inference

Causal inference as reasoning about interventions, counterfactuals, and treatment effects.

LLMs

Large language models with links to retrieval, agents, evaluation, production, and security pages.

Machine Learning

Machine learning as applied modeling, evaluation, production design, monitoring, roles, and business tradeoffs.

A/A Testing

A/A testing for validating experiment assignment, tracking, and statistical interpretation before A/B tests are trusted.

A/B Testing

A/B testing as randomized product evaluation, with assignment, metrics, noise, power, and rollout decisions.

Evaluation

How teams judge whether ML, LLM, RAG, product, and production systems are good enough to trust.

Experimentation

Experiments for reducing product, ML, and organizational uncertainty before rollout.

Metrics

Metrics for product decisions, ML systems, monitoring, experiments, and business impact.

Power Analysis

Power analysis for estimating experiment sample size, duration, and detectable effect before teams read A/B test results.

Related books

Build a Large Language Model (From Scratch)

58 questions answered

In Build a Large Language Model (From Scratch), you'll learn and understand how large language models (LLMs) work from the inside out by coding them from the ground up, step by step. In this book, I'll guide you through creating your own LLM, explaining each stage with clear text, diagrams, and examples.

Sebastian Raschka

GPT-3

11 questions answered

GPT-3 has made creating AI apps simpler than ever. This book provides a comprehensive guide on how to utilize the OpenAI API with ease. It explores imaginative methods of utilizing this tool for your specific needs and showcases successful businesses that have been established through its use.

Sandra Kublik Shubham Saboo

Optional analytics

Optional analytics are off unless you allow them. Your choice does not affect access to DataTalks.Club, Slack, events, or courses.

Current choice: not chosen.

Privacy Policy

If you allow analytics, self-hosted Umami counts anonymous public pageviews without analytics cookies. Private account and learning pages are excluded. Read the Privacy Policy for the complete data boundary.

Want to learn more about our community?

How it started, who's here, and everything that goes on here: courses, events, Slack, and more.

About DataTalks.Club