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.
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.
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.
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.
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.
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).
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.
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).
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.
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.
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.
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.