learntodriveai.dev/Data Science/Causal Inference: Loyalty Program Evaluation
Data Science·Project 09·7 units

Causal Inference: Loyalty Program Evaluation.

**Track:** Data Science

§ 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 presents it as the answer. It does not adjust for self-selection. It constructs DAGs that omit critical confounders because it reasons from variable names, not from understanding of why people behave the way they do. 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