Skip to main content

Whole-History Rating for Python

PyPI version Python versions CI License: MIT

A maintained, pure-Python implementation of Rémi Coulom's Whole-History Rating (WHR) algorithm for estimating time-varying skills from dated pairwise results.

WHR is useful when the history of a competitor's strength matters—not only the latest leaderboard—and when later evidence should be allowed to refine earlier ratings.

Installation

pip install whole-history-rating

Python 3.11 or newer and NumPy 2.0 or newer are required.

Quickstart

from whr import WHR

model = WHR()
model.load_games(
    [
        "alice bob B 1",
        "alice bob W 2",
        "alice bob B 3",
    ]
)
model.auto_iterate()

print(model.ratings_for_player("alice"))
print(model.probability_future_match("alice", "bob"))

Games are formatted as black_player white_player result time_step, where the result is B, W, or D. You can also add structured games with create_game().

Why Whole-History Rating?

Unlike an online rating update, WHR jointly revisits each competitor's complete trajectory when new results are added. A later result can therefore refine the estimated rating at an earlier date.

This implementation provides:

  • retrospective smoothing of time-varying skill;
  • uncertainty for ratings, differences, and changes over time;
  • uncertainty-aware match predictions;
  • binary outcomes and Davidson-model draws;
  • learned contextual advantages such as home advantage, handicap, and komi;
  • convergence and data-connectivity diagnostics;
  • a reproducible comparison with KickScore and TrueSkill Through Time.

The main reason to choose WHR is not that it wins every predictive benchmark—it does not. Its strength is an interpretable, relatively lightweight model of complete pairwise histories.

Benchmark evidence

Lower log-loss is better. All systems below are trained, tuned, and evaluated under the same temporal protocol.

Predictive log-loss of WHR, KickScore and TrueSkill Through Time on NBA, ATP tennis and European football data.
Benchmark Test set WHR KickScore TrueSkill Through Time
NBA 2018–19, n=1,312 0.666 0.662 0.688
ATP tennis 2014, n=2,816 0.614 0.606 0.604
Football, three outcomes 2022–23, n=1,826 1.008 1.013 1.023

No system wins every dataset, and the gaps are small. WHR leads the three-outcome football comparison, KickScore leads the NBA comparison, and TrueSkill Through Time leads tennis. Domain-specific NBA models using rosters, injuries, and travel still outperform all three generic rating systems.

The complete protocol, hyperparameter grids, limitations, data sources, and reproduction commands are in the benchmark report and benchmark README.

Applications

WHR can be used for dated pairwise-comparison histories such as:

  • board games including Go and chess;
  • sports and esports rankings;
  • historical leaderboards;
  • matchmaking analysis;
  • human-preference experiments;
  • pairwise evaluation of models or systems.

The model observes outcomes, dates, and optional contextual effects. It does not use domain-specific information such as rosters, injuries, maps, prompts, or evaluator identities. For LLM evaluation, treat it as a rating component rather than a complete evaluation methodology.

Documentation

The documentation site can be built locally with:

uv sync --group docs
uv run --group docs mkdocs build --strict

Implementation characteristics

  • Pure Python with NumPy used where batching is beneficial.
  • No compiled extension required.
  • Binary and drawn outcomes.
  • Learned contextual advantages.
  • Reproducible real-data benchmark suite.
  • High-level compatibility alias for the former Base class.

The project originated as a port of the GoShrine Ruby implementation and has since added a modern API, diagnostics, draws, learned contextual advantages, uncertainty-aware predictions, and cross-library benchmarks.

Citation

If you use this package in research, cite both the software and Rémi Coulom's original WHR paper. GitHub exposes the complete metadata from CITATION.cff.

Rémi Coulom. “Whole-History Rating: A Bayesian Rating System for Players of Time-Varying Strength.” Computers and Games, LNCS 5131, 113–124, 2008. DOI: 10.1007/978-3-540-87608-3_11.

Development

uv sync --dev
uv run ruff check whr tests benchmarks
uv run mypy
uv run pytest

The fast CI suite also runs a synthetic benchmark smoke test. Full real-data benchmarks are intentionally manual because they download external datasets and can take hours.

License

MIT. See the license text.

Metadata

Release files for whole-history-rating 3.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whole-history-rating 3.6.2
File Size Uploaded
whole_history_rating-3.6.2.tar.gz 224.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for whole-history-rating 3.6.2
File Interpreter ABI Platform
whole_history_rating-3.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 272.3 kB

Release files / whole_history_rating-3.6.2.tar.gz

Download URL whole_history_rating-3.6.2.tar.gz
Size 224.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fa5671f11b9de372e7ffb2c8d65712dcd62eef158c90ffd1f41d93b15b4de3f8
BLAKE2b-256 checksum
How to use checksums
b6b8bbf77150a2f9dc25657292606a611a0afd0792c7883dddd167f58e994832
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / whole_history_rating-3.6.2-py3-none-any.whl

Download URL whole_history_rating-3.6.2-py3-none-any.whl
Size 47.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3380666b4c4d15beb1791b2af964b667d200b24c03ee33ef1b09b7b25c8723bd
BLAKE2b-256 checksum
How to use checksums
0a57575685fe5b8c3a533221792a378093f49d0a06f32973f76e339c991ace80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

3.7.1

2 release files

3.7.0

2 release files

This release

3.6.2 This release

2 release files

3.6.1

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

1 release file

1.5

2 release files

1.4

2 release files

1.3.5

2 release files

1.3.3

2 release files

1.2.1

2 release files

1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page