Safe deployment strategy for adaptive experimentation
Machine LearningModel answerLast updated
Design a Bayesian bandit with delayed feedback, churn protection, and rollback rules; compare regret to fixed-split testing under real-world constraints.
You're building an adaptive allocation system to test three product variants. Conversions arrive with delay, and you must protect a churn metric.
Your task:
a) Bandit design. Specify a Thompson Sampling implementation: choice of prior and likelihood, how you'll account for conversion delays (users exposed recently haven't had time to convert yet), and how you'll adapt when conversion rates drift over time.
b) Safety constraints. Explain how you'll ensure every variant remains measurable, the churn guardrail keeps statistical power, and no variant is unfairly starved of traffic.
c) Stopping and rollback. Define the criteria for declaring a winner and the escalation ladder when a variant harms the churn metric.
d) Business trade-off. Three million users arrive over four weeks. Variant A (control) converts at 5.0%, B at 5.3%, and C at 5.5%. Estimate how many conversions you gain or lose compared to a static equal split, and explain how weekly seasonality changes both the regret calculation and your inference.
Hints
Hint 1
For delayed conversions, think about how much of the outcome window has elapsed for each user—treat partial information probabilistically rather than ignoring it or assuming failure.
Hint 2
Churn is a constraint, not just another reward. Consider filtering samples or adjusting the objective before choosing an arm.
Hint 3
Seasonality makes allocation correlate with time-of-week, biasing naive comparisons. You'll need propensity weighting or stratification to get clean estimates.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Approach
This problem tests whether you can adapt academic bandit algorithms to production realities: delayed feedback, drift, safety constraints, and the need for causal measurement alongside optimization.
a) Thompson Sampling implementation
Reward model
Model conversion as a Bernoulli trial per user within a fixed attribution window (for example, 7 days):
- Likelihood: Each user's outcome follows Bernoulli(p_k) for variant k.
- Prior: Beta(α₀, β₀) centered near your historical baseline—if conversions historically run around 5%, use Beta(5, 95).
- Posterior: After observing s_k successes in n_k completed trials, the posterior is Beta(α₀ + s_k, β₀ + n_k − s_k).
For revenue outcomes with heavy tails, use a Bernoulli × Gamma hurdle model to avoid being dominated by rare large values.
Guardrail model
Churn is also Bernoulli. Model it with its own Beta posterior per variant. Since 30-day churn is too slow for real-time decisions, use a leading indicator such as 7-day inactivity and calibrate it against historical long-term churn.
Constrained arm selection
Each allocation cycle (hourly or daily):
- Sample conversion rate p̃_k and churn rate c̃_k from their posteriors for each variant.
- Filter out any variant where c̃_k − c̃_control > δ (for example, δ = 0.2 percentage points).
- Among the remaining variants, pick the one with the highest p̃_k.
- Repeat many Monte Carlo draws to produce allocation probabilities π_k.
This hard constraint is easier to explain to stakeholders than a Lagrangian penalty; alternatively you could maximize p − λ·c with tuned λ.
Handling delayed conversions
The challenge: a user exposed two hours ago with no conversion yet is not a failure—they simply haven't had time to convert.
Naive approach: treat pending users as failures. This is pessimistic and penalizes variants that recently received more traffic, creating a feedback loop against the current winner.
Matured-only: ignore users until their exposure age exceeds the attribution window. Unbiased but slow to react.
Debiased (recommended): model the delay distribution F(e), the CDF of time-to-conversion. For a user exposed e hours ago, the probability of observing no conversion yet is 1 − p·F(e). In the Beta-Bernoulli setting, approximate this by treating each pending user as a fractional trial:
Posterior ≈ Beta(α₀ + successes, β₀ + Σ F(exposure_age) − successes)
Each user contributes only the fraction of the outcome window that has elapsed. Estimate F empirically from historical conversion-delay data using Kaplan-Meier, and refresh it weekly. Monitor whether delay distributions differ by variant.
Non-stationarity
Apply exponential discounting to sufficient statistics at each update:
α_k ← γ·α_k + new_successes
β_k ← γ·β_k + new_failures
With γ = 0.95 and daily updates, effective memory is about 20 days, covering multiple weekly cycles. Smaller γ adapts faster but keeps posteriors wide, sustaining exploration indefinitely. Don't discount below one full weekly cycle or you'll chase day-of-week noise. A sliding window is a simpler alternative.
b) Traffic floors and fairness
Minimum allocation
Mix Thompson Sampling with a uniform floor:
π_k = floor + (1 − K·floor)·π_k^TS
Use a 10% floor per variant and 20% for control. Floors provide:
- Measurability if conditions shift.
- Statistical power for the churn guardrail on every variant.
- Bounded propensities (≥ 0.1) for stable inverse-propensity weighting in causal estimates.
- Continued drift detection.
User assignment
Assign each user to one variant at first exposure and keep them there for the experiment duration. Reassignment applies only to newly arriving users. Switching existing users contaminates their outcomes and harms user experience.
Additional constraints
- Propensity logging: record π_k at assignment time for every user so you can later compute unbiased estimates via IPW.
- Rate limiting: cap allocation changes at 2× per day to prevent oscillation and operational surprises.
- Per-segment guardrails: enforce churn constraints within key segments (country, platform, tenure cohort). If a variant passes globally but harms a segment, consider stratified bandits.
- Minimum samples per segment: ensure no segment is starved, preserving the ability to detect heterogeneous effects.
c) Stopping and rollback policies
Declaring a winner
Ship a variant only when all conditions hold:
- P(variant is best) ≥ 0.95.
- Expected regret—E[max_j p_j − p_variant]—is below your business threshold (for example, 0.05 pp).
- At least two full weekly cycles have passed, plus the attribution window so conversions have matured.
- No guardrail is in alert or breach state.
If stakeholders require frequentist error control, report always-valid confidence sequences (for example, mixture sequential probability ratio tests) alongside Bayesian posteriors to guard against peeking bias.
Guardrail escalation ladder
| Alert level | Condition | Response |
|---|---|---|
| Warning | P(churn_k − churn_control > δ) > 0.80 | Reduce variant to floor allocation; notify owner |
| Breach | P(churn_k − churn_control > δ) > 0.95 | Set allocation to zero; move users to control |
| Systemic | Sample-ratio mismatch, logging gap, or delay-model drift detected | Freeze allocation or revert to uniform; halt learning |
Rollback mechanics
- Use feature flags so you can kill a variant in minutes.
- Retain data from killed variants for postmortem analysis.
- Track churn in the reverted cohort to detect lagging harm.
- Hold out a persistent 5% control group after full rollout to measure long-term effects the bandit cannot observe during optimization.
d) Regret and business impact
Static equal split
With 1 million users per variant:
- Users on A lose 0.5 pp compared to the best (C): 1M × 0.005 = 5,000 conversions.
- Users on B lose 0.2 pp: 1M × 0.002 = 2,000 conversions.
- Total regret: 7,000 conversions.
Thompson Sampling with floors
Floor cost (300k users each on A and B at minimum allocation):
- A: 300k × 0.005 = 1,500
- B: 300k × 0.002 = 600
- Floor cost: 2,100
Learning-phase regret (exploring before C is identified) adds roughly 500–1,000 conversions in stationary settings, since TS regret grows as O(log T). The 20% control floor increases this modestly.
Total regret ≈ 2,600–3,600, saving roughly 3,500–4,500 conversions compared to the static split. The floor is an explicit cost paid for safety and continued measurement.
Seasonality impact
Inference bias: allocation becomes correlated with time. If variant C receives most traffic on high-converting weekends, its naive sample mean is inflated (Simpson's paradox). Fixes:
- Inverse-propensity weighting or doubly-robust estimators using logged propensities.
- Time-stratified comparisons or day-of-week fixed effects in the reward model.
Regret: if the true best variant changes with day-of-week, discounting allows TS to track the shift and exploit it, which a static test cannot. The cost is perpetual re-exploration, making regret grow linearly with the number of regime changes rather than logarithmically.
Delay-seasonality interaction: conversion-delay distributions themselves shift on holidays and weekends. Misspecifying F(e) reintroduces bias into the debiased estimator, so monitor and refresh F by day-of-week if needed.
When not to use a bandit
Avoid adaptive allocation when:
- Variants affect long-term metrics (lifetime value, retention) that mature much slower than your decision cycle.
- Network effects or two-sided-market dynamics mean individual assignment breaks the stable unit treatment value assumption.
- Stakeholders require clean causal estimates and are unwilling to invest in propensity weighting or accept the complexity.
- The cost of floors (to preserve measurement) negates the regret savings.
In those cases, run a traditional fixed-horizon experiment with proper power analysis.
Common mistakes
- Treating pending conversions as failures, which biases allocation against the current leader.
- Ignoring seasonality and reporting naive sample means, which confound time and treatment.
- Forgetting to log propensities, making unbiased retrospective analysis impossible.
- Using 30-day churn as a real-time guardrail when decisions happen daily.
- Allowing unbounded allocation (no floors), which destroys statistical power on losing arms and makes drift undetectable.
- Declaring a winner after one day because P(best) > 0.95, ignoring both maturation delays and weekly cycles.
Complexity: Each allocation decision is O(K · num_samples) for Monte Carlo sampling. Posterior updates are O(1) per user in the Beta-Bernoulli case. With propensity weighting, offline causal estimation is O(n).