README.mdsrc/projects/promotion-simulator/modelling/README.md
Read only

Seasonal range response baseline

The LSKD reference case is an imagined promotion for a 12-product seasonal range. A marketer can use this baseline to see which audiences might benefit from a range overview, a style and fit guide, a short text or waiting. Build the two CSVs in the data preparation guide first. Then run from the project directory with Python 3.11 or later.

python3 modelling/plan_campaign.py "$demo_dir/current.csv" "$demo_dir/training.csv" \
  --randomized-history wave-1 --randomized-history wave-2 > "$demo_dir/seasonal-plan.json"

The report shows channel and audience counts, the estimated change in kept orders versus waiting, and an equal-volume broad email comparison. Absolute conversion estimates use only the contacts for whom both plans and the wait rate can be estimated. The report shows those denominators. Its small set of named audiences and message angles are fixed baselines for testing the later clustering and brief interpretation.

How it decides

The planner finds previous assignments for contacts with the same behavioural group, decision context and set of opted-in channels. The three decision contexts are routine, behaviour-triggered and limited-time. Each comparison requires assignment to the message and to waiting from a common set of eligible options. It reweights by the recorded assignment probabilities, keeps failed deliveries in their assigned arms and counts repeat appearances by contact when assessing sample size. An incomplete or sparse comparison supplies no effect estimate. Each estimate includes arm counts, campaigns and an approximate historical interval. The interval describes sampling uncertainty in those campaigns. It leaves open how well their outcomes transfer to the new range.

A proposed send has positive estimated value after subtracting the assumed contact cost. Change the order value, costs, contact cap and total sends with CLI options listed in --help. The planner picks one action per contact and builds a broad range email with the same number of sends. It checks observed purchase, opt-in, serviceability and recent delivered contact counts before proposing a send. An unresolved basket requires confirmed stock for an SMS. Routine SMS is also a candidate for opted-in groups with a comparable prior history. Use --limited-time only for a brief with a genuine deadline. The planner flags a proposal for a trial if the historical interval leaves open whether it beats waiting or another eligible message after costs.

The --randomized-history flag is an analyst's confirmation of both random assignment and relevance to this brief. A probability column alone cannot establish either. The baseline requires exactly matched retailer, category and outcome windows. The CSV adapter can receive data from other CRMs via the shared contract. Applying this scoring baseline to other campaigns also requires mapping their tested messages to the baseline angles and reviewing comparability. The plan uses basket stock for SMS and still needs current product availability checked before using any suggested angle in copy.

Replay the held-out wave

python3 data-prep/build_snapshots.py "$demo_dir/canonical.sqlite" "$demo_dir/wave-2-snapshot.csv" \
  --campaign wave-2 --as-of 2026-03-24T00:00:00Z --training "$demo_dir/prior-training.csv"

python3 modelling/plan_campaign.py "$demo_dir/training.csv" "$demo_dir/prior-training.csv" \
  --randomized-history wave-1 --holdout wave-2 > "$demo_dir/holdout.json"

The exercise fits on outcomes available before wave 2 and then estimates the two policies' kept-order rates using that wave's randomized assignments. Each policy gets credit for an observed kept order when it agrees with the logged assignment, weighted by the inverse assignment probability. The difference interval uses paired contributions from the same contacts. The replay needs complete labels and probabilities for the evaluated population.

With the default synthetic seed, wave 2 estimates 2.4% kept-order conversion for the targeted plan and 2.8% for a broad email with the same send count. The difference of −0.39 percentage points has an approximate 95% interval of −2.43 to +1.66 percentage points. The one-wave comparison leaves the policy advantage unresolved. A forecast on the new seasonal range is an extrapolation from those earlier campaigns.

This slice evaluates one decision per contact. The basket reminder reflects recent shopping behaviour. Estimating the effect of a full email followed by SMS sequence requires history on the outcomes of those sequences.