I Wrote a Program That Predicts the Top 100 Fantasy F1 Teams in 2022

Rok Strniša
4 min readMar 20, 2022

Introduction

A few friends invited me to join their Fantasy F1 league. I didn’t know what it was, and I don’t count myself as a massive fan of Formula 1, though I have quite enjoyed Netflix’s show Drive to Survive.

The key idea of Fantasy F1 is to choose 5 drivers and 1 constructor that will collect points for you during the season. Each driver and constructor has their own virtual price, e.g. a good driver will cost $30M. You only have $100M, so you cannot pick only the best drivers. The goal is for your team to collect as many points as possible, and win against your friends and others.

When I saw the Fantasy F1 game rules and point scoring pages, and started choosing my team, I realised that I could write a program that automatically finds a good team for me. That’s what I did.

Setting the Stage

Following the Pareto Principle, I was looking for a program that would give me fairly good suggestions without being massively complex. An involved solution would require lots of data from various sources over many years, an AI-based prediction model, etc. Instead, I went for something much simpler.

I decided to use only last year’s data, since it’s likely to be most relevant, because big changes happen often, including drivers’ experience, the capability of the cars, drivers switching teams, the chosen race tracks, the scoring system, etc.

One of the core simplifications I decided to make was to assume that the two drivers of a particular constructor in 2021 are considered equivalent to the two drivers of the same constructor in 2022. For example, this assumes that George Russell will be roughly as good in Mercedes 2022 as Valtteri Bottas was in Mercedes in 2021. I realise that this is a massive simplification; however, without this, the model would have been much more complex.

In addition, some race (and sprint) locations changed from 2021 to 2022. In my model, I assume that these changes don’t impact the scores. An alternative would have been to analyse past data for these locations, which would have required considering many other changes, so the extra complexity of doing so didn’t seem worth the potential improvement in prediction accuracy.

Finally, I decided that modelling the price changes of the drivers and race-to-race substitutions would have been too complex, so the model assumes that the prices don’t change and that the team stays constant. This means that the program predicts a good starting team, but one that may need to be evolved during the season as prices change and new information becomes available.

Writing the Model

The code for the program can be found here. It’s shared under the MIT Open Source Licence. I decided to use the Python programming language, which I believe is the best language for quickly iterating on small programs.

I obtained last year’s data from the relevant Wikipedia pages, e.g. here’s the one for the Italian Grand Prix 2021. The data occasionally required minor cleanup, like the removal of footnotes and adjusting for special cases (e.g. a driver not making a qualifying time, yet being allowed to race).

Once I had all of the 2021 data in CSV files, I wrote the code to score the drivers according to Fantasy F1 2022 scoring rules. For each race location, each driver was assigned a score that also contributed to their constructor’s score and one that did not (e.g. for being ahead of their teammate).

The code then does a brute-force search through all of the possible teams. For each team, it chooses the mega driver (3x multiplier) based on the top scores from the selected drivers in each half-season. Then, it picks the turbo driver (2x multiplier) for each race location based on the top score from the selected drivers, excluding mega drivers and drivers more expensive than $20M (as per the game rules).

There are 120887 valid teams. When the program completes after about 20 seconds on a modern machine, it prints out the top 100 teams. The results are shown in the following section.

Results

The winning team (with 5003 points) is:

  • Constructor: Red Bull Racing-Honda
  • Drivers: Max Verstappen, Sergio Pérez, Alexander Albon, Mick Schumacher, Kevin Magnussen.
  • Mega Driver(s): Max Verstappen @ {Canada, Monaco}.
  • Turbo Drivers: Alexander Albon @ {Belgium, Hungary}, Mick Schumacher @ {Abu Dhabi, Emilia Romagna}, Sergio Pérez @ {elsewhere}.
The winning Fantasy F1 team for 2022 according to the prediction.

The other teams in the top 100 can be seen here.

Here are some interesting observations of the results:

  • Red Bull is the constructor of choice in 87 out of the top 100 teams, while Mercedes appears in only 9. This is probably because Mercedes is too expensive in Fantasy F1 for the points it brings.
  • Sergio Pérez appears in 89 out of 100 top teams. This means that Sergio is likely the best driver for his virtual price.
  • In the top 100 teams, Max Verstappen appears 7 times, while Lewis Hamilton appears only twice.
  • Nico Hulkenberg and George Russell are not in any of the top 100 teams.

Final Thoughts

Writing this program was a lot of fun, and I hope you found this blog post interesting. Let me know what you think and follow me on Twitter for more.

--

--