ποΈ How I Reached the Top 1% in Fantasy F1
Around a year and a half ago, I really got into Formula 1, ignited after binge-watching Netflix's "Drive to Survive." More than the racing itself, I loved watching the behind-the-scenes drama and the strategies devised by teams across the sport. My enthusiasm led me to discover F1 Fantasy, an engaging game where you build a team of five drivers and two car constructors within a budget, aiming to score the most points based on their real-world performance. For someone like me who loves numbers and games (hence why this substack exists tbh), this seemed like a lot of fun!
π Data Gathering and Cleaning
First, I needed the data to see how everyone performed over the past years so I could potentially predict how they would do in the future. Luckily, there's a company called Ergast which provided a data dump for all the analytics I wanted to perform. There were so many datasets involved, but after spending some time looking through and cleaning and merging data from various tables, I created a solid dataset ready for deeper exploration.
π Historical Performance Analysis
A critical step in my strategy was calculating how many points each driver would have historically scored. This retrospective analysis was pivotal, as it allowed me to evaluate driver performance effectively. Understanding past performance was essential to making informed decisions and projecting future success. I acknowledge that teams improve based on their budget and other factors, but since I lack concrete data sources for them, I chose to ignore them. Additionally, while younger drivers typically perform worse than experienced ones, I chose to overlook that aspect as well (sue me (actually donβt please)).
π° Budget Constraints and Cost Assignment
In F1 Fantasy, each driver and constructor comes with a market value. Assigning these costs to my potential team members added an exciting layer of complexity. Also, can we talk about how some of these terrible drivers cost so much? Each week, market values changed, requiring me to update my code regularly to reflect these fluctuations. This manual aspect killed me. I know I'm being dramatic, but I donβt want to write a Python scraper to get their values off the F1 website. This dynamic aspect of the game made team selection a continuously evolving challenge.
π Recent Performance Filtering
To ensure relevance, I filtered the data to include only recent years and excluded all drivers who have left. The performance of car constructors can vary significantly over time, and focusing on the latest data helped in making more accurate predictions. I am aware that different tracks affect constructors differently, but I chose not to dig deeper into that aspect. Beyond historical data, I stayed updated with current news and speculations within the F1 world to fine-tune my decisions (by fine-tuning, I mean I adjusted the average projected points based on what I saw on TV).
π§ Optimization Model
The heart of my strategy lay in the application of a linear optimization model, specifically using PuLP linear optimization. This technique enabled me to maximize my team's potential points while adhering to the budget constraint. The model played a crucial role in fine-tuning my team selection, balancing cost and expected performance.
Here's how the process generally works:
Defining the Objective Function: I started by defining the objective I wanted to optimize. In this case, it was maximizing the total points of my F1 Fantasy team.
Setting Constraints: I specified all the limitations or constraints I needed to adhere to. For example, the budget constraint limited how much I could spend on selecting drivers and constructors.
Modeling the Problem: Using PuLP, I translated the objective function and constraints into a mathematical model. This involved converting the rules of the game, such as budget constraints and player point values, into mathematical equations.
Solving the Model: Once the model was defined, I utilized PuLP to employ various algorithms to find the optimal solution. The goal was to maximize the objective function (total points) while ensuring that all constraints (such as budget limitations) were satisfied.
Analyzing the Results: After solving the model, I analyzed the results to determine which combination of drivers and constructors would maximize my team's potential points while staying within budget. This involved reviewing the output provided by PuLP and making informed decisions based on the mathematical optimization results.
π Result: Top 1% Success
After the 2023 season, my model had propelled me into the top 1% of all fantasy teams. It was very fun watching the power of data-driven decision-making and strategic optimization.
If you're an F1 fan or just love strategic games, I highly recommend giving F1 Fantasy a try. It adds a new dimension to watching the races, making each event even more exhilarating. You can join the game at F1 Fantasy.
For those interested in the technical details or looking to build upon my work, I've made my code available on GitHub. Feel free to explore and enhance it for your own F1 Fantasy adventures: GitHub Repository.