A single R script that pulls match data from Cricsheet and ranks team pairings and venues by a simple predictability score. In our run the download worked but the script stopped on a package error, which this post explains and works around.
Open-Source Tools · How-To · Misc analysis
How to use cricket-data-analysis: score how predictable IPL and World Cup match-ups are
Revised
· v1.0.0 · what changed
Code: github.com/herrrickshaw/cricket-data-analysis
Watch the walkthrough
Watch on YouTube: youtu.be/_DC2pU9I7DU
Why it is useful
- Who benefits: sports-analytics hobbyists and students who want a first, honest worked example of turning open match data into a ranking.
- What it replaces: hand-copying results from scorecards. The script downloads the full public dataset in one step.
- The idea is clean: score = 1 minus binary entropy of the dominant side's win share, so 0 means a coin flip and 1 means one side always wins.
- Evidence from our run: the Cricsheet download succeeded (6.5 MB), but cricketdata 0.3.0 then failed to parse it. A workaround using the same formula gave a real ranking (below).
- Caution: tiny samples dominate the top of the list (5 meetings can score 1.000), so read the sample sizes next to every score.
What it is for
Cricsheet publishes every match as CSV. This script downloads the IPL and ICC men's World Cup archives, normalises franchise renames (for example Delhi Daredevils to Delhi Capitals), keeps decisive matches, and computes a predictability score per team pairing and per venue.
It was extracted from stray copies in two stock-market repos, so it is a single standalone script rather than a package. It is an analysis exercise, not a betting or forecasting tool.
Who it is for
- Students learning entropy as a measure of predictability
- R users who want a worked example of the cricketdata package
- Anyone curious which IPL match-ups have been lopsided
- Betting or match-outcome prediction. Past head-to-head records are not a forecast.
- Quoting scores for pairings with few meetings as if they were stable
- Anyone who needs it to run unchanged today: it currently stops with an error (see limits)
What you need
| Requirement | Why | How to get it |
|---|---|---|
| R | runs the script | r-project.org; we used the Rscript already installed |
| R packages | data fetch and wrangling | install.packages(c("cricketdata","dplyr","tidyr","stringr","readr","lubridate","ggplot2")) |
| Internet access | downloads zip files from cricsheet.org | normal connection, no account or key |
| Not needed | no API key, GPU or database | - |
Get the code and an AI assistant
You do not have to be a programmer. Get the repository, give it to an AI assistant, and ask in plain language. Any of these routes works:
| Tool | What you need | Best for |
|---|---|---|
| GitHub | Free account to fork or star; git to clone, or the green Code button, then Download ZIP, or open in Codespaces | Getting the code and keeping up with updates |
| Claude Code | Claude subscription or API key; run claude inside the cloned folder | Letting the AI read and run the whole repo |
| Gemini CLI | Google account; run gemini inside the cloned folder | The same hands-on workflow with Gemini |
| Claude.ai, Gemini or ChatGPT in the browser | A chat account; upload README.md and the files you care about (or paste the output of git ls-files) | Understanding the project and asking questions without installing anything |
| Other tools (Copilot Chat, Cursor, Codex CLI) | Open the cloned folder in the tool and point it at README.md first | Editing and extending the code |
git clone https://github.com/herrrickshaw/cricket-data-analysis.git
cd cricket-data-analysis
claude # or: gemini
Install
- Get the code
git clone https://github.com/herrrickshaw/cricket-data-analysis.git cd cricket-data-analysis - Install the R packages
Rscript -e 'install.packages(c("cricketdata","dplyr","tidyr","stringr","readr","lubridate","ggplot2"))'
Quick start: commands and what you should see
Run the script
Rscript fetch_and_analyze_cricket_data.R
It prints 'Fetching IPL match data from Cricsheet...', downloads about 6.5 MB, then should write five CSV files to ./output/. On our run (19 Oct 2026, cricketdata 0.3.0, tidyr 1.3.2) it stopped at the parsing step with the error shown below, so no CSVs were written.
Sample outputs
Real output from a run on the date shown in the sources line; trimmed to fit.
Live run of the repo script: download OK, parsing fails
Rscript fetch_and_analyze_cricket_data.R
Fetching IPL match data from Cricsheet...
Downloading: https://cricsheet.org/downloads/ipl_male_csv2.zip
downloaded 6.5 MB
Downloaded file size: 6834886 bytes
Zip file verified OK. Proceeding with fetch_cricsheet()...
Error in `tidyr::pivot_wider()`:
! Names must be unique.
x These names are duplicated:
* "match_id" at locations 1 and 10.
Execution halted
Cause we found: the current Cricsheet *_info.csv files include an 'info,match_id' row, which collides with the match_id column that cricketdata 0.3.0 adds when it reshapes the data. This looks like an upstream package issue, not a bug in the repo script's own logic.
Workaround: the same score formula applied directly to the downloaded zip (our own small script, not part of the repo)
python3 -I pred.py # reads *_info.csv from ipl_male_csv2.zip
decisive matches 1218 seasons 2007/08 - 2026
pairings with >=3 meetings 73
Gujarat Lions vs Sunrisers Hyderabad n= 5 dominant=Sunrisers Hyderabad 5/5 (100.0%) score=1.000
Pune Warriors vs Royal Challengers Bengaluru n= 5 dominant=Royal Challengers Bengaluru 5/5 (100.0%) score=1.000
Gujarat Titans vs Sunrisers Hyderabad n= 7 dominant=Gujarat Titans 6/7 (85.7%) score=0.408
Mumbai Indians vs Pune Warriors n= 6 dominant=Mumbai Indians 5/6 (83.3%) score=0.350
Deccan Chargers vs Kolkata Knight Riders n= 9 dominant=Kolkata Knight Riders 7/9 (77.8%) score=0.236
Top rows only. It applies the script's own rename map and the score = 1 - H(p) formula with a minimum of 3 meetings. The top scores come from teams that existed for only a few seasons.
Ways to use it
| Method | How it works |
|---|---|
| Run as written | Once cricketdata fixes the parsing issue (or you pin an older package version), Rscript writes the five CSVs and prints top-10 tables. |
| Reuse the formula | The predictability score is only a few lines; copy it into your own notebook for any head-to-head dataset. |
| Ask an AI to port it | Ask an assistant to rewrite the fetch step to read the Cricsheet zip directly, as in our workaround. |
| Extend | Uncomment the optional ESPNCricinfo career-stats block for player-level context. |
Sample prompts for your AI assistant
Copy, paste and edit the parts in [brackets].
- Read fetch_and_analyze_cricket_data.R and explain the predictability score 1 - H(p) with a worked example for a 7-2 head-to-head record.
- The cricketdata fetch_cricsheet() call fails with 'Names must be unique: match_id'. Rewrite the fetch step to read the Cricsheet zip's *_info.csv files directly.
- Add a minimum-sample-size column and a confidence interval to the pairing predictability table so small samples are not over-read.
- Extend the script to show predictability by venue for the last five IPL seasons only.
- Explain why a score near 1.000 on 5 matches is weaker evidence than 0.236 on 9 matches, in plain language.
Limits and honest caveats
- The script does not run end to end today: cricketdata 0.3.0 fails on current Cricsheet files (duplicate match_id). We did not patch the repo.
- Only the IPL download was exercised; the World Cup (ODI and T20) and venue-fortress outputs were not produced.
- The workaround numbers are our re-computation of the same formula on 19 Oct 2026 data, not output of the repo script. Cricsheet updates continuously, so counts will change.
- Head-to-head win share ignores toss, venue, squad and form, and the min-3-meetings filter still leaves very noisy scores.
- Cricsheet data is shared under its own licence terms (see README.txt and LICENSE.txt inside the zip); check them before redistributing.
Sources: Repo herrrickshaw/cricket-data-analysis (script and README, 3 files); Cricsheet IPL men's CSV archive (cricsheet.org/downloads/ipl_male_csv2.zip), downloaded and run 19 October 2026.
- v1.0.0 — 2 November 2026 — first published.
About this article: Researched, written and edited by Umashankar Triplicane Dwarakanathan, with AI research assistance; every figure is meant to trace to the primary source cited. See the Editorial Policy for how sourcing, AI use and corrections work.