Ram Thatham

ATP Match Predictor

A model that prices professional tennis matches, the warehouse under it, and the things that broke on the way. Built in 2026 with AI coding agents I direct.

Data
199K matches
3.4M ranking rows
Stack
DuckDB · dbt · Dagster
XGBoost · MCP
Tests
768 automated
688 pytest · 80 dbt
Code
Private repo
on request
01Result

It picks the winner 65.2% of the time on matches it never saw.

65.2% 95% CI 63.7 to 66.6 · n = 4,278 · Jan 2025 to May 2026

That beats both simple rules, but only by 0.8 points over ELO, which is inside the margin of error. A good rating system carries most of the signal in tennis. What the model adds is a probability that means what it says, and section 05 shows that.

AUC 0.717 · log loss 0.615 · Brier 0.214. The holdout was touched once, for this report.

02Try it

Pick two players.

Every pair below was priced by the real model before this page loaded. Nothing runs on a server.

Surface
Format

What moved the number

Fourteen players: the top twelve by ELO on the date below, plus João Fonseca and Learner Tien. Each match is priced as a quarterfinal played that day, so real rest and recent workload count. A long layoff or a heavy fortnight moves the number. Bars are the model's own feature attributions in log-odds, grouped.

03What I built

A warehouse first, a model second.

Most of the work is in getting the data right. The model is a few hundred lines; the pipeline that feeds it honest features is most of the repo.

  1. SourceJeff Sackmann's tennis_atp, pinned at June 2026Then the TML database for results after the snapshot
  2. IngestAn 8-check gate that fails closedA failed load leaves the warehouse untouched
  3. WarehouseDuckDB: 199K matches, 3.4M ranking rows
  4. Transformdbt: 4 staging, 3 intermediate and 4 mart modelsA 196K-row, 65-column feature mart, point-in-time correct
  5. OrchestrateA Dagster asset graph, with blocking checks
  6. ModelXGBoost on 55 featuresSurface-specific ELO ratings built as their own chains
  7. EvaluateOne look at a held-out 2025-26 sliceReported next to rank and ELO baselines, with intervals
  8. ServeA 7-page Streamlit app and a read-only MCP serverBoth run locally; nothing is hosted
04Kept honest

Split by time, so the test is the future.

Shuffling matches into train and test would let 2024 results teach the model about 2023. Every split here is a block of calendar time, and the test block comes last.

Train1991–2022101,788 matches
Early stop20232,913
Calibration20243,138
Holdout2025–264,278
  1. Features only see matches that came strictly before. Eight window frames enforce it, and 17 dbt tests check it, no-future-leakage among them.
  2. The holdout is never used to fit, stop, tune or calibrate anything.
  3. The build fails if accuracy tops 72% or AUC tops 0.80. Numbers that good in tennis mean a leak, not a good model.
  4. Two runs on the same machine give identical numbers.
05Calibration

When it says 73%, the favourite wins about 70% of the time.

Sort the 4,278 holdout matches into ten equal bins by predicted probability, then check how often the predicted side actually won. A calibrated model sits on the diagonal.

Raw model probabilities, ten quantile bins of about 428 matches each.

I also fit an isotonic calibrator on 2024, the usual next step. On the holdout it made things slightly worse (Brier 0.214051 against 0.213985 raw), so the model ships its raw probabilities and the report says why.

06What drives it

The rating gap does most of the work.

Gain is how much each feature improved the model's splits during training. ELO leads by a distance. The surface ELO, which I built as its own rating chain for each surface, comes second.

07What broke

Four bugs worth telling.

01

Builds that wouldn't repeat

Training twice gave two different models. I traced it to ties in DuckDB window functions and duplicate ranking rows in an ASOF join. A total-order tie-break now gives byte-identical marts.

02

A backtest that looked too good

A rebuild renumbered the matches, but one downstream table kept the old IDs, so a backtest joined to the wrong matches and looked far better than it was. Every build is now stamped, and a mismatch blocks the read.

03

A leak the audit caught

A full code audit raised 25 findings. One was real: outcome labels could be reached through the views meant to hide them. Fixed.

04

The data source went offline

In June the upstream repo disappeared. The pinned snapshot stays the only training data. New results come from a second source through the 8-check gate, which matched the snapshot on 99.4% of 5,792 overlapping matches against a 99% floor I set before the first pull.

08For agents

A safe way for an AI agent to query the warehouse.

Warehouse Copilot is a read-only MCP server with 7 tools. Every query is parsed down to a single SELECT, checked against a default-deny table allowlist, capped at 1,000 rows and 5 seconds, and logged. Label-stripped views keep match outcomes out of reach.

A 24-question gold regression gate runs through the same governed path as a blocking Dagster check, so a build that changes the gold answers or trips the guardrails can't ship. Three rounds of adversarial agent review closed 17 bypasses.

09Live

Four live predictions so far.

On August 31 the model priced four US Open second-round matches and logged them before play. All four have settled, and the favourite won each one. Four matches is an anecdote, not a result. The ledger and the drift report are there for when the count is big enough to mean something.