LearnQuestion bank

How can you estimate a new recommendation policy’s performance from logs collected by the old policy?

ML engineeringTechnicalHard

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Log the chosen action, its outcome and its propensity under the old policy (ideally the full action distribution).
  • Use IPS for unbiased off-policy value, self-normalised IPS for lower variance, and doubly robust estimators, which stay consistent if either the propensities or the outcome model is right.
  • Expect variance blow-up when old and new policies differ; clip or truncate weights and check effective sample size.
  • Replay for bandits: keep only logged events where the candidate picks the logged action and average their rewards; unbiased under uniformly random logging, otherwise reweight.
  • Keep some exploration in the old policy and log it, because counterfactual estimation needs overlap and known propensities.

In full

The core is to log, for each context, the action taken, the reward or outcome, and the old policy’s propensity for that action (ideally its full action distribution), then estimate the new policy’s value by reweighting those logs. Inverse propensity scoring weights each logged outcome by pi_new(a|x)/pi_old(a|x); self-normalised IPS divides by the sum of the weights rather than n, which reduces variance at the cost of some bias; doubly robust estimators combine a reward model with an IPS correction on its errors, so they remain consistent if either the propensities or the outcome model is right. The main failure mode is variance: when the new policy chooses actions the old policy rarely took, importance weights explode and the effective sample size collapses, so clipping or truncating weights helps stability but introduces bias and should be reported with diagnostics such as effective sample size. For bandits, replay evaluation steps through the logged events and keeps only those where the candidate policy chooses the same action that was logged, then averages their rewards; this is unbiased when the logging policy chose actions uniformly at random, and otherwise needs IPS-style weighting. All of this only works if the old policy explored enough and those randomisation probabilities were logged, because without overlap and known propensities the counterfactual value is not identifiable.

Corrected by an independent AI reviewer.

What a strong answer covers

  • Log propensities. Inverse propensity scoring (IPS), self-normalised IPS, doubly robust estimators.
  • Variance problems when policies differ a lot; clipping.
  • Replay evaluation for bandits.
  • Explore/exploit and why some randomisation must be logged.

Common mistakes

  • evaluating on clicks without correcting exposure bias
  • no propensity logging.