Causal Uplift Targeting: Measure a Promotion, Then Spend It Wisely

Analyse a randomized promotion experiment end to end: check that the randomization held, estimate the coupon's average effect on net margin with CUPED and regression adjustment, estimate who benefits with four meta-learners and a hand-written two-headed neural network, judge them on held-out randomized data, value targeting policies with doubly robust estimates before running them, and hand over a traceable decision memo, an MLflow-registered model and a FastAPI scoring service with a strict input contract. Synthetic data with known true effects lets every method be checked against the truth.

AI & Data Scientist. Advanced.

What you will build and explain

  • Run health checks that stop an unsound experiment: sample ratio mismatch, covariate balance, a placebo test and feature availability before assignment.
  • Estimate an average treatment effect by intention to treat with honest intervals, reduce its variance with CUPED and Lin's regression adjustment, control several metrics with Holm's correction and test a guardrail for non-inferiority.
  • Estimate heterogeneous effects with S-, T-, X- and DR-learners and a two-headed network trained by hand, choose one by the doubly robust value of its policy on a validation fold, and evaluate it once on a test fold with Qini curves, deciles and calibration.
  • Value targeting policies off-policy with inverse propensity weighting and doubly robust estimates, report who a policy targets by protected group, and recognise leakage and selection effects that inflate offline metrics.
  • Record every stage in MLflow, register the chosen model with a generated model card, serve it behind a validating FastAPI service, and release and roll back through a registry alias.

Before you begin

  • Python with NumPy and pandas, basic SQL, and using a terminal, Git and Make
  • Introductory statistics (standard errors, confidence intervals, p-values) and machine learning basics (train, validation and test splits, overfitting, gradient-boosted trees)
  • A computer running Linux (x86_64 or arm64), macOS on Apple silicon, or Windows with WSL 2, with Python 3.12 or 3.13 and Docker with Compose v2, about 4 CPU cores, 8 GB of memory and 6 GB of free disk

Who this is for

For data scientists and analysts who already build predictive models and want to measure what a promotion really caused, estimate who benefits and choose who to target with evidence that survives review.

Curriculum

Learning topics (18)
  1. Check your starting skills and prepare your computer

    This project assumes you can already build an ordinary predictive model. It teaches the experimentation and causal methods on top. Check the list below honestly: each item is used without explanation later, and each has a short way to fill the gap.

  2. Follow the data from warehouse exports to a targeting decision

    This project answers four questions about Fernhill Market's coupon experiment: did the coupon raise net margin, for whom, how sure are we, and which customers should get it next quarter when the budget covers one in five. The system that answers them has three parts:

  3. Randomization, intention to treat and potential outcomes

    Before computing anything, be precise about the question. "Did the coupon work?" can mean several different things, and only one of them is answered by this experiment.

  4. From warehouse exports to one row per customer

    An analysis is only as trustworthy as the table it starts from. Most experiment errors found in practice are not statistical: a join that duplicated customers, a window that included the day before the launch, refunds counted as sales. This lesson builds the analysis table and the checks that stop a broken delivery before anything is estimated.

  5. Is this experiment safe to analyse?

    An effect estimate inherits every flaw of the randomization behind it. A treatment arm that quietly lost a few thousand customers, or a model feature recorded after the coupon was sent, will produce a confident, precise and wrong number. Nothing in the effect estimate itself warns you.

  6. The average effect, with honest uncertainty

    Finance asked one question: did SPRING8 make money? This lesson answers it for the whole population, three ways, and explains why the three answers differ. Along the way it covers the standard error behind every interval in the project, variance reduction with CUPED and regression adjustment, more than one metric at a time, and a guardrail that must not get worse.

  7. Plan the next test, and why daily peeking lies

    The marketing team wants to run another coupon test next quarter, and they want a dashboard that shows the result every morning. Two questions follow. How many customers does the test need to detect an effect worth acting on? And is it safe to look at the result every day and stop as soon as it is significant?

  8. Meta-learners and cross-fitting

    The average effect is 50 pence per customer, but nobody is an average customer. A price-sensitive shopper who was about to place a large order might earn the business several pounds more with the coupon; a loyal customer who would have bought the same basket anyway costs £8.00 and earns nothing extra. If the coupon went only to customers of the first kind, it could be worth far more than 50 pence per customer sent.

  9. A two-headed network trained by hand

    Deep learning libraries make a network a few lines of code, and they also hide every step that can go wrong. This lesson's network is written in NumPy: the forward pass, the gradient of the loss for every weight, the optimizer and the stopping rule are all visible and testable. The aim is not to beat the tree learners (it does not, here) but to understand exactly what a training loop does, how to check it is correct, and why a flexible model is not automatically a better effe

  10. Judge effect estimates on held-out randomized data

    A churn model can be scored by comparing its predictions with who actually churned. An effect model cannot: no customer's true effect is observed, so there is no column of right answers to compare with. This lesson shows what can be measured instead, why it must be measured on customers who played no part in building or choosing the model, and how noisy even an honest evaluation is.

  11. Spend the budget, and value the decision before making it

    Next quarter's budget covers sending SPRING8 to one customer in five. Marketing has its own candidate rules: send it to the top spenders, or to customers who seem to be lapsing. The model offers another. Which one should the business run?

  12. Clusters, groups and responsible targeting

    Two questions follow every targeting model into a business review. Marketing asks: "Which kinds of customers is it picking? Can we describe them as segments?" Legal and leadership ask: "Is it treating any group of customers very differently, and should it?" This lesson answers both from the policy stage's results, and shows why the first question's most common answer, k-means clustering, describes customers rather than effects.

  13. Track, register and serve the model

    Six weeks after the analysis, someone asks: "The model the campaign tool is calling, which data was it trained on, which learner is it, and what threshold does it use?" If the answer depends on someone's memory or a notebook on a laptop, the analysis cannot be audited or repeated. This lesson covers the three pieces that make the answer a lookup: experiment tracking, a model registry, and a scoring service that accepts only the input the model was built for.

  14. Write the conclusion, including what you do not know

    Everything so far produces numbers in metrics.json. The people who decide next quarter's campaign will read none of them. They will read one page, and the quality of that page decides whether the analysis changes anything. This lesson covers what the memo says, how it is generated so that it cannot drift from the results, and how to write what the analysis does not know.

  15. Run the analysis and the lab

    This guide runs the whole project in order. Milestones 1 to 6 run the analysis on your computer, one stage at a time, so you can read each stage's results as the matching lesson explains them. Milestones 7 and 8 run the same pipeline in containers, with an MLflow tracking server and the scoring service, and practise a release and a rollback. Cleanup removes everything.

  16. Diagnose wrong numbers, not just errors

    Most failures in this project do not crash anything. The pipeline finishes, the memo is written, the service answers, and a number is wrong: an effect inflated by a broken randomization, a model that looks better because of a leaked feature, a scorer serving a version nobody meant to release. The skill this lesson practises is noticing that a successful run can still be wrong, and finding out why from evidence rather than intuition.

  17. Defend the analysis in an interview

    Interviews for data science roles rarely ask you to recite a formula. They ask you to walk through an analysis, defend a choice when a constraint changes, and say what you would check when a number looks wrong. This project gives you a concrete analysis to talk about, with real trade-offs: an exposure log you chose not to use, an estimate you adjusted, a learner you kept although the test fold seemed to prefer another, a feature you refused, and a recommendation that depends

  18. Remove the lab and check for leftovers

    Everything this project creates lives in two places: files under the source folder, and Docker objects labelled with the Compose project name fernhill. Nothing is created in any cloud account, and nothing outside those two places is changed. This page removes both, in an order that never leaves something unremovable, and shows how to confirm nothing is left.

Practical build steps (9)
  1. Install the tools and run the local checks

    This milestone gets your computer ready and proves the code works on it before any data exists. You start with the source folder and finish with a Python environment in .venv/, a clean lint run and a passing test suite.

  2. Generate the experiment and check it

    This milestone creates the data and decides whether it can be trusted. You start with an empty data/ folder and finish with seven warehouse exports, the oracle of true effects, an analysis table with one row per assigned customer, and a health-check result that says the experiment is safe to analyse.

  3. Estimate the average effect and plan the next test

    This milestone answers finance's question, whether the coupon made money on average, and plans the next test. You finish with three estimates of the average effect on net margin, the same for revenue and orders, the unsubscribe guardrail, and the power and peeking simulations.

  4. Fit and choose the effect learners

    This milestone estimates each customer's effect five ways and chooses one learner without looking at the test fold. You finish with every learner's estimates for validation and test customers, the chosen learner saved with its encoder, and the targeting threshold.

  5. Evaluate on the test fold and value the policies

    This milestone opens the test fold once. You finish with the chosen learner's Qini curve, deciles and calibration on customers it has never seen, a comparison with the true effects kept apart as a teaching note, and six targeting policies valued with intervals.

  6. Write the memo and register the model

    This milestone turns the results into the document the business reads and records the chosen model where a service can find it. You finish with runs/current/memo.md and its seven figures, the teaching note oracle_check.md, and version 1 of fernhill-uplift with the alias champion in the local MLflow store.

  7. Build the lab and run the pipeline in containers

    This milestone runs the pipeline the way a team would share it. You start with Docker running and ports 5000 and 8080 free, and finish with the image fernhill/uplift:1.0.0, an MLflow tracking server on http://127.0.0.1:5000 holding a full pipeline run, and version 1 of the model registered there.

  8. Serve, verify, release and roll back

    This milestone puts the model behind an API and practises changing which model it serves. You start with the tracking server and a registered model, and finish with the scoring service on http://127.0.0.1:8080, a passing verification, and the experience of moving the champion alias forward to a new version and back again.

  9. Remove the lab and check for leftovers

    This milestone removes everything the project created. You start with the lab running, or partly running after an interruption, and finish with no fernhill containers, network or volume, ports 5000 and 8080 free, and, if you choose, the image and the local files removed.

Access

Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.

Cloud costs and boundaries

No cloud account or spending is needed: the analysis runs in a Python environment on your own computer and the lab runs as three containers there, using under 3 GB of memory while it runs and about 1.4 GB of disk for its image. GitHub Actions is optional; it is free on public repositories and uses your account's included minutes on private ones. The data is synthetic. This is a learning project, not a hosted environment or a production-readiness guarantee.

Licence and completion

Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. Third-party components, such as NumPy, pandas, SciPy, scikit-learn, DuckDB, MLflow, FastAPI and pytest, retain their own licences. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.

Questions about projects

Do I need a cloud account?

You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.

Can I read the code with Learning Access?

Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.

Are cloud charges included?

No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.

Does the project include troubleshooting and interview preparation?

The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.

How long can I use the project?

The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.

Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy