An Overview of Contextual Bandits

Ugur Yildirim2 Feb 2024

Problem

A data scientist starts a two-week A/B test and sees after a day or two that version A suits one group of users and version B suits another. A fixed split keeps sending half of each group to the worse version until the test ends. A multi-armed bandit shifts traffic over time, but it looks only at the overall winner and ignores who the user is. The cost is lost value during the test.

Example from the article: a treatment works better for core users and control works better for casual users, so the best allocation sends more core users to treatment and more casual users to control.

Solution in brief

A contextual bandit (CB) re-estimates, as data arrives, which condition gives the higher outcome for a user with a given context, and serves that condition more often. An exploration rule keeps some traffic on the other conditions. Before launch, the policy is scored on logged randomized data.

Questions this case answers
  • How to allocate traffic adaptively across treatments according to unit-level context while the effect still has to be learned
  • How to estimate offline the value of a new adaptive assignment policy from logs produced by a different randomized policy
  • How to shift traffic toward the variant that works better for each type of user while an experiment is still running?
  • How to balance exploring weaker variants against serving the current best one for a given user segment?

Tools and methods

  • Contextual bandit — dynamic, context-dependent traffic allocation.
  • ε-greedy, upper confidence bound (UCB), Thompson sampling — exploration strategies.
  • Inverse propensity scoring (IPS), doubly robust (DR) estimation — offline policy evaluation with causal inference.
  • Replay method with resampling — offline evaluation on logged randomized data.
Continue reading — it's free

Google or a one-time email code. No password.