SCALED_HISTORY.mdsrc/projects/promotion-simulator/SCALED_HISTORY.md
Read only

Scaled promotion history and evaluation

This run asks whether a marketing team should vary email, SMS and waiting for an ordinary second push of a recently released range. The calendar provides dated campaign examples. Shopping, consent, stock, offer response and all projections are synthetic.

Reproduce the run

From the project directory, install the pinned DuckDB dependency, then generate the calendar and history into new local paths.

work_dir=$(mktemp -d)
python3 -m venv "$work_dir/venv"
. "$work_dir/venv/bin/activate"
python -m pip install -r data-prep/scale/requirements.txt
python data-prep/generate_campaign_calendar.py "$work_dir/calendar.json"
python data-prep/scale/generate_history.py "$work_dir/calendar.json" "$work_dir/pilot" --profiles 100000
python data-prep/scale/audit_history.py "$work_dir/pilot"

The generator appends one calendar decision and one month of background activity at a time. It writes month-partitioned Parquet for the larger event and decision tables, campaign metadata and a focal planning snapshot. The DuckDB work file is temporary. The JSON readout includes row counts, disk size, runtime, peak memory and evidence coverage. Use the same command with a new output directory and --profiles 1000000 for the scale benchmark, or --world weak_sms for a history with smaller or negative incremental SMS effects. Use Python 3.11 or later on an environment with IANA time-zone data. The memory figure is peak resident memory, normalized to MiB on Linux and macOS.

What the data can answer

ProblemHow this fixture handles it
High purchase rates among SMS subscribers can be mistaken for an effect of sending a text.SMS opt-in is correlated with organic buying intent. Most scheduled sends follow ordinary marketing rules and carry blank assignment probabilities. In experimental episodes, assignment is uniform over the contact's feasible options, including an explicit no-message assignment. The estimator uses the randomized records and compares assigned options even when deliveries fail.
A customer can get several campaigns in a week, which makes a channel test hard to interpret.Available permissions, recent contact pressure, stock and already-purchased exclusions apply before assignment. The replay prevents further promotional decisions for seven days after any randomized assignment, including wait. The estimand applies to the opportunities remaining under that quiet period.
A purchase from another collection can make a campaign look successful.The primary label is buying a SKU from the featured collection within seven days and retaining a line through the simulated return window. Full refunds remove a line. A simulated exchange retains it if the replacement stays in the collection. We use when stock, orders and consent became visible for decision features. The focal range has early shopping and orders and remains unassigned.
Campaigns drift over time and members appear in multiple experiments.Training uses routine range follow-ups with mature labels before the six-month holdout starts. Whole campaign episodes stay together. Action cells require at least 100 effective contacts per arm and three historical episodes. The holdout compares the fixed audience policy with broad overview email at equal sends per campaign. Supported cells pool only equivalent contact eligibility and context.
A large contact count can hide a small sample of independent campaigns.Report held-out episodes and estimates by episode. The aggregate uncertainty calculation accounts for shared contacts and campaign episodes when at least eight episodes are available. With fewer episodes the report omits an aggregate interval. Historical intervals for individual action cells are approximate and leave transfer to the focal range open.

The primary comparison uses the inverse logged assignment probability to estimate the two policies on the same eligible decisions. Contact costs are one and eight simulated cents for email and SMS, respectively. The economic readout assumes A$35 contribution per additional kept order. The report includes opt-outs as a separate outcome. Neither contact costs nor contribution are estimates for LSKD.

Issue found during development

The first 100,000-profile run had 270 materially imbalanced campaign and eligibility arms. DuckDB's multi-column numeric hash produced correlated draws when adjacent values represented reach, assignment and outcome. On a 100,000-key preflight, correlations were approximately −0.60 for reach versus assignment, −0.97 for browsing versus assignment, and −0.90 for assignment versus response. The initial run's estimates are invalid.

The generator now hashes each stream identifier before mixing it with the account or order key. It checks that those three correlations stay below 0.02 in absolute value before generating any output. The export audit also compares empirical arm counts with the expected counts within each campaign, eligibility set and decision context. It checks consent, contact caps, duplicate assignments, seven-day overlap, purchase and return links, campaign split and the focal purchase gate.

Stock checks for purchases and exchanges also became a runtime bottleneck. The pipeline uses a DuckDB as-of join to find the last inventory record at the transaction time. Decision history counts use the collection of the primary order line, which is verified against the item ledger. Both changes avoid repeatedly joining and sorting the same fact tables for every campaign.

100,000-profile pilot

The corrected seed-24 run generated 6,557,985 shopping events, 254,153 orders, 631,860 paid lines and 2,052,669 attempted sends across 30 months. It exported 45.6 MiB of Parquet in a 104-second local run, including generation and evaluation, with 1.74 GiB peak process memory. All 13 export audit checks passed. The audit found 107,216 shopping signals that reached the team after their decision cutoff. Reconstructed sampled decision features used only the signals available by that cutoff.

One audit trace follows synthetic contact 4620. They were assigned a range overview on 30 July 2024, placed an order for that collection after the send, and were excluded from its 13 August follow-up because the purchase was already visible. A refund arrived on 23 August. The follow-up gate prevented an extra message given the information at the time. The later refund is available when assessing the kept-order outcome.

On 62,014 randomized range-follow-up decisions across four mature held-out episodes, the fixed targeting policy estimated 4.39% kept-order conversion versus 4.00% for broad email, with 55,138 sends per policy. Estimated opt-outs were 0.190% versus 0.174%. The episode-level differences ranged from +0.06 to +0.76 percentage points. Some accounts appeared in multiple episodes. Four episodes fell below the configured minimum for an aggregate interval. Treat the point estimates as fixture diagnostics. The modeled net value is conditional on the assumed A$35 per additional kept order and excludes a monetary cost for opt-outs.

At the fictional focal brief, 26,481 contacts passed the current eligibility gates. The rule-based plan flagged 1,022 in-stock basket reminders and 4,366 first campaign texts for repeat shoppers. Both SMS groups were trial candidates. Across all channels the largest exclusions were the seven-day experimental quiet period and lack of marketing consent.

Stress test with weak SMS effects

The second 100,000-profile run uses the same calendar and seed with smaller or negative incremental SMS effects. It leaves SMS consent and its correlation with organic purchase intent in the simulation. All export checks passed. The policy proposed zero SMS sends for the focal brief, compared with 5,388 in the responsive world. The targeted kept-order rate on held-out decisions was 4.24% versus 4.01% for broad email, with 55,138 sends per policy and equal contact costs. This tests whether the pipeline can back away from SMS when simulated incremental value falls. It still uses four held-out episodes.

Million-profile benchmark

Measure100,000-profile pilot1-million-profile run
Shopping events6,557,98565,691,587
Paid orders254,1532,547,778
Paid order lines631,8606,324,697
Send attempts2,052,66920,519,202
Recorded marketing decisions2,364,33823,636,121
Exported Parquet45.6 MiB478.9 MiB
Build, evaluate and export104 seconds13 minutes 27 seconds
Peak process memory1.74 GiB3.33 GiB

The million-profile data used the same calendar and fixed rules. All 13 export checks passed. The audit found 1,067,746 shopping signals that arrived after their decision cutoff and no sampled features that used them. On the shared local machine with two DuckDB threads, building the focal snapshot during generation took 7.32 seconds. Applying the fitted policy to that snapshot took 0.56 seconds. These are local timings for the fixture.

On 618,599 randomized range-follow-up decisions, the fixed policy estimated 4.52% kept-order conversion versus 3.97% for broad email, with 550,724 sends each. Estimated opt-outs rose from 0.185% to 0.231%. The kept-order differences across the four held-out episodes were +0.48 to +0.64 percentage points. Scaling accounts increased the evidence within the same four campaign episodes, so the comparison remains below the threshold for the aggregate interval.

The run generated about 9.3 million randomized decisions. It samples experiments more heavily than the initial workload assumptions. Send attempts fall below the 30–60 million design estimate because the current replay uses one decision opportunity per brief and applies the contact cap, stock and quiet-period gates. The history produced 613,683 buyers in the preceding year and 671,198 contacts with at least one opted-in channel, above our starting assumptions of about 500,000 and 625,000. Those are calibration gaps in the simulated population. This benchmark establishes the workload size and does not calibrate behaviour to LSKD's customer records.

Audience clustering comparison

Install the optional analysis dependencies and compare the two segment representations on the same exported pilot.

python -m pip install numpy==2.3.5 scikit-learn==1.8.0
python data-prep/scale/compare_audiences.py "$work_dir/pilot" > "$work_dir/audience-comparison.json"

Five k-means groups use training-period purchase counts, distinct styles viewed, in-stock basket presence and recent contact counts by channel. Fit the scaler and centres on a deterministic sample of 20,000 training decisions. Carry the same fixed cost assumptions and evidence thresholds into both policies. The exploration holds actual send volume at 16,540 per policy across identical held-out episodes, with 30% of the email-eligible contacts as the budget per wave.

Audience methodEstimated kept-order rateAssumed send cost
Broad email3.710%A$165.40
Fixed rules4.149%A$555.72
Five clusters4.154%A$322.90

Clustering changed the purchase estimate by +0.005 percentage points versus the fixed rules, with mixed differences across episodes. It shifted which channels were proposed and lowered modeled contact cost. Four episodes and one response world give insufficient evidence to promote clustering over the rules. The comparison is exploratory because the pilot had already been read for data validation.

Scope

This fixture represents an Australian catalogue and customers. Stock is a binary history by SKU with simulated sell-outs and restocks. The generator does not model how a larger send would deplete quantities or take demand away from other customers. Each scheduled brief contributes a single historical decision opportunity per sampled account. The records include linked web and store orders and some anonymous web views.

Dates and offer patterns came from public evidence. Channel effects, eligibility policies, opt-out rates and costs were set for the simulation. The generator's campaign texts come from a small number of templates. Evaluating an LLM on those alone would mostly measure whether it recognises the same wording. The brief interpretation evaluation should use independently written briefs with confirmed fields, missing terms and conflicting instructions. Hold out families of offer mechanics and score material mistakes such as inventing a deadline, applying a discount to the wrong products or recommending a channel the brief excludes. Keep locked randomized comparisons for the separate question of whether better interpretation changes campaign decisions.