Skip to main content

A Python interface incorporating a C++ implementation of the Whole History Rating algorithm proposed by Rémi Coulom. The implementation is based on the Ruby code of GoShrine.

Project description

Whole History Rating

CI status
conda.recipe Conda Actions Status
pip builds Pip Actions Status
cibuildwheel Wheels Actions Status

Description

A Python interface incorporating a C++ implementation of the Whole History Rating algorithm proposed by Rémi Coulom.

The implementation is based on the Ruby code of GoShrine.

Installation

To install it from PyPI:

pip install whr

To install it from source code:

git clone git@github.com:wind23/whole_history_rating.git
pip install ./whole_history_rating

To build this package from the source code, you will need a recent version of Python 3 installed, along with setuptools>=42 and pybind11>=2.10.0. Furthermore, depending on your operating system, you may also require the installation of the appropriate C++ build environment. If you are uncertain about the required dependencies, you can begin by attempting pip install and follow the instructions provided by your system to install the necessary components.

If you encounter compatibility issues while using the latest version, you can also try the older version implemented purely in Python:

pip install whr==1.0.1

Usage

Here is an easy example about how to use the package:

In [1]: import whr
   ...: import math
   ...:
   ...: base = whr.Base(config={"w2": 30})
   ...: base.create_game("Alice", "Carol", "D", 0)  # Alice and Carol had a draw on Day 0
   ...: base.create_game("Bob", "Dave", "B", 10)  # Bob won Dave on Day 10
   ...: base.create_game("Dave", "Alice", "W", 30)  # Dave lost to Alice on Day 30
   ...: base.create_game("Bob", "Carol", "W", 60)  # Bob lost to Carol on Day 60
   ...:
   ...: base.iterate(50)  # iterate for 50 rounds

In [2]: print(base.ratings_for_player("Alice"))
   ...: print(base.ratings_for_player("Bob"))
   ...: print(base.ratings_for_player("Carol"))
   ...: print(base.ratings_for_player("Dave"))
[[0, 78.50976252870765, 185.55230942797314], [30, 79.47183295485291, 187.12327376311526]]
[[10, -15.262552175731392, 180.95086989932025], [60, -18.086030877782818, 183.0820052639819]]
[[0, 103.91877749030998, 180.55812567296852], [60, 107.30695193277168, 183.1250043094528]]
[[10, -176.67739359273045, 201.15282077913983], [30, -177.3187738768273, 202.03179750776144]]

In [3]: print(base.get_ordered_ratings())
[('Carol', [[0, 103.91877749030998, 180.55812567296852], [60, 107.30695193277168, 183.1250043094528]]), ('Alice', [[0, 78.50976252870765, 185.55230942797314], [30, 79.47183295485291, 187.12327376311526]]), ('Bob', [[10, -15.262552175731392, 180.95086989932025], [60, -18.086030877782818, 183.0820052639819]]), ('Dave', [[10, -176.67739359273045, 201.15282077913983], [30, -177.3187738768273, 202.03179750776144]])]

In [4]: evaluate = whr.Evaluate(base)
   ...: test_games = [
   ...:     ["Alice", "Bob", "B", 0],
   ...:     ["Bob", "Carol", "W", 20],
   ...:     ["Dave", "Bob", "D", 50],
   ...:     ["Alice", "Dave", "B", 70],
   ...: ]
   ...: log_likelihood = evaluate.evaluate_ave_log_likelihood_games(test_games)

In [5]: print("Likelihood: ", math.exp(log_likelihood))
Likelihood:  0.6274093351974668

To learn more about the detailed usage, please refer to the docstrings of whr.Base and whr.Evaluate.

References

Rémi Coulom. Whole-history rating: A Bayesian rating system for players of time-varying strength. In International Conference on Computers and Games. 2008.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whr-2.0.4.tar.gz (14.1 kB view hashes)

Uploaded Source

Built Distributions

whr-2.0.4-pp310-pypy310_pp73-win_amd64.whl (118.1 kB view hashes)

Uploaded PyPy Windows x86-64

whr-2.0.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (162.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

whr-2.0.4-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (174.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

whr-2.0.4-cp313-cp313-win_amd64.whl (119.8 kB view hashes)

Uploaded CPython 3.13 Windows x86-64

whr-2.0.4-cp313-cp313-win32.whl (101.2 kB view hashes)

Uploaded CPython 3.13 Windows x86

whr-2.0.4-cp313-cp313-musllinux_1_2_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.13 musllinux: musl 1.2+ x86-64

whr-2.0.4-cp313-cp313-musllinux_1_2_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.13 musllinux: musl 1.2+ i686

whr-2.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (173.6 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

whr-2.0.4-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl (182.4 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ i686

whr-2.0.4-cp313-cp313-macosx_11_0_arm64.whl (138.9 kB view hashes)

Uploaded CPython 3.13 macOS 11.0+ ARM64

whr-2.0.4-cp313-cp313-macosx_10_13_x86_64.whl (142.9 kB view hashes)

Uploaded CPython 3.13 macOS 10.13+ x86-64

whr-2.0.4-cp313-cp313-macosx_10_13_universal2.whl (270.2 kB view hashes)

Uploaded CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64)

whr-2.0.4-cp312-cp312-win_amd64.whl (119.7 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

whr-2.0.4-cp312-cp312-win32.whl (101.2 kB view hashes)

Uploaded CPython 3.12 Windows x86

whr-2.0.4-cp312-cp312-musllinux_1_2_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

whr-2.0.4-cp312-cp312-musllinux_1_2_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ i686

whr-2.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (174.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

whr-2.0.4-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (182.9 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686

whr-2.0.4-cp312-cp312-macosx_11_0_arm64.whl (138.9 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

whr-2.0.4-cp312-cp312-macosx_10_13_x86_64.whl (142.8 kB view hashes)

Uploaded CPython 3.12 macOS 10.13+ x86-64

whr-2.0.4-cp312-cp312-macosx_10_13_universal2.whl (270.0 kB view hashes)

Uploaded CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64)

whr-2.0.4-cp311-cp311-win_amd64.whl (119.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

whr-2.0.4-cp311-cp311-win32.whl (101.0 kB view hashes)

Uploaded CPython 3.11 Windows x86

whr-2.0.4-cp311-cp311-musllinux_1_2_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

whr-2.0.4-cp311-cp311-musllinux_1_2_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ i686

whr-2.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (174.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

whr-2.0.4-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (184.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

whr-2.0.4-cp311-cp311-macosx_11_0_arm64.whl (137.4 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

whr-2.0.4-cp311-cp311-macosx_10_9_x86_64.whl (141.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

whr-2.0.4-cp311-cp311-macosx_10_9_universal2.whl (267.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

whr-2.0.4-cp310-cp310-win_amd64.whl (118.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

whr-2.0.4-cp310-cp310-win32.whl (99.9 kB view hashes)

Uploaded CPython 3.10 Windows x86

whr-2.0.4-cp310-cp310-musllinux_1_2_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

whr-2.0.4-cp310-cp310-musllinux_1_2_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ i686

whr-2.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (173.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

whr-2.0.4-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (181.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

whr-2.0.4-cp310-cp310-macosx_11_0_arm64.whl (135.9 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

whr-2.0.4-cp310-cp310-macosx_10_9_x86_64.whl (140.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

whr-2.0.4-cp310-cp310-macosx_10_9_universal2.whl (265.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

whr-2.0.4-cp39-cp39-win_amd64.whl (117.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

whr-2.0.4-cp39-cp39-win32.whl (100.1 kB view hashes)

Uploaded CPython 3.9 Windows x86

whr-2.0.4-cp39-cp39-musllinux_1_2_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

whr-2.0.4-cp39-cp39-musllinux_1_2_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ i686

whr-2.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (173.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

whr-2.0.4-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (182.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

whr-2.0.4-cp39-cp39-macosx_11_0_arm64.whl (136.2 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

whr-2.0.4-cp39-cp39-macosx_10_9_x86_64.whl (140.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

whr-2.0.4-cp39-cp39-macosx_10_9_universal2.whl (265.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

whr-2.0.4-cp38-cp38-win_amd64.whl (118.3 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

whr-2.0.4-cp38-cp38-win32.whl (100.0 kB view hashes)

Uploaded CPython 3.8 Windows x86

whr-2.0.4-cp38-cp38-musllinux_1_2_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

whr-2.0.4-cp38-cp38-musllinux_1_2_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ i686

whr-2.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (173.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

whr-2.0.4-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (181.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

whr-2.0.4-cp38-cp38-macosx_11_0_arm64.whl (135.7 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

whr-2.0.4-cp38-cp38-macosx_10_9_x86_64.whl (140.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

whr-2.0.4-cp38-cp38-macosx_10_9_universal2.whl (264.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

whr-2.0.4-cp37-cp37m-win_amd64.whl (118.8 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

whr-2.0.4-cp37-cp37m-win32.whl (101.5 kB view hashes)

Uploaded CPython 3.7m Windows x86

whr-2.0.4-cp37-cp37m-musllinux_1_2_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.2+ x86-64

whr-2.0.4-cp37-cp37m-musllinux_1_2_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.2+ i686

whr-2.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (174.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

whr-2.0.4-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (186.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686

whr-2.0.4-cp37-cp37m-macosx_10_9_x86_64.whl (139.1 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

whr-2.0.4-cp36-cp36m-win_amd64.whl (119.9 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

whr-2.0.4-cp36-cp36m-win32.whl (101.8 kB view hashes)

Uploaded CPython 3.6m Windows x86

whr-2.0.4-cp36-cp36m-musllinux_1_2_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.2+ x86-64

whr-2.0.4-cp36-cp36m-musllinux_1_2_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.2+ i686

whr-2.0.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (172.8 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

whr-2.0.4-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl (186.8 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ i686

whr-2.0.4-cp36-cp36m-macosx_10_9_x86_64.whl (137.2 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page