Skip to main content

Extended Elo rating system implementation exploiting the equivalence with logistic regression.

Project description

:chess_pawn: EloGrad

Extended Elo rating system implementation exploiting the equivalence with logistic regression.

EloGrad (Elo as Gradient descent) leverages the framing of the Elo rating system as logistic regression with stochastic gradient descent (see Elo as Logistic Regression for a walkthrough) to offer a collection of extensions to the rating system. All models are scikit-learn compatible.

:sparkles: Features

  • Standard Elo rating system for binary outcomes.
    • pandas and scikit-learn compatible.
    • See examples/nba.ipynb for an example using NBA data.
  • Elo rating system for binary outcomes with additional regressors, e.g. home advantage.

:book: Installation

You can install elo-grad with:

pip install elo-grad

:zap: Quick Start

Detailed example notebooks are provided in the examples/ directory. To install any extra dependencies required to run the notebooks install with:

pip install elo-grad[examples]

:clipboard: Minimal Example

from elo_grad import EloEstimator, Regressor

# Input DataFrame with sorted index of Unix timestamps
# and columns entity_1 | entity_2 | score | home
# where score = 1 if player_1 won and score = 0 if
# player_2 won and home is a boolean flag indicating if
# entity_1 has home advantage.
df = ...
estimator = EloEstimator(
    k_factor=20, 
    default_init_rating=1200,
    entity_cols=("player_1", "player_2"),
    score_col="result",
    init_ratings=dict(home=(None, 0)),
    additional_regressors=[Regressor(name='home', k_factor=0.1)],
)
# Get expected scores
expected_scores = estimator.predict_proba(df)
# Get final ratings (of form (Unix timestamp, rating))
ratings = estimator.model.ratings

:compass: Roadmap

In rough order, things we want to add are:

  • Poisson model support
  • Regularization (L1 & L2)
  • Support for Polars
  • Head-to-head ratings
  • Interaction terms
  • Other optimizers, e.g. momentum
  • Support for draws
  • Extend plotting support, e.g. plotly

:blue_book: References

  1. Elo rating system: https://en.wikipedia.org/wiki/Elo_rating_system
  2. Elo rating system as logistic regression with stochastic gradient descent: https://stmorse.github.io/journal/Elo.html
  3. Elo rating system for NFL predictions: https://fivethirtyeight.com/methodology/how-our-nfl-predictions-work/

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

elo_grad-0.3.1.tar.gz (249.0 kB view details)

Uploaded Source

Built Distribution

elo_grad-0.3.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file elo_grad-0.3.1.tar.gz.

File metadata

  • Download URL: elo_grad-0.3.1.tar.gz
  • Upload date:
  • Size: 249.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.4.20

File hashes

Hashes for elo_grad-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f6c04651a5132d9f674437114fb88d100440d3a41cf05f98d7884fad302d81b7
MD5 a665e181f313fbe535470f34e9323b57
BLAKE2b-256 4443772c6227638cfac7b4ca3d101ab64e43ec136588a367e4c21750e57f376f

See more details on using hashes here.

File details

Details for the file elo_grad-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for elo_grad-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 39484c48fb65859452a19f5dbc7d92ca3c2457ae5b966debe083456ea3440985
MD5 656cc74f1b54c3e6bf4082b1fd7be277
BLAKE2b-256 d33a603354f7344f70c6efd040acb9475e547a2e264d2ba9f23ac23df391f812

See more details on using hashes here.

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