The Learning Router ← sugeerth.github.io

Off-policy evaluation · lab.js

What would a setting you never shipped have scored?

Every learning layer can tell you about choices it made. The questions people actually have are about the ones it didn't. This answers them from traffic you already have — and because the page knows the true answer, you can watch the estimate be right.

Why this is possible at all

Only because the router randomizes. Under a deterministic policy every alternative was taken with probability zero, the importance weight is a division by zero, and no amount of data fixes it — the question has no evidence behind it. The router spends a measured 0.2 points of accuracy on exploration, and that is what buys every number below.

Ask about a policy

Traffic below is logged under the router's own policy in a two-domain world. Pick a different policy and the page estimates what it would have scored, three ways. The truth line is computed directly from the world, so you are checking the estimator rather than trusting it.

estimator value

 

The per-context badges are the ones that decide whether to believe any of it. Choose Always Shaped / Deep and drop the traffic: the pooled numbers stay healthy while cook collapses, because the router picks that setting constantly for code asks and almost never for cooking ones. Nearly all the evidence then comes from the half of the world where it happens to be good, and the estimate quietly answers a narrower question than the one asked. A pooled diagnostic cannot see that — the weight is real, it is just all in one place — which is why credibility is gated on the worst context.

Reading the three numbers

estimatorwhat it ishow it fails
IPS Re-weight each logged reward by how much more (or less) likely the policy you're asking about would have been to take that action. Unbiased, and wildly high-variance exactly when the two policies disagree most — which is when you most wanted the answer.
SNIPS The same, divided by the sum of the weights instead of the count. Slightly biased, far steadier, and it cannot return a value outside the rewards actually observed. This is the one worth showing people.
DR A reward model carries the signal; the importance-weighted residual corrects the model's error. Right if either the model or the propensities are right. It needs the target policy's probability for every action — give it less and it collapses, which is a bug this code had.
ESS Not an estimate — the effective sample size. How much evidence is really behind the number. Pooled, it hides deficient support in a subpopulation: this code reported a healthy ESS of 96 on an estimate that was wrong by 0.36. It is now computed per context and gated on the worst.

The honest limit

Drag the slider down and watch the estimate go wrong while the badge turns amber. That is the whole design: wrong and flagged is recoverable, wrong and confident is what gets shipped.

There is a real ceiling here and it is worth stating. The router randomizes only between settings it cannot separate, which keeps exploration nearly free but means roughly 2% of decisions are off-policy. Questions about a setting the router confidently rejects therefore need a lot of traffic before they become answerable — in the repository's eval, around 5,000 logged decisions for a policy that disagrees almost everywhere. Until then the right output is a refusal, not a number.

It is checked against truth, not vibes

tests/lab-eval.js builds a world with a known reward table, so the exact value of any policy can be computed rather than sampled. It then logs under a deliberately mediocre policy and asks about a better one:

truth (computed, not sampled): 0.875
what the logs averaged:        0.413
IPS   0.815   SNIPS 0.867   DR 0.846
ESS 188 of 4000, max weight 20, overlap 0.047

The gap between 0.413 and 0.875 is the mistake you make by reading the logs naively. The estimators close it to within 0.008.