Starbucks Offer Targeting
Starbucks sends Rewards members BOGO and discount offers, but many people would have bought anyway and others never look. With a teammate, I built a pipeline that predicts who will actually respond, groups customers into segments, and uses uplift modelling to spend a fixed offer budget where it changes behaviour.
An offer only pays off if it changes what the customer does. Sending a discount to someone who would have bought anyway costs margin, and sending one to someone who never opens the app is wasted. So there are three questions: who responds, what kinds of customer exist, and given a fixed reward budget, who should get an offer?
Only count real responses
A positive label means the customer viewed the offer and then completed it before it expired. Completing without viewing stays negative, because the offer didn't cause the purchase.
No peeking at the future
Behavioural features use only events before each offer arrived, and the train/test split follows time order, so test scores reflect real forecasting.
Data exploration & plotting
Wrote the first exploration notebook and the shared plotting utilities used throughout the project.
7-day spend velocity features
Added "spend in the last 7 days" and "transactions in the last 7 days" before each offer, using point-in-time merge_asof joins so no future data leaks in.
Hyperparameter tuning
Added RandomizedSearchCV (15 draws, 3-fold CV, optimising F1) with search spaces for logistic regression, random forest and XGBoost.
Decision thresholds
Replaced the fixed 0.5 cutoff with the threshold that maximises F1 on validation data (0.32 for XGBoost), then re-ran every evaluation and explanation report.
# customer_features.py: spend velocity just before each offer (time is in hours)
features["time_7d_ago"] = features["received_time"] - 168
history_7d = pd.merge_asof(..., left_on="time_7d_ago", right_on="time", by="person", direction="backward")
features["spend_last_7d"] = features["total_spend_before"] - features["spend_7d_ago"]
Niloy led the raw-data parsing, target construction, feature pipeline, clustering, uplift model, budget simulation and test suite.
What the models found
All figures are from the repo's reports, on held-out data.
Held-out test: ROC-AUC
Time-based split: 30,420 train rows, 20,412 test rows.
XGBoost: F1 0.62, precision 0.51, recall 0.81. The majority-class and rule-based baselines score F1 0.
Budget simulation: extra responses
Same budget (25% of total reward value) spent two ways.
Expected incremental responses from 12,209 candidates. Uplift picked 3,119 offers. Random is the mean of repeated draws (± 1.4).
Offer completion rate by segment
K-Means, k = 4 (best silhouette, 0.255). Segment names are descriptive.
The largest group joined most recently (about 315 days), averages $5 per visit, and almost never completes offers.
Strongest XGBoost signals
Feature importance (gain share).
Bars scaled to the top feature. Confirmed with a SHAP summary in the repo.
Incomplete profiles are the biggest tell
Whether a customer filled in their gender, age and income mattered more than any spending feature. Members who skip their profile behave very differently with offers.
Channel matters
Offers sent through social media were the second-strongest signal, ahead of reward size or difficulty.
Target by incremental effect, not by likelihood
Ranking by uplift per reward dollar got 2.4× the extra responses that random targeting got for the same spend.