ML Systems Lab Open interactive version →
Advanced 70 min read non-stationarysliding windowdiscounted UCBEXP3adversarial

Non-Stationary Bandits

Sliding window UCB, discounted UCB, change-point detection, EXP3, REXP3

Standard UCB and Thompson Sampling are built for stationary reward distributions. They accumulate observations indefinitely — N_a(t) grows monotonically. An arm with millions of accumulated observations has a confidence interval so tight it never loses the argmax, even after its reward has collapsed.

The algorithm stays frozen on a historically dominant arm long after its true mean has dropped. The failure mode is slow: it takes O(N_a) new observations to substantially move the empirical mean — that is months of data for a heavily exploited arm. The right production strategy combines two mechanisms: CUSUM-based change detection for abrupt shifts (triggers an immediate statistics reset when a change is detected) and sliding window or discounted UCB for gradual drift (continuously forgets stale observations so the mean tracks recent reality). Predictable seasonality is not non-stationarity — weekly cycles belong in contextual features, not in a forgetting mechanism.

Key points

Takeaway

Standard UCB/TS freezes on a historically dominant arm after a change point because N_a is too large for the empirical mean to move quickly — it takes O(N_a) post-change observations to detect the drop. The right production strategy combines CUSUM-based change detection for abrupt shifts (immediate statistics reset) and sliding window or discounted UCB for gradual drift (continuous forgetting). Predictable seasonality is not non-stationarity — recurring patterns belong in contextual features where the model learns them, not in a forgetting mechanism that discards them.

Recap

Check your understanding

Q1. You're running UCB on an ad creative rotation with K=5 creatives. Creative A dominated for 3 months, but a competitor launched a similar ad and A's CTR dropped from 8% to 2% overnight. Select the two true statements about the failure and fix.

Q2. Explain the EXP3 importance-weighted reward estimate x̂_{a,t} = r_t / p_{a,t}. Why is it unbiased and what is the variance?

Q3. In a content recommendation system with weekly seasonality (weekend vs weekday user preferences differ strongly), is non-stationary bandit the right framing? What would you do differently?

Q4. REXP3 restarts EXP3 every T/Υ rounds. Each restarted run is a fresh EXP3 instance over a horizon of length T/Υ, so it inherits the O(√(K·(T/Υ)·ln K)) bound taught above. Summing this bound across all Υ epochs, what is REXP3's total regret order, and how does it compare to the informal lower bound Ω(√(ΥKT))?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →