ML Systems Lab Open interactive version →
Advanced 65 min read OPEimportance samplingdoubly robustSNIPSIPW

Off-Policy Evaluation for Bandits

Importance sampling, doubly robust estimator, SNIPS, variance control, distribution shift

Online A/B testing every candidate policy is expensive and risky — you need weeks of traffic and accept all the costs of deploying a suboptimal policy. Off-Policy Evaluation (OPE) addresses this: given logged data from a behaviour policy, estimate how well a new policy would perform without deploying it. The fundamental problem is that logged data reflects the behaviour policy's choices — the new policy may want to take very different actions in contexts the behaviour policy rarely encountered. Importance weighting corrects for this mismatch but variance explodes when the policies diverge significantly: a small propensity denominator drives importance weights arbitrarily large, and a few high-weight observations dominate the estimate. The doubly robust estimator is the production standard because it is consistent if either the reward model or the propensity model is correctly specified — two independent chances to be right.

Key points

Takeaway

The doubly robust estimator is the production standard because it is consistent if either the reward model or the propensities are correct — two independent chances to be right. Log propensities at serve time, not reconstructed later: reconstruction errors from a changed policy break all IS-based estimators. Monitor $N_eff = (Σw)²/(Σw²) continuously — if it falls below 5-10%$ of sample size, a handful of high-weight observations dominate the estimate and the OPE is unreliable regardless of how much data you have.

Recap

Check your understanding

Q1. You have 1M logged impressions from a random policy (uniform over K=10 arms) and want to evaluate a new deterministic policy that always chooses arm 3. Compute the importance weights and analyze the variance.

Q2. Why is the doubly robust estimator called "doubly robust"? Construct a simple example where one model is wrong but DR is still consistent.

Q3. Spotify wants to evaluate 50 new playlist ranking policies before A/B testing. Select the two true failure modes you must monitor in the OPE pipeline.

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 →