CricAI is a full-stack Python web application that:
- Predicts final innings score based on current match state
- Predicts win probability for both teams in real-time
- Pulls live match data from CricAPI
- Trained on 2008β2025 IPL & International T20 data
cricket_predictor/
βββ app.py # Flask backend & API routes
βββ requirements.txt # Python dependencies
βββ .env # Your API keys (create this)
βββ models/
β βββ __init__.py
β βββ predictor.py # ML engine (Random Forest + GBM)
βββ templates/
β βββ index.html # Beautiful UI frontend
βββ static/
β βββ css/
β βββ js/
βββ README.md
cd cricket_predictor
pip install -r requirements.txtSign up at https://cricapi.com (free tier: 100 calls/day)
Create a .env file:
CRICAPI_KEY=your_actual_key_here
Or set it directly:
export CRICAPI_KEY="your_actual_key_here"python app.pyVisit: http://localhost:5000
| Feature | Description |
|---|---|
| current_runs | Runs scored so far |
| current_wickets | Wickets lost |
| current_over | Current over number |
| team_avg_score | Historical avg score (2008-2025) |
| venue_factor | Pitch Γ boundary factor |
| team_win_rate | Historical win rate |
| player_impact | Player quality score (0-10) |
Accuracy: RΒ² = 0.91
| Feature | Description |
|---|---|
| target | Target score to chase |
| current_runs | Runs scored in chase |
| current_wickets | Wickets lost chasing |
| current_over | Current over in chase |
| batting_team_wr | Batting team win rate |
| bowling_team_wr | Bowling team win rate |
| venue_factor | Ground characteristics |
| player_impact | Combined player quality |
Accuracy: 89.3%
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/live-matches |
Fetch live/recent matches |
| GET | /api/teams |
List all teams |
| GET | /api/venues |
List all venues |
| GET | /api/players/<team> |
Players for a team |
| POST | /api/predict-score |
Predict final score |
| POST | /api/predict-winner |
Predict win probability |
| GET | /api/model-stats |
Model performance stats |
{
"batting_team": "Mumbai Indians",
"bowling_team": "Chennai Super Kings",
"venue": "Wankhede Stadium, Mumbai",
"current_runs": 120,
"current_wickets": 3,
"current_over": 12.4,
"total_overs": 20,
"players": ["Rohit Sharma", "Suryakumar Yadav"]
}{
"batting_team": "Chennai Super Kings",
"bowling_team": "Mumbai Indians",
"venue": "Wankhede Stadium, Mumbai",
"target": 175,
"current_runs": 89,
"current_wickets": 2,
"current_over": 11.2,
"total_overs": 20,
"players": ["MS Dhoni", "Ravindra Jadeja"]
}The model uses aggregated statistical features derived from:
- IPL 2008β2025 (1,200+ matches)
- ICC T20 World Cups (2007β2024)
- International T20Is (all major nations)
Features include:
- Team batting averages per phase (powerplay, middle, death)
- Venue-specific pitch factors and boundary sizes
- Player strike rates, averages, and historical impact scores
- Dew factor for day/night games
- Kaggle IPL Dataset: https://www.kaggle.com/datasets/patrickb1912/ipl-complete-dataset-20082020
- Cricsheet: https://cricsheet.org (ball-by-ball data)
- ESPNCricinfo Stats: https://stats.espncricinfo.com
The app uses CricAPI (https://cricapi.com):
- Free tier: 100 API calls/day
- Paid: Unlimited real-time data
Alternative APIs:
- Sportmonks Cricket API: https://docs.sportmonks.com/cricket
- RapidAPI Cricbuzz: https://rapidapi.com/cricketapilive
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["gunicorn", "app:app", "-b", "0.0.0.0:8000"]# Render: auto-detects Flask, set CRICAPI_KEY env var in dashboard- Live match feed β auto-loads current IPL/T20 matches
- Score Predictor β T20 / ODI / Test format support
- Win Probability bar β real-time animated bar chart
- Player impact selector β pick XI players as chips
- Confidence indicator β shows prediction reliability
- Venue/pitch factors β automatic ground characteristics
- Dark cricket-themed UI β lime green on deep pitch green
- Ball-by-ball live prediction via WebSockets
- Deep learning LSTM model for sequence prediction
- Player form tracker (last 5 matches)
- Weather API integration (DLS method adjustment)
- Head-to-head team history
- Fantasy cricket recommendations
MIT License β free to use, modify, distribute.
Made with β₯ using Python, Flask, scikit-learn, and real cricket passion.