Skip to content

Human judgment, preference, and annotation measurement · Human judgment, annotation, and latent measurement · HME001 · Model

Bradley–Terry paired-comparison model

Estimate relative item or system worth from binary pairwise preferences. The fitted object is a probabilistic ranking model; it is distinct from the Ansari–Bradley statistical test and from a raw win-rate leaderboard.

Runs in CodeSplash Complete calculation CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method runs this entry in Python and R. Set it up from the method's page.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Runs in CodeSplash
Code example
Complete calculation
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through measurement.bradley_terry. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Estimate relative item or system worth from binary pairwise preferences. The fitted object is a probabilistic ranking model; it is distinct from the Ansari–Bradley statistical test and from a raw win-rate leaderboard.

Question / hypotheses

How likely is item i to be preferred to j in the specified comparison population? A hypothesis such as equal worth requires an additional inferential procedure and a defensible sampling unit.

Architecture / computational structure

Each comparison produces a signed item-indicator row for a logistic regression. One location constraint identifies log-worths. Optimization uses binomial likelihood; covariates can encode presentation order, item attributes, or other contest-specific effects.

Assumptions

The basic model has a stable one-dimensional worth per item and conditionally independent judgments. Worth differences explain log odds. Heterogeneous criteria, judge dependence, cycles, and item-by-prompt interactions can violate this simplification. An undirected connected graph identifies contrasts; finite unpenalized estimates require stronger win/loss connectivity conditions.

Formula / computational definition

P(i≻j)=wiwi+wj=σ(si−sj),wi=esi,ℓ(s)=∑m[ym(sim−sjm)−log⁡{1+esim−sjm}].P(i\succ j)=\frac{w_i}{w_i+w_j}=\sigma(s_i-s_j),\quad w_i=e^{s_i},\quad \ell(s)=\sum_m[y_m(s_{i_m}-s_{j_m})-\log\{1+e^{s_{i_m}-s_{j_m}}\}].

Parameters and notation

Estimated: item log-worths s, and any explicitly included covariate effects. Fix one s or impose sum-to-zero; absolute levels have no meaning. Design choices: comparison graph, repeated judgments, tie policy, criterion, order randomization, and resampling unit. Numerical settings: optimizer tolerance and iteration limit. Priors or penalties create a different estimator and must be named.

Fitting, fine-tuning, and adaptation

New items need comparisons linking them to established items. Warm-starting speeds refitting but does not remove uncertainty or drift. Refit after a rubric or population change; compare stable anchor items across occasions. Preserve every judgment rather than only aggregate ranks when judge/prompt effects may matter.

How to use and calibrate

Check graph connectivity and separation, inspect residual pair frequencies, and evaluate held-out comparisons. Report pairwise probabilities and uncertainty as well as rank order. Resample independent prompts or raters when judgments are clustered; a row bootstrap assumes independent comparison rows.

Example application

Compare summarizers under a fixed rubric with randomized left/right order and several prompts. The full workflow in this volume fits a controlled synthetic comparison graph and evaluates held-out log loss.

Interpretation / pitfalls

Watch out

Rank is sensitive when worth intervals overlap. Adding a constant to all log-worths changes nothing. A regularized finite solution is not evidence that an unpenalized MLE existed. Learned worth reflects the sampled judging task, not objective universal quality.

Python and R code examples

Scope: Exact pair-probability and log-likelihood calculation for supplied worths; the companion workflow fits the complete model. Python NumPy; R base.

Validation: Python executed successfully; native R reviewed but not executed.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Complete calculation — Exact pair-probability and log-likelihood calculation for supplied worths; the companion workflow fits the complete model. Python NumPy; R base. · needs numpy

import numpy as np
s=np.array([.8,.1,-.4]); i=np.array([0,0,1]); j=np.array([1,2,2]); y=np.array([1,1,0])
z=s[i]-s[j]; p=1/(1+np.exp(-z)); ll=np.sum(y*z-np.logaddexp(0,z))
assert np.allclose(p,1/(1+np.exp(-((s+7)[i]-(s+7)[j]))))
print(p,ll)
R

Complete calculation — Exact pair-probability and log-likelihood calculation for supplied worths; the companion workflow fits the complete model. Python NumPy; R base.

s <- c(.8,.1,-.4); i <- c(1,1,2); j <- c(2,3,3); y <- c(1,1,0)
z <- s[i]-s[j]; p <- plogis(z); ll <- sum(y*z-log1p(exp(z)))
stopifnot(isTRUE(all.equal(p,plogis((s+7)[i]-(s+7)[j]))))
print(list(probabilities=p,loglikelihood=ll))

Sources

From the CodeSplash reference, entry HME001.