Applying Elo rating to football

February 15, 2024

6 minutes read

If you're a football fan, you might be familiar with the ; if you're a chess fan, you might be familiar with the . If you're a fan of both, you might have wondered what would happen if we applied Elo to football.

A simple internet search will lead you to , where national teams are ranked based on their Elo points.

This article, however, is a step-by-step explanation of how that works, and my attempt at applying the system to real-world data.

But what is Elo?

In a nutshell, the calculates the relative skill level of players in games such as chess. It does so by assigning a numerical rating to each player.

The difference in ratings between two opponents predicts the probability of one player winning against the other, with the higher-rated players expected to win.

Although it's mostly linked to chess, today, Elo is used as a rating system in many other fields, sometimes not even related to sports.

How does it work?

In a traditional football league, the system is pretty straightforward: Teams get 3 points for a win, 1 point for a draw, and no points when they lose.

In Elo, things are different. After every game, the winning team takes points from the losing one.

This rating system is self-correcting; teams will gradually improve or decline relative to the system's predictions until the ratings reflect their true strength.

Real-world application

I applied the algorithm to Kaggle's .

It includes over 45000 matches, and while the dataset is updated quite often, the one I used for this post was last updated on February 10, 2024.

All teams were given an initial rating of 1000.

The full Python code is available on ; feel free to change it as you like.

Now let's see how the system behaves in the real world:

Final thoughts

This has been an exciting dive into applying Elo to international football.

But how would the system work in domestic leagues, where promotion and relegation come into play? Can Elo handle the changes in teams from season to season?

I look forward to tackling these questions in another article, hopefully later this year.

Thank you for making it this far, and feel free to check out the code on !

Method

The Formulas Behind Elo Ratings:

Where:
: is the new rating
: is the old (pre-match) rating.
and:
where:
is the weight constant for the tournament played, in our case:

Tournament
Friendly20
Other tournaments30
World Cup and continental qualifiers and major tournaments40
Continental championship finals and major intercontinental tournaments50
World Cup60

: The number of goals is taken into account by use of a goal difference (gd) index:

gd012+3
G001.5

: is the result of the game (1 for a win, 0.5 for a draw, and 0 for a loss).

: is the expected result (win expectancy):

Where:

: equals the difference in ratings plus 100 points for a team playing at home.