Flagship project
01 — Personal Analytics / End-to-End ML

ODI Full Match Predictor

A 3-stage end-to-end ML system predicting an ODI cricket match from before the toss to the final ball. Calibrated probabilities, temporal train/val/test splits, ICC-style ratings, deployed as a public Streamlit app. Trained on 2,520 ODIs and 1.3 million deliveries from Cricsheet.

Domain ODI Cricket
Approach 3-Stage Pipeline
Stack LR · GBM · XGBoost
Best Result 91% Death Acc
Status Live · Public
01 / Problem

Broadcast win-probability widgets are opaque. And often wrong.

Open any cricket telecast. There's a win-probability bar at the bottom of the screen. It moves. Sometimes it makes sense; sometimes it jumps 15% on a single dot ball. Nobody knows where the number comes from, whether it's calibrated, what features it uses, or how the model was trained. Most existing cricket-prediction tools fall into one of two camps: pre-match odds models that ignore the live state, or live-state models that ignore team strength and form. No tool covers the full match continuously, transparently, with calibrated probabilities.

And no public tool lets you ask the question scouts and broadcasters actually want to ask: "swap this player into the XI — what happens to the win probability?"

That's the gap this project closes.

02 / Solution

Three stages. One match. End to end.

The pipeline outputs a continuous, calibrated win probability from before the toss to the final ball. Each stage uses a different model — chosen for the data it has, not by default.

Stage 01
Fires: before the toss

Pre-match probability

Logistic Regression · Calibrated

13 features per match — team Elo ratings, batting/bowling rating differentials, recent form, head-to-head record, toss winner, batting order, venue intelligence. Trained on 2,005 matches up to 2022. Beat XGBoost and Random Forest at validation.

Test Accuracy
57.7%
Stage 02
Fires: every over of innings 1

1st innings projection

Gradient Boosting + Quantile

Snapshot the match at every over-end. 13 features: cumulative state, current run rate, phase encoding, venue context, team Elo. Point predictor plus q=0.10 and q=0.90 quantile regressors for honest 10/90% confidence bands.

Death-Over MAE
±13.1
Stage 03
Fires: every over of innings 2

Chase win prob

XGBoost · Calibrated

14 features per over-snapshot — including the killer rrr_crr_diff (35.7% importance) and the pre-match probability as a prior. Sharp nonlinearities + sufficient samples make XGBoost the right call here.

Death-Over Acc
91%
03 / How It Works

From YAML to live win probability.

01

Parse Cricsheet YAMLs

Cricsheet ships each match as a YAML — match info plus a list of innings with delivery-level records. The tricky bit: delivery keys are floats like 0.1 and 14.7 meaning "over 0 ball 1" and "over 14 ball 7". Splitting on the decimal parses them. The parser handles 2,520 files into clean DataFrames.

PyYAML pandas Cricsheet
02

Build ICC-style team Elo ratings

Standard Elo with two ICC-specific tweaks. Variable K-factor: K=50 for World Cup / Champions Trophy matches, K=32 for bilateral series — a loss in a tournament says more than a loss in a friendly. Recency weighting: last 12 months count at weight 1.0, 12–24 months at 0.5, older ignored. Sanity check: top 6 weighted ratings come out as India, Australia, England, NZ, SA, Pakistan. ✓

Variable-K Elo recency weighting
03

Compute rolling player ratings

Per innings: batting rating = runs × (SR/100) × opposition × venue × innings_factor — rewards volume, speed, tougher bowling, harder pitches, chasing pressure. Bowling rating = wickets × 25 + dots × 0.5 − economy × 3. Each player gets a 10-match rolling weighted average (recent = 1.0, 10 ago = 0.1) plus a 5% decay if inactive 60+ days.

rolling avg opposition factor decay
04

Build per-venue intelligence (10 stats per ground)

Average 1st-innings score, PP/Middle/Death scoring averages, chasing win rate, toss-bat win rate, spin vs pace wicket ratio, frequency of 300+ scores. Wankhede and Chennai have completely different signatures — venue features capture that. Spin classification uses an economy < 5.5 heuristic when bowl_style metadata is missing.

groupby aggregation venue features
05

Temporal split — non-negotiable

Train on matches up to 2022-12-31 (2,005 matches). Validate on 2023 (186 matches) — used for model selection and calibration fitting. Test on 2024+ (201 matches) — never touched until the end. A random split would let the model train on 2024 and test on 2020. That's deployment-impossible and unfaithfully optimistic.

temporal split no leakage
06

Train Stage 1 — Logistic Regression (and why it won)

All three models compared on the validation set: LR 68.8%, RF 65.1%, XGBoost 59.1%. LR wins because with 13 features × 2,005 rows, tree boosting has too many degrees of freedom and overfits. The team-strength-to-win-probability relationship is roughly monotonic — LR's linear decision boundary is the right inductive bias. Match the model to the data, not the trend.

scikit-learn LogisticRegression model comparison
07

Train Stage 2 — Gradient Boosting + Quantile bands

Snapshot the match state at every over-end (50 per match × 2,392 valid matches = ~120k rows). Train a GradientBoostingRegressor for the point prediction, plus two XGBRegressors with objective='reg:quantileerror' at q=0.10 and q=0.90 for the confidence band. Bundle all three into one .pkl. Top feature: current run rate, ~55% importance.

GBM XGB Quantile snapshot per over
08

Train Stage 3 — XGBoost on live state

Same training size as Stage 1, but live state has sharp nonlinear interactions — rrr_crr_diff crossing zero is a regime change, wicket cliffs after a fall, partnership momentum compounding. Tree boosting handles these well. The pre-match probability is itself a feature here — Stage 3 inherits Stage 1's prior instead of relearning it.

XGBoost forward info flow rrr_crr_diff
09

Calibrate both classifiers

Wrap both Stage 1 and Stage 3 in CalibratedClassifierCV with isotonic regression, fitted on the 2023 validation set. A 70% prediction has to mean a true 70%, or the app lies. Brier scores: pre-match 0.248 (honest, barely beats random 0.25 — the modesty is real), 2nd innings 0.146 (well-calibrated).

CalibratedClassifierCV isotonic Brier score
10

Ship to Streamlit Community Cloud

Three .pkl bundles + small ratings CSVs load at cold-start (~10s). Phase 1: pre-match setup — probability. Phase 2: 1st innings, score per over — projected total + win prob. Phase 3: 2nd innings, score per over — chase prob. 12 MB repo (training data lives elsewhere). Push to GitHub → Streamlit auto-redeploys → public URL stays live.

Streamlit GitHub Actions 12 MB repo
04 / Results

The honest numbers.

Matches Modeled
2,520
Full IPL/ODI match history through 2025.
Deliveries Processed
1.3M
Ball-by-ball records across 23 years.
Test Set Size
201
Matches from 2024+, never seen during training or tuning.
Pre-match Brier
0.248
Better than random (0.25) — modesty is honest. Pre-match is the hard stage.
2nd Innings Brier
0.146
Well-calibrated. A 70% prediction means a true 70%.
Death-Over Accuracy
91%
The headline result. Strongest where it matters most — broadcast prime time.
Stage 02 — 1st Innings score MAE by over block
test set · uncertainty decays sharply with each phase
Over range
MAE (runs)
Insight
Overs 1–10
48.7
Early overs — only 60 balls of CRR signal, team Elo is the strongest feature
Overs 11–20
39.9
CRR stabilizing, wicket pattern starting to inform
Overs 21–30
30.4
Middle overs — half the innings done, projection sharpens
Overs 31–40
24.0
Acceleration phase, partnership data adds signal
Overs 41–49
13.1
Death overs — final score within ±13 runs. Tight bands.
Stage 03 — 2nd Innings chase accuracy by phase
test set · the further the chase goes, the sharper the signal
Phase
Accuracy
Insight
Powerplay (1–10)
72.1%
Pre-match prior dominates; live state still noisy
Middle (11–30)
79.0%
RRR-CRR diff starts dominating the prediction
Middle (31–40)
84.5%
Wicket cliff patterns become visible
Death (41–50)
91.0%
The headline. Sharp interactions, abundant signal, calibration pays off.
05 / Limitations

What this doesn't see — yet.

The honest gaps between this and a production-grade broadcast-quality system. Each one is a real V2 target, not hand-waving.

01
Pre-match test accuracy is 57.7%. Honestly modest. The val/test gap (68.8% → 57.7%) suggests era drift between 2023 and 2024+ cricket. Stage 1 is the weakest link in the pipeline. Live stages compensate, but pre-match deserves a V2 overhaul with player-level features.
02
No player-level live model. The chase model uses batting_quality — the team's average rating — not the specific batter at the crease. A 200-rated tailender at 80/3 and an 800-rated opener at 80/3 look identical to Stage 3.
03
No weather or pitch report features. Green-top or flat deck, dewy or dry — none of it visible to the model. Only the venue's historical average is used.
04
Manual score entry. No cricket-API integration. The user types in the score per over. Workable for a portfolio demo, not for a broadcaster.
05
Win probability is a point estimate. No uncertainty band on the probability itself. "62% likely" might really be 62% ± 8% on small evidence — V2 bootstraps the predictions to surface that.
Version 2 — Build Order

What ships next.

  • 01Player-level live model — wire the specific batter and bowler into Stage 3's feature vector.
  • 02Live data ingestion via Cricbuzz or ESPN Cricinfo API.
  • 03Bootstrap win-probability uncertainty bands.
  • 04Weather + pitch report features from pre-match conditions where available.
  • 05Model monitoring infrastructure — log predictions and outcomes for drift detection.
  • 06Parquet caching for ratings CSVs — bring cold-start under 3 seconds.
  • 07T20 variant — same engine, retuned phase boundaries and feature weights.
— The system is live. Pick a match. —

Run the full match. Live.

Public Streamlit app — set up a match, enter scores per over, watch all three stages predict in real time.