learntodriveai.dev/Data Science/Causal Inference: Loyalty Program Evaluation
Data ScienceProject 097 unitsVerified on 16 October 2026

Causal Inference: Loyalty Program Evaluation

Gabriela DominguezVP of Marketing and Customer Strategy · Supermarket chain · Mexico City, Mexico
Meeting transcript · from Gabriela
Did Fresco Rewards actually cause people to spend more, or did we just give a discount card to people who were already loyal? And if there IS a real effect, how big is it really?
Chat with Gabriela

What you hand back

  • A naive comparison with its 35% gap
  • A causal diagram with confounders named
  • A matched estimate of the program's effect
  • Refutation tests run against the estimate
  • Effects broken out by customer segment
  • Findings summary with limits and recommendation

7 units

  1. Unit 1: The meeting and the question

    Set up the project, read the kick-off transcript, and settle what question Gabriela is really asking.

    Open unit 1
  2. Unit 2: The naive comparison

    Compute the 35% gap between members and non-members, then compare their spending before the program began.

    Open unit 2
  3. Unit 3: The causal model

    Draw the causal diagram, build the propensity model, check balance, and review the marketing team's earlier attempt.

    Open unit 3
  4. Unit 4: The causal estimate

    Estimate the program's effect on members with matching, then compare it with the naive number.

    Open unit 4
  5. Unit 5: Refutation testing

    Run placebo, random cause, and data subset tests to try to break the estimate.

    Open unit 5
  6. Unit 6: Polars and preparation depth

    Prepare per-customer inputs with Polars and build separate propensity models for each shopper segment.

    Open unit 6
  7. Unit 7: Honest evidence for Gabriela

    Draft the findings, restore the naive comparison and limits, and send Gabriela a recommendation.

    Open unit 7
Read the full brief

A regional supermarket chain in Mexico is convinced its loyalty program made members spend more. You build a causal inference analysis to find out whether the program actually caused the increase -- or whether the company just handed a discount card to people who were already its best customers.

The discipline skills: constructing a causal DAG, identifying confounders with domain knowledge, building a propensity score model with DoWhy, estimating treatment effects, running refutation tests designed to break your own claim, and communicating the difference between a naive comparison and a causal estimate.

The AI-direction lesson: AI computes the naive comparison -- members spend 35% more -- and may present it as the answer, or hedge it and still stop short of an estimate. A current model often names self-selection unprompted; the work that stays yours is the number, the confounder list and the method. Its DAGs reason from variable names, not from understanding of why people behave the way they do, so they place or omit rollout-specific variables differently from run to run. It writes "the program increased spending" when the method only established association. The skill is catching AI's causal language -- every time AI presents correlation as causation, you correct it. The gap between the naive comparison and the adjusted causal estimate is the distance between what AI produces by default and what the analysis actually shows.

Your Role

You deliver the honest answer to a causal question. You own the entire analytical approach -- no methodology guide. You discover the question through conversation, design the analysis, build the causal model, test whether it holds, and communicate the findings honestly.

What's New

Last time, you connected Claude Code to a DuckDB database via MCP and experienced the capability shift of AI reading data directly. You verified data paths -- checking that AI queried the right tables with the right filters.

This time, the shift is conceptual. Causal inference enters. You will construct a DAG, identify confounders using domain knowledge, build a propensity score model, estimate a treatment effect, and run refutation tests designed to break your own claim. AI computes naive comparisons by default -- it reports the 35% as though it were the answer. Your job is to catch that and produce the honest number.

The hard part is the gap between what looks right and what is right. The naive comparison looks like an answer. The causal estimate is the answer. The distance between them is what makes this project matter.

Tools

  • Python 3.11+ via your conda "ds" environment
  • Jupyter Notebook for the analysis
  • pandas for data handling
  • Polars -- an alternative DataFrame tool for preparation-heavy work (new)
  • DoWhy -- a causal inference library (new)
  • statsmodels and scipy for statistical analysis
  • matplotlib / seaborn for visualization
  • DuckDB and DuckDB MCP server (carry-forward from last time)
  • Claude Code as the AI you direct
  • Git / GitHub for version control

Materials

You receive:

  • Transaction data covering 14 months post-launch and 6 months pre-launch -- purchases, store locations, member status, enrollment dates, demographics
  • A data dictionary describing the dataset
  • The marketing team's earlier in-house analysis memo (reviewed in Unit 3)
  • No methodology templates, no analysis guides, no communication templates
Materials · 4 files
Start Project 9

You work at a computer with a terminal. Signed in, your place is saved.