mixle.stats.rankings.paired_comparison moduleΒΆ
Paired-comparison models beyond plain Bradley-Terry: Gaussian pairwise and ties.
Three canonical models that complete the pairwise-comparison family:
ThurstoneMostellerDistributionβ the Gaussian (probit) pairwise modelP(i beats j) = Phi((mu_i - mu_j) / sqrt(2)); the pairwise peer ofThurstoneDistributionand the Gaussian counterpart ofBradleyTerryDistribution. Observation:(winner, loser).DavidsonDistributionβ Bradley-Terry with ties (Davidson 1970): a draw has probabilitynu * sqrt(w_i w_j) / (w_i + w_j + nu sqrt(w_i w_j)). Observation:(i, j, outcome)withoutcomein{0: i wins, 1: j wins, 2: tie}.RaoKupperDistributionβ Bradley-Terry with ties via a thresholdnu >= 1(Rao-Kupper 1967):P(i beats j) = w_i / (w_i + nu w_j). Same(i, j, outcome)observation.
All three treat the compared pair as a uniform draw over the C(K, 2) unordered pairs, making them
proper distributions over (canonicalized) comparison outcomes. Worths/utilities are identified up to a
shift and stored mean-zero. Fitting maximizes the comparison log-likelihood from the win/tie count
matrices (the sufficient statistic).
- class ThurstoneMostellerDistribution(mu, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionGaussian/probit paired-comparison model
P(i beats j) = Phi((mu_i - mu_j) / sqrt(2)).- classmethod compute_capabilities()[source]
Return backend capabilities for the probit pairwise likelihood.
- density(x)[source]
Return the probability mass of one winner-loser pair.
- log_density(x)[source]
Return the log probability of one winner-loser pair.
- seq_log_density(x)[source]
Score encoded winner-loser pairs.
- sampler(seed=None)[source]
Return a sampler for winner-loser comparisons.
- Parameters:
seed (int | None)
- Return type:
ThurstoneMostellerSampler
- estimator(pseudo_count=None)[source]
Return the least-squares probit paired-comparison estimator.
- Parameters:
pseudo_count (float | None)
- Return type:
ThurstoneMostellerEstimator
- dist_to_encoder()[source]
Return the encoder for winner-loser pair data.
- Return type:
PairDataEncoder
- class ThurstoneMostellerSampler(dist, seed=None)[source]
Bases:
DistributionSamplerSampler for Thurstone-Mosteller winner-loser comparisons.
- Parameters:
dist (ThurstoneMostellerDistribution)
seed (int | None)
- class ThurstoneMostellerEstimator(dim, name=None, keys=None)[source]
Bases:
ParameterEstimatormu_i - mu_j = sqrt(2) Phi^{-1}(P(i beats j))from the win-count matrix (least squares).- accumulator_factory()[source]
Return the accumulator factory used by this estimator.
- Return type:
PairWinAccumulatorFactory
- class PairWinAccumulator(dim, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorWin-count matrix
wins[i, j]for (winner, loser) pair data.- update(x, weight, estimate)[source]
Accumulate one weighted winner-loser observation.
- initialize(x, weight, rng)[source]
Initialize sufficient statistics from one weighted pair.
- Parameters:
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate weighted winner-loser pairs from an encoded batch.
- seq_initialize(x, weights, rng)[source]
Initialize sufficient statistics from an encoded weighted batch.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge serialized win-count sufficient statistics.
- Return type:
PairWinAccumulator
- value()[source]
Return serialized win-count sufficient statistics.
- from_value(x)[source]
Restore accumulator state from serialized win counts.
- Return type:
PairWinAccumulator
- key_merge(stats_dict)[source]
Merge tied win-count statistics into
stats_dict.
- key_replace(stats_dict)[source]
Replace tied win-count statistics from
stats_dict.
- acc_to_encoder()[source]
Return the encoder associated with this accumulator.
- Return type:
PairDataEncoder
- class PairWinAccumulatorFactory(dim, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for paired win-count accumulators.
- make()[source]
Create a fresh paired-win accumulator.
- Return type:
PairWinAccumulator
- class PairDataEncoder(dim=None)[source]
Bases:
DataSequenceEncoderEncode
(winner, loser)pairs into an(N, 2)integer array.- Parameters:
dim (int | None)
- class DavidsonDistribution(log_w, nu=1.0, name=None, keys=None)[source]
Bases:
_BaseTieDistributionBradley-Terry with ties (Davidson 1970); tie mass
nu sqrt(w_i w_j).
- class DavidsonEstimator(dim, name=None, keys=None)[source]
Bases:
ParameterEstimatorMaximum-likelihood Davidson worths and tie parameter (L-BFGS on the count matrices).
- accumulator_factory()[source]
Return the accumulator factory used by this estimator.
- Return type:
_TieAccumulatorFactory
- class RaoKupperDistribution(log_w, nu=1.5, name=None, keys=None)[source]
Bases:
_BaseTieDistributionBradley-Terry with ties via a threshold
nu >= 1(Rao-Kupper 1967).