02 — Personal Analytics / Scouting

AI Player Scouting Model

An unsupervised machine learning system that clusters IPL batters by behavior, not batting position — surfacing four distinct roles across 17 seasons of ball-by-ball data, with a deployed Streamlit interface and a strategy-aware team builder.

DomainT20 Cricket / IPL
ApproachUnsupervised ML
ModelK-Means · k=4
StatusDeployed
01 / Problem

Batting position lies. Behavior doesn't.

Cricket analysts evaluate batters by their batting position and aggregate strike rate. Both are misleading. KL Rahul has batted everywhere from one to five — averaging him into "opener" or "middle-order" flattens what he actually does on the field. And a single career strike rate of 150 looks identical whether the batter scores at 200 in the death and 100 in the powerplay, or runs at a flat 150 throughout. Those are two completely different cricketers.

Franchise scouts know this intuitively. They watch tape, sort by phase, and build mental role categories — finisher, anchor, accelerator, all-phase weapon. The problem is that this knowledge lives in heads, not in databases. There's no quantified, league-wide role label that a strategist can filter on when building an XI or shortlisting auction targets.

This project builds that label from the data itself.

02 / Solution

Cluster the behavior, not the lineup.

Approach

Every IPL batter is represented as a point in 18-dimensional feature space — six performance metrics (runs, balls faced, dismissals, fours, sixes, strike rate) measured separately across three game phases (Powerplay, Middle, Death). K-Means clustering groups batters whose phase profiles look alike, regardless of where they bat in the order.

The output is a role label per batter, mapped to four archetypes: Powerplay Specialist, Middle Overs Anchor, Death Overs Finisher, and All-Phase Versatile. From there, a team builder accepts strategic weights ("I need four finishers, two PP specialists, three anchors") and constructs the corresponding XI.

Roles Discovered
CLUSTER 0
All-Phase Impact
V Kohli
RG Sharma
S Dhawan
CLUSTER 1
Powerplay Specialist
AD Russell
AB de Villiers
CLUSTER 2
Middle Overs Anchor
V Sehwag
F du Plessis
JC Buttler
CLUSTER 3
Death Overs Finisher
MP Stoinis
KS Williamson
SP Narine
03 / How It Works

From ball-by-ball to role label.

01

Ingest 17 seasons of Cricsheet data

Ball-by-ball deliveries joined with match metadata on match_id. Each row is one delivery: batter, bowler, runs, wicket flag, over, ball. Coverage: IPL 2008 through IPL 2024.

pandascricsheet
02

Tag each delivery with a phase

Overs 0–6 → Powerplay. Overs 7–15 → Middle. Overs 16–20 → Death. This is the axis the whole model rotates around: every stat below is computed three times, once per phase.

feature engineering
03

Aggregate to one row per batter

GroupBy batter × phase, compute six stats per group, pivot wide. Result: one row per batter, 18 columns (6 stats × 3 phases). MinMax normalize so high-magnitude features (runs) don't dominate distance calculations against rate features (strike rate).

groupbyMinMaxScalerpivot
04

Find the right k with the elbow method

Fit K-Means for k=2 through 10, plot inertia, find the bend. K=4 is the clear inflection — and it lines up with cricket's natural structure: three phases plus one versatile catch-all.

scikit-learnelbow method
05

Cluster, label, validate

Run K-Means with k=4. Inspect each cluster's centroid profile — a centroid with high death-runs and high death-boundary% is the Finisher cluster. Hand-assign role names by reading the centroids. Cross-checked against Agglomerative Clustering to expose borderline players (Russell flips between groups — flagged honestly).

KMeansAgglomerativeClusteringPCAt-SNE
06

Build the strategy-aware XI

Given a role-weight dictionary ("I want 2 PP specialists, 3 anchors, 4 finishers, 2 versatile"), the team builder pulls top-scored players per role until 11 slots are filled. A fallback redistributes weight if a role is under-supplied.

composition logicrole weighting
07

Ship to Streamlit + Tableau

Deployed as an interactive Streamlit app with player radar comparisons and a team-builder UI. A Tableau dashboard sits alongside for static league-wide analysis. Both publicly accessible.

StreamlitTableaumatplotlib
04 / Results

The numbers.

Seasons Analyzed
17
IPL 2008 through IPL 2024 — every ball, every batter.
Feature Dimensions
18
Six stats × three phases — each batter as a point in 18-D space.
Roles Discovered
04
Validated against domain intuition: PP, Middle, Death, All-Phase.
Simulated Team Score
161.4
Sample XI built from the model — par T20 total against an average attack.
Phase Breakdown
54.7 / 55.8 / 50.9
Powerplay / Middle / Death — balanced output across phases.
Deployment
live
Streamlit app + Tableau dashboard, both public.
05 / Technical Decisions

Every choice has a reason.

Why K-Means
over alternatives?
K-Means gives you centroids you can read — and that matters when the audience is half data scientists, half cricket coaches. A coach wants to know what defines the finisher cluster; pointing at a centroid with high death-runs and high death-boundary% explains the role in one sentence. DBSCAN doesn't give you that. Hierarchical clustering does but is harder to update when new data lands. K-Means is the right cost-quality balance for this domain.
Why phase-wise
features?
Aggregate strike rate is the most misleading stat in cricket. A batter at 150 SR who scores 200 in the death and 100 in the PP is a completely different cricketer from one who runs flat at 150 — and the aggregate number can't tell them apart. Splitting every stat by phase makes the model see what scouts see: profile, not summary.
Why k=4
specifically?
Elbow method showed a clear inertia bend at k=4. It also aligns with cricket's natural structure — three phase specialists plus one versatile bucket. Honest caveat: silhouette score was not computed in v1. The k=4 choice is defensible by domain logic and the elbow plot, but it isn't statistically air-tight. V2 priority.
Why both K-Means
and Agglomerative?
Cross-validation. Where the two methods agree, confidence is high. Where they disagree — AD Russell flipping between Powerplay Specialist and Death Finisher — the player is genuinely ambiguous, and that ambiguity is itself useful information for a scout. Better to expose the disagreement than hide behind one method.
Why MinMax
over StandardScaler?
MinMax pushes everything to [0, 1] regardless of distribution. K-Means uses Euclidean distance — without normalization, runs (thousands) would dominate strike rate (~100) and the clusters would just be ranking by total runs. StandardScaler would work too, but MinMax keeps the interpretation cleaner: every feature is on the same 0-to-1 scale for the inertia plot to make sense.
06 / Limitations

What this model can't see.

An honest portfolio is more useful than a polished one. Here are the specific weaknesses I'd attack in V2 — and the order I'd attack them.

01
No opposition context. Kohli vs Bumrah and Kohli vs a debutant medium-pacer are averaged into the same strike rate.
02
No venue context. Batting at Chinnaswamy (high-scoring) and Chepauk (low-scoring) look identical to the model.
03
The Dhoni-in-PP problem. Hard clustering can't tell "doesn't bat here" from "is bad at batting here." A batter who almost never bats in the Powerplay gets pulled into PP-themed clusters by absence rather than presence.
04
No silhouette validation. Elbow method chose k=4, but I didn't compute silhouette or Davies-Bouldin. The k choice is defensible, not rigorous.
05
Hard cluster assignments. A player is either a Finisher or an Anchor — no middle ground. A Gaussian Mixture Model would give soft probabilities ("60% Anchor / 40% Finisher"), which is more useful for borderline cases.
06
Batters only. Half the squad — bowlers — isn't analyzed in this version. A sister project is the obvious next build.
07
Data ends at IPL 2024. Two seasons stale. Refresh is mechanical but needs to happen before this informs real auction decisions.
Version 2 — Build Order

What ships next.

  • 01Replace K-Means with Gaussian Mixture Model — get soft cluster probabilities per batter.
  • 02Add opposition strength tier and venue category as feature axes.
  • 03Add silhouette score + Davies-Bouldin to validate k properly.
  • 04Per-phase minimum-balls filter to eliminate the Dhoni-in-PP problem.
  • 05Build a real undervalued-gem detector: cluster fit × inverse auction price.
  • 06Refresh data through IPL 2026 and add a sister model for bowlers.
Try it / Read it

The model is live. The code is open.

Pull up the Streamlit app, run a head-to-head radar, build an XI under your own match strategy. Or read the notebook end-to-end.