Elo Ratings#

Open in Colab

The Elo rating system is a method for calculating the relative skill levels of players or teams in competitive games. Originally developed by Arpad Elo for chess, it has since been adapted for many other sports and competitions. In an Elo system, each player or team has a numerical rating that increases when they win matches and decreases when they lose, with the magnitude of change depending on the expected outcome of the match based on the rating difference between opponents. Higher-rated teams are expected to win against lower-rated teams, so an upset victory results in larger rating changes than a predictable outcome.

import penaltyblog as pb
elo = pb.ratings.Elo()

New Teams Default to 1500 Elo#

elo.get_team_rating("Team A"), elo.get_team_rating("Team B")
(1500.0, 1500.0)

Predict Match Results#

elo.calculate_match_probabilities("Team A", "Team B")
{'home_win': np.float64(0.5060806246811322),
 'draw': np.float64(0.20932932618252026),
 'away_win': np.float64(0.28459004913634756)}

Update Ratings#

elo.update_ratings("Team A", "Team B", 0)

Get New Ratings#

elo.get_team_rating("Team A")
1507.1987000039423

Interactive Example#

For a comprehensive, hands-on demonstration of the Elo rating system, try the interactive Colab notebook. The notebook walks you through loading match data, calculating ratings, and visualizing the results. You can modify the code, experiment with different parameters, and see how the ratings change in real-time.

Open in Colab