crowdkit.aggregation.pairwise.bradley_terry.BradleyTerry | Source code
BradleyTerry(self,n_iter: int,tol: float = 1e-05)
Bradley-Terry model for pairwise comparisons.
The model implements the classic algorithm for aggregating pairwise comparisons. The algorithm constructs an items' ranking based on pairwise comparisons. Given a pair of two items and , the probability of to be ranked higher is, according to the Bradley-Terry's probabilistic model,
Here is a vector of positive real-valued parameters that the algorithm optimizes. These optimization process maximizes the log-likelihood of observed comparisons outcomes by the MM-algorithm:
where denotes the number of comparisons of and "won" by .
The Bradley-Terry model needs the comparisons graph to be strongly connected.
David R. Hunter. MM algorithms for generalized Bradley-Terry models Ann. Statist., Vol. 32, 1 (2004): 384–406.
Bradley, R. A. and Terry, M. E. Rank analysis of incomplete block designs. I. The method of paired comparisons. Biometrika, Vol. 39 (1952): 324–345.
A number of optimization iterations.
'Labels' scores. A pandas.Series index by labels and holding corresponding label's scores
The Bradley-Terry model needs the data to be a
DataFrame containing columns
right contain identifiers of left and
right items respectively,
label contains identifiers of items that won these
import pandas as pdfrom crowdkit.aggregation import BradleyTerrydf = pd.DataFrame([['item1', 'item2', 'item1'],['item2', 'item3', 'item2']],columns=['left', 'right', 'label'])
Last updated: March 31, 2023