9 min read

I Trained AI on 95,491 Sports Matches. It Got 85% Right

Source: http://x.com/i/article/2031376454936588288

Someone collected every single professional tennis match played in the last 43 years, fed all of it into a machine learning model, and asked one question: can you predict who wins?

The model said yes.

It then went on to correctly predict 99 out of 116 matches at this year's Australian Open, a tournament it had never seen during training, including every single match the eventual champion won.

85% accuracy on live professional sports.

Built on a laptop with free data and open-source code.

I'm going to walk you through exactly how it works, from the raw data all the way to the final prediction

because what this guy built is genuinely one of the most impressive solo AI projects I've come across.

His nickname is @theGreenCoding

Part I: 43 Years of Data in One Folder

The whole thing starts with data, and he found what he calls the Holy Grail of sports data.

Every single ATP (Association of Tennis Professionals) match from 1985 to 2024.

Every break point, every double fault, every forehand, every backhand, heights, ages, rankings, head-to-head records, the surface the match was played on, and every point-level statistic the ATP has ever tracked.
Image

40 years of CSV files sitting in one folder.

When he opened the full thing it crashed his computer, summoned three statisticians and made Excel beg for mercy.

Image

But he didn't stop at raw match data.

For every single one of the 95,491 matches in the dataset he calculated a massive set of derived features: the head-to-head record between the two specific players, their age difference, height difference, win rate over the last 10, 25, 50 and 100 matches, first serve win percentage differential, break points saved differential, and a custom ELO rating system that he adapted from chess and that turned out to be the most powerful predictor of all.

Image

The final dataset: 95,491 rows and 81 columns.

Every professional tennis match played in the last four decades, enriched with dozens of calculated features that no raw dataset would give you out of the box.

Part II: The Algorithm That Learned From the Titanic

Before running any of this through a classifier he wanted to understand how the algorithm actually works, so he did something most people would never bother with and built a decision tree from scratch using nothing but numpy. To explain the concept he started with a completely different dataset: the Titanic.

Image

A decision tree works like a choose-your-own-adventure book where instead of fighting dragons you're classifying passengers as survived or not survived by asking yes/no questions about their data. Take passenger number 11, Miss Elizabeth Bonnell.

The tree asks: did she pay more than £20 for her ticket? Yes she did.

Next question: was she in first class? Yes. The tree predicts she survived, and she actually did.

Image

How does the algorithm decide which questions to ask?

It starts with all the data and finds the single variable that best separates survivors from non-survivors.

For the Titanic that turned out to be passenger class.

First class passengers go one way, everyone else goes the other.

But not everyone in first class survived, so there's still impurity.

The algorithm finds the next best split, which is sex.

Every female in first class survived. That's what's called a pure node, and the branch stops there.

Image

You keep repeating this process until you've built a fully grown tree that covers every possible combination in the data:

Image

And here's a cleaner visual version trained with sklearn:

Image

His custom numpy version worked perfectly on small datasets.

When he tried it on 95,000 tennis matches it was painfully slow, so for the real training he switched to sklearn's optimized version.

Same logic, just much faster.

Image

Part III: The Variable That Split Winners From Losers

Before fitting any model he plotted every variable against every other variable in a massive scatter plot matrix called an SNS pairplot, looking for anything that might help separate match winners from losers.

Image

Most features were noise. Player ID is obviously useless. Win rate differences showed some mild patterns but nothing clean enough to build a reliable classifier on.

One variable stood out far above everything else:

ELO difference

The scatter plots for ELO_DIFF and ELO_SURFACE_DIFF showed clear, obvious separation between the two classes in a way that no other feature came close to.

This is what led him to build the most important part of the entire project.

Part IV: A Chess Rating System Applied to Tennis

ELO is a method for estimating a player's skill level and it's most commonly used in chess, where Magnus Carlsen sits at the top of the world rankings with a rating of 2833

Image

He decided to apply the same system to tennis. Every player starts at 1500. Win a match and your rating goes up, lose and it goes down.

The key mechanic is that the amount you gain or lose depends on the rating gap between you and your opponent, which means beating a higher-rated player gives you more points than beating a lower-rated one, and losing to someone weaker costs you more.

To show how the formula actually works he used the 2023 Wimbledon final between Carlos Alcaraz (rated 2063) and Novak Djokovic (rated 2120):

Image

Alcaraz won in a shocking comeback.

After running the result through the formula, Alcaraz gained about 14 points and Djokovic lost about 14

Simple arithmetic, but surprisingly powerful when applied to 43 years of matches.

Part V: Three Lines Above Everyone Else

Here's where it starts to get really interesting. He plotted Roger Federer's ELO rating over every single match of his career, from the very beginning to retirement.

Image

The curve tells his entire story. You can see the early climb, the peak dominance around match 400, the late-career fluctuations, all visible in one chart.

But the truly insane visualization happens when you plot Federer against every other player who has ever competed on the ATP tour since 1985

Image

Three lines tower above everyone who has ever played professional tennis.

Federer in green, Nadal in blue, Djokovic in red.

The Big Three isn't just a nickname, it's mathematically visible when you plot 40 years of match data.

According to his custom ELO calculations the current best player in the world is Jannik Sinner at 2176, followed by Djokovic at 2096 and Alcaraz at 2003:

Image

Remember that Sinner is ranked number one here. It matters later.

VI: The Surface Problem

In tennis the surface you're playing on changes everything about the game.

Clay courts are slow with high-bouncing balls. Grass is fast and low. Hard court falls in between.

Players who dominate on one surface can completely collapse on another.

So he built separate ELO ratings for each surface: clay, grass, and hard

Image

The results confirmed what every tennis fan already knows but now with 43 years of mathematical proof behind it.

Rafa Nadal's clay ELO is the highest rating he calculated for any player on any surface in the entire dataset.

14 French Open titles, 112 wins versus 4 losses at Roland Garros.

The ELO formula doesn't care about narratives or reputations, it just processes wins and losses, and it arrived at the exact same conclusion as four decades of sports journalism.

VII: From 74% to 85%: The Climb

With the data prepared and the ELO system in place he started training classifiers and the progression tells an interesting story about how much the choice of algorithm matters.

Decision Tree: 74%

A single decision tree trained on the full dataset achieved 74% accuracy.

That sounds decent until you find out that simply predicting winners based on ELO difference alone gives you 72%

The decision tree was barely adding anything on top of the rating system he already built by hand.

Random Forest: 76%

The problem with a single tree is high variance, it's too sensitive to whichever specific subset of data it happened to train on.

The standard fix is a Random Forest: build dozens or hundreds of trees, each one trained on a different random subset of the data with a different random subset of the features, and combine all their predictions through a majority vote.

Image

94 individual decision trees, each unique, all voting together on who wins each match.

Image

The result was 76%. Better, but he hit a wall.

Grid search across dozens of hyperparameter combinations, different feature engineering approaches, tweaking the data in every way he could think of, and nothing moved the accuracy past 77%

VIII: XGBoost: 85%

Then he tried XGBoost, which he describes as a Random Forest on steroids.

The fundamental difference is that instead of building trees independently and averaging them, XGBoost builds them one after another where each new tree specifically focuses on correcting the mistakes that the previous trees made.

It also uses regularization to prevent overfitting and intentionally keeps individual trees small so they can't memorize the training data.

Image

The result was 85% accuracy, a massive jump from the 76% ceiling he couldn't break through with Random Forests.

Same data, same features, the only thing that changed was the algorithm.

XGBoost identified the same three features as most important:

ELO difference, surface-specific ELO difference, and total ELO

The custom chess-inspired rating system he built turned out to be the strongest predictor of professional match outcomes in the entire 81-column dataset.

For comparison he also trained a neural network on the same data, which achieved 83%. Good but still worse than XGBoost.

On this particular dataset the tree-based method won.

IX: The Moment of Truth: Australian Open 2025

Everything described above was trained on data through December 2024

The Australian Open in January 2025 was completely outside the training set, which made it a perfect test of whether the model actually learned something real about the sport or just memorized patterns from the past.

Image

He fed the complete tournament bracket into the model and let it predict every single match.

Out of the 116 matches he could find sufficient player data for, the model correctly predicted 99 of them and got only 17 wrong.

That's 85.3% accuracy on a live Grand Slam tournament that wasn't part of the training data.

Image

And the biggest prediction of all: the model correctly called that Jannik Sinner, the player his ELO system ranked number one in the world, would win every single one of his matches through the entire tournament.

The AI predicted the Grand Slam champion before the first ball was hit. > A university student with a laptop, Python, and data that anyone can download from the internet built a sports prediction model that achieves 85% accuracy and correctly called the winner of a major championship before it started. No proprietary data, no expensive infrastructure, no research team. His code is on GitHub and the entire project is reproducible. The tools to build something like this have never been more accessible, and the edge has never been more available to anyone willing to actually put in the work.

in part two: i'll tell you how he managed to improve his model, but only if you subscribe, deal?