Learning to Rank the Bayesian Way

Robert Kübler9 Aug 2022

Problem

Ranking by win ratio fails in two ways. A near-100% win ratio does not tell you whether a player is exceptional or only beat weak opponents. A player with few games gets a point estimate with no sign that it is shaky. The same one-versus-one structure appears when judging which of two search results is more relevant to a query, or which of two recommendations a user is more likely to want.

Example from the article: a synthetic league of three players with 1000 random pairings (same-player pairs dropped), plus a fourth who played only two games against player 2 and won both. It is unclear whether player 3 is truly better than player 2 or just lucky.

Solution in brief

Give every item a latent strength and model the win probability as a sigmoid of the strength difference (the Bradley–Terry model). Fit the strengths as parameters in a Bayesian model with Gaussian priors. Rank by posterior mean, and read the width of each posterior as the uncertainty.

Questions this case answers
  • How to order a set of items from sparse pairwise comparisons so that each score carries an uncertainty estimate and items with little data are not over-trusted
  • How to rank items from pairwise win/loss outcomes when a raw win ratio ignores opponent strength?
  • How to show how uncertain an item's score is when it has only a few comparisons?
  • How to score search results or recommendations from pairwise relevance judgments without item features?

Tools and methods

  • Bradley–Terry model — win probability from the difference of two latent strengths
  • Bayesian inference with Gaussian priors — gives a posterior distribution of strength per item
  • PyMC — builds the model and runs MCMC sampling (pm.sample())
Continue reading — it's free

Google or a one-time email code. No password.