Top results get more clicks. How do you correct for position?
Question
A shop's search page logged clicks for two products, 1,000 impressions each:
| product | position | impressions | clicks |
|---|---|---|---|
| A | 1 | 1,000 | 180 |
| B | 2 | 400 | 72 |
| B | 3 | 600 | 54 |
From an earlier experiment, the chance that a shopper looks at a position is 0.9 for position 1, 0.6 for position 2 and 0.3 for position 3.
By raw click-through rate, A beats B. Is that fair? Correct the click rates for position and say which product shoppers prefer once they see it. What does your correction assume, and how would you measure the chance of looking at each position?
Show hints (3)
- "SEEN OR NOT"
A shopper who never looked at position 3 can't click B there. A missing click can mean "not interested" or "never seen".
- "SPLIT THE CLICK"
Assume a click needs two things: the shopper sees the product, then likes it. So P(click) = P(seen) × P(click once seen). Solve for the second part.
- "WEIGHT THE CLICKS"
Divide each click by P(seen) at its position. Add these up, then divide by all impressions, not only the clicked ones.
Show checked explanation
No. A gets more clicks partly because more shoppers see position 1. Assume position only changes whether a product is seen: the examination hypothesis. Then weight each click by 1 / P(seen). A's corrected rate is 0.2 and B's is 0.3, so B wins. Measure P(seen) with a small swap experiment.
seen = {1: 0.9, 2: 0.6, 3: 0.3} # P(shopper looks at the position)
log = [ # product, position, impressions, clicks
("A", 1, 1000, 180),
("B", 2, 400, 72),
("B", 3, 600, 54),
]
totals = {}
for product, pos, shows, clicks in log:
t = totals.setdefault(product, [0, 0, 0.0])
t[0] += shows
t[1] += clicks
t[2] += clicks / seen[pos] # each click counts 1 / P(seen)
for product, (shows, clicks, weighted) in totals.items():
print(f"{product}: raw CTR {clicks / shows:.3f}, "
f"corrected {weighted / shows:.3f}")A: raw CTR 0.180, corrected 0.200 B: raw CTR 0.126, corrected 0.300
Code run on CPython 3.12 against the example above. Checked by an editor other than the author.
Walkthrough
The examination hypothesis splits a click into two steps. The shopper looks at the position, then clicks if the product appeals:
P(click) = P(seen at position) × P(click once seen)
The second part belongs to the product, so compare that.
| row | P(seen) | clicks | clicks ÷ P(seen) |
|---|---|---|---|
| A at 1 | 0.9 | 180 | 200 |
| B at 2 | 0.6 | 72 | 120 |
| B at 3 | 0.3 | 54 | 180 |
A: 200 / 1,000 = 0.2. B: (120 + 180) / 1,000 = 0.3. The raw rates were 0.18 and 0.126. So B appeals more once seen.
This is inverse propensity weighting (IPW), and the propensity is P(seen). A click at a rarely seen position also stands for shoppers who would have clicked but never looked. If P(seen) is right, this estimate of P(click once seen) has no bias.
Where does P(seen) come from? Not from the raw click rate by position, because better products already sit higher. Run a small experiment instead. For a small share of searches, swap the top result with the one at a random position k. Compare those same top results at position k and at position 1. The products are the same, so the ratio measures position alone. If they get 0.15 at position 1 and 0.05 at position 3, then P(seen at 3) is one third of P(seen at 1).
That ratio is enough. If every propensity is off by the same factor, so is every corrected rate, and the order of products stays the same.
Common mistakes
- Dividing the weighted clicks by the number of clicks instead of all impressions. Every impression counts, with or without a click.
- Trusting tiny propensities. A click at P(seen) = 0.01 weighs 100, so one click can swing the estimate. Capping the weights cuts the noise but adds some bias.
- Ignoring trust bias. If shoppers click position 1 partly because they trust the top result, the examination hypothesis fails, and IPW alone can't fix it.
- Expecting IPW to rescue products shown only where nobody looks. With P(seen) = 0 there are no clicks to weight. You must show them to collect data.
Follow-up questions
- "How do you use this to train a ranking model?" Weight each clicked example in the training loss by 1 / P(seen) at its position. The model then learns as if every position were seen equally. This is the core of unbiased learning to rank.
- "Randomizing results hurts some searches. Can you estimate P(seen) without it?" Partly. In an old A/B test, two rankers often put the same product at different positions. Shoppers were split at random, so compare its click rates there. Or fit P(seen) and appeal together from normal logs with an EM model. That fit is only as good as its appeal model.
What a strong answer covers
Separates being seen from being liked and names the examination hypothesis. Weights clicks by 1 / P(seen) over all impressions and finds B beats A. Estimates propensities with a swap experiment and flags tiny propensities and trust bias.
Open in interactive practice deck →