Formula 1 Race Results Predictor
A machine-learning approach to predicting Formula 1 Grand Prix outcomes, built on every race from 1950 to 2022.
Formula 1 is one of the most prestigious and challenging motorsports in the world, and predicting the winner of the next Grand Prix is genuinely hard. Plenty of people try, but most of it rests on subjective opinion rather than data. We wanted to see how far a rigorous, data-driven approach could get.
The project is a comprehensive methodology for predicting driver performance in Formula 1 races. It combines six classification models with heavy exploratory analysis to work out which factors actually influence whether a driver reaches the podium, scores points, or fails to finish at all — considering weather conditions, driver and constructor standings, qualifying results, and race history, both present and past. That signal is buried across many separate datasets, and a large part of the work was merging them into something coherent.
Beyond the prediction itself, the goal was inference: not just producing a number, but using the models and their results to identify what actually contributes to a win. The answer that surprised us most was home advantage — the familiarity of the track and the support of a home crowd turned out to have a genuinely outsized effect on race outcomes.
-
Driver and Constructor DNF index
We introduced DNF indices for both drivers and constructors to quantify how much driver error and constructor error each contribute to race results. Reliability history carries real predictive signal that a simple finishing-position average washes out entirely.
-
Driver and constructor confidence
Engineered a confidence score calculated as the percentage of races a driver had completed without a DNF, with the equivalent for constructors — capturing relative reliability against the rest of the field rather than in isolation.
-
Home team effect
Built columns capturing the home advantage of drivers and constructors. This turned out to be the single most interesting finding of the project: competing in your own country has a humongous impact on outcome.
-
One-hot encoding across mixed data
Used one-hot encoding to transform both categorical and numerical data — nationalities, constructors, circuits — into a format the classifiers could consume.
-
Feature selection and hyperparameter tuning
Applied selection techniques to identify the genuinely important features and discard the ones we had wrongly assumed mattered, then tuned hyperparameters per model with k-fold cross-validation to avoid overfitting.
No single source had what we needed, so the data was assembled from several. The Ergast Data repository carried comprehensive historical Formula 1 data, but it had real gaps, and the rest had to be scraped. Six individual dataframes were collected and merged into one final dataset, keeping the features we believed influenced race outcome and stripping the redundant columns.
-
All races information
Every race from the first year of Formula 1 in 1950 through to 2022 — season, round, location, and the Wikipedia link for each.
-
All results
Iterating through every year and every race of each season to collect all drivers and their results, including nationality and the constructor they drove for, while discarding fields that carried no signal.
-
Driver standings
Points per driver after each race — only the top 10 drivers score, with a maximum of 25 points for a win.
-
Constructor standings
The top three constructors after every race, accounting for the fact that these points accumulate across the season rather than resetting.
-
Qualifying standings
The Ergast repository was unreliable here — the data had too many holes — so we web-scraped qualifying results directly from the official Formula 1 website instead.
-
Weather information
Ergast doesn't cover weather at all, despite it drastically affecting race outcome. We scraped conditions at the race location for the race duration from Wikipedia, falling back to OpenWeatherMap where Wikipedia had nothing.
Before modeling anything we went deep on the data itself — circuit analysis, driver nationality, championship wins, and the number of races won by each driver and constructor.
Clear trends emerged: the dominance of teams like Ferrari and Mercedes by both race wins and championships, and a meaningful split in DNF ratio between driver error and constructor error, which sharpened how much reliability matters in this sport.
We also investigated how drivers and constructors perform in their home races. The plots made it obvious — home ground carries a large advantage — and that observation went on to shape the entire feature engineering approach.
We trained six classification models to predict whether a driver would finish on the podium, finish in the points, or record a DNF: Logistic Regression, Decision Tree, Random Forest, Support Vector Machine, Gaussian Naive Bayes, and K-Nearest Neighbors. They were chosen for their standing in the literature and their fit to classification problems.
Parameters were selected through research and experimentation rather than defaults. The Decision Tree used the entropy criterion to measure split quality with a bounded max_depth to prevent overfitting; the Random Forest tuned n_estimators for the number of trees and max_features to limit the features considered at each split.
Every model was assessed with k-fold cross-validation — partitioning the data into k equal subsets and training and evaluating k times, each time holding out a different subset. That gave a far more reliable estimate of generalization than a single train/test split, and let us tune hyperparameters without overfitting to one particular partition.
Random Forest was ultimately selected as the final model. Although SVC scored marginally higher on raw accuracy, Random Forest provided feature importance scores, which let us identify which features were actually driving the predictions — the inference half of the project's goal.
Accuracy was the headline metric — the proportion of correctly classified instances over the total. Alongside it we tracked precision, recall, and F1 score, which account for the trade-offs between true positive, false positive, true negative, and false negative rates, and used cross-validation throughout to test robustness rather than a single lucky split.
The first pass was disappointing. Training on the raw combined dataset, four algorithms — logistic regression, a neural network regressor, random forest, and SVC — landed between 0.50 and 0.68 accuracy. Not useless, but nowhere near what we expected.
The cause was our own assumptions. We had thrown in a large number of variables we believed would influence race outcome. They did influence it, technically — just insignificantly, and collectively they drowned the signal that mattered.
Applying the engineered features — driver and constructor confidence, home team advantage, DNF rate — plus feature selection and hyperparameter tuning produced a substantial jump across every model. SVC reached 0.95, Random Forest 0.94, Logistic Regression and K-Nearest Neighbors both 0.93, and Gaussian Naive Bayes 0.87.
The lesson was unambiguous and is the one I've carried into everything since: the choice of model mattered far less than what the model was allowed to see.
Motorsport analysis leans heavily on human intuition and subjective opinion. Taking a strictly data-driven approach to predicting outcomes was itself part of the contribution, but the novel features were the real addition — driver and constructor confidence, home team effects, and DNF ratios and indices for both drivers and constructors. Together they captured nuances of motorsport performance that the standard variables miss entirely.
-
Sports betting
Data-driven likelihoods for podium, points, and DNF outcomes give bettors a grounded basis for decisions instead of form-guide intuition.
-
Team management
Insight into what actually contributes to driver and constructor success supports strategic calls on driver selection, race strategy, and car development.
-
Fantasy Formula 1
Predicting race outcomes lets you select the top-performing drivers and constructors within a limited fantasy budget, maximising expected points across a league.
-
Driver development
Analysing driver performance across multiple seasons and circuits surfaces which skills and attributes most predict success, useful for identifying talent early.
The models predict podium and points bands accurately, but predicting exact finishing positions at the same confidence remains out of reach. The other clear gap is that everything here is static — incorporating real-time race data would allow dynamic, in-race prediction rather than a single pre-race call.
With better data access, both are tractable. The broader approach isn't specific to motorsport either; the same methodology transfers to other sports and to domains like finance and marketing.
Further reading: Jaideep's write-up.