# Likely buyers or persuadable buyers: a propensity model against an uplift model on real e-mail tests

A marketing team often sends an offer to the customers a model rates likeliest to buy. Some of those customers would
have bought anyway, so the send adds little for them. This study measures how much of a send's added purchases the
likeliest buyers actually hold, on a randomized e-mail test where some customers got no e-mail. It compares that list
with one ranked by an uplift model, which estimates how much the e-mail changes each customer's chance of buying.

What it found, on 64,000 customers of one retailer (MineThatData e-mail test): the propensity model ranks buyers
modestly well (AUC 0.655, interval 0.611 to 0.704, fitted on the 21,306 customers who got no e-mail, 122 of whom
bought). Its top 30% held 40% of the added purchases from the Mens e-mail and 11% of those from the Womens e-mail,
where a random 30% holds 30%; the gap between the two e-mails has a 95% interval of 4 to 74 points. In that top 30%,
customers with no Womens e-mail bought at 90% of the rate of those mailed. The uplift model's top 30% held 26% and
52%, and for the Womens e-mail it reached 1.6 added purchases per 1,000 customers against 0.3 (gap 0.1 to 2.6). The follow-up on another, larger test (a one-in-four sample of the
Criteo uplift dataset, 3,494,359 users) could not tell the two lists apart: 90% and 89%. Money figures rest on an assumed margin
and cost per send, set out in `protocol-r1.json` and scaled to a list by `assumptions.json`.

## Data

- Kevin Hillstrom's MineThatData E-Mail Analytics and Data Mining Challenge dataset: 64,000 customers randomized to a
  Mens e-mail, a Womens e-mail or no e-mail, with a visit, purchase and spend over the next two weeks.
- Criteo uplift prediction dataset v2.1 (Diemert, Betlei, Renaudin, Amini), CC BY-NC-SA 4.0, from the publisher's
  Hugging Face page: 13,979,592 users, 85% treated, with twelve anonymised features, a visit and a conversion.

`data/sources.json` has each URL, sha256, size, row count and terms. Neither dataset is copied into this folder.

## Rebuild

From this folder, with Python 3.12, NumPy 2.5, scikit-learn 1.9, pandas 3.1, PyArrow 26 and DuckDB 2.0:

    python3 -I -B tools/get_data.py ~/.cache/propensity-versus-uplift
    python3 -I -B tools/fit_scores.py hillstrom ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores
    python3 -I -B tools/fit_scores.py criteo ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores
    for s in 1 2 3 4; do python3 -I -B tools/fit_scores.py hillstrom ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores --seed $s; done
    python3 -I -B tools/evaluate.py hillstrom ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores
    python3 -I -B tools/evaluate.py criteo ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores
    for s in 1 2 3 4; do python3 -I -B tools/evaluate.py hillstrom ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores --seed $s --points-only; done
    python3 -I -B tools/after_results.py ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores
    python3 -I -B tools/score_predictions.py
    python3 -I -B tools/change2.py ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores
    python3 -I -B tools/cutoff.py ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores
    python3 -I -B tools/cutoff_policy.py ~/.cache/propensity-versus-uplift ~/.cache/propensity-versus-uplift/scores
    python3 -I -B site/render.py
    python3 -I -B tests/test_study.py

The first command downloads both files (about 4 MB and 311 MB), checks each against its sha256 and writes the Criteo
sample as Parquet. The fits use five folds split within each arm, so every score is made by a model that never saw
that customer. The Criteo fit and evaluation need about 1.5 GB of memory.

## Files

- `index.html`, `results.html`, `followup.html`, `method.html`: the pages.
- `DESIGN-r1.md`, `protocol-r1.json`, `predictions-r1.json`: the design, declared before any model was fitted. The
  margins and costs per send are in the protocol.
- `assumptions.json`: the list size (100,000 customers) that scales the money figures, set after the
  results.
- `tools/change2.py`: a further analysis, declared after the first results and before its code: how large a
  holdout the check needs, each sending policy's net with an interval, and the spend rule against the model.
- `tools/cutoff.py`: a follow-up added after the results and declared before its code: the propensity score at which
  a send pays at an assumed margin and cost, and what the send added above it.
- `tools/cutoff_policy.py`: the same cut-off, and one set on the margin an uplift model predicts a send adds, run as
  mailing policies against mailing everyone and last year's spend, with intervals; declared before its code and
  computed after the results.
- `results/`: every result file the pages read. `after-r1.json` holds the analyses added after the results, and
  `change2-r2.json` the results of the further analysis with its four predictions scored, `cutoff-r3.json` the
  cost cut-off with its three, and `cutoff-r4.json` the cut-offs as mailing policies with their three, each labelled
  so wherever a page shows it.
- `tools/`, `tests/`, `site/`: the code, the tests and the page builder.
- `vendor/`: the design system's files, copied unedited from one pinned release.

Some files are packed in propensity-versus-uplift-data-1.zip; unzip it here to restore the full export, which the manifest lists file by file.
