20/31
Part 5 of 6 · Position bias and IPSLearn and do

Why it's unbiased

An impression at position kk is clicked with chance pkrp_k r. Divide by pkp_k, and rr is what's left:

E ⁣[cpk]=pk rpk=r\mathbb{E}\!\left[\frac{c}{p_k}\right] = \frac{p_k \, r}{p_k} = r

E\mathbb{E} is the expected value: the average over many impressions. That holds at every position, so any mix of positions averages to rr.

It needs one condition. Every position the item was shown at must have pk>0p_k > 0. A position nobody ever looks at tells you nothing, and no weight can fix that.

Here's what 1,000 simulated logs give, each built like the practice test's:

EstimatorCodeExpectedMean of 1,000 logsSpread (sd)
Raw click-through ratemean(c)0.1610.1610.0008
IPSmean(c / p)0.3000.3000.0019
Multiplied by propensitymean(c * p)0.1140.1140.0006

IPS landed within 0.01 of 0.3 in all 1,000 logs. It pays for that with a spread a bit over twice as wide as raw click-through rate's. That's the variance question under the follow-ups.

The same weight fixes offline scoring on clicks. To score a new ranker on old logs, count each logged click toward its metric, divided by the propensity of the slot where the click happened. Joachims, Swaminathan and Schnabel prove this estimate is unbiased.

A real log mixes many items. In the editor, write ips_by_item(items, clicks, positions, propensity): items[j] is the item id shown at impression j, and you return each item's IPS click rate, indexed by its id.