CricOptima is an advanced, AI-powered fantasy cricket team optimizer. I designed and built this system to move beyond simple heuristics, implementing Gradient Boosting for player performance prediction and mathematical constraint satisfaction for optimal team selection.
π΄ LIVE DEMO - Experience the AI optimizer in action!
- π Deployment Guide: How to run this on the web or Docker.
- ποΈ Architecture: Deep dive into the clean, modular design.
- π€ Contributing: How to join the project.
Build optimal fantasy cricket teams using machine learning predictions and constraint optimization algorithms.
| Dashboard | Constraints Setup | Player Analytics |
|---|---|---|
![]() |
![]() |
![]() |
| Optimization Results | Head-to-Head | Simulation |
![]() |
![]() |
![]() |
| Feature | Description |
|---|---|
| π€ ML Predictions | Gradient Boosting model predicts player fantasy points |
| π― Smart Optimization | Builds best team within budget and role constraints |
| π Analytics Dashboard | Explore player stats, value scores, and predictions |
| π REST API | Full-featured FastAPI backend with Swagger docs |
| π³ Docker Ready | One-command deployment with docker-compose |
# Clone repository
git clone https://github.com/millenniumsingha/CricOptima.git
cd CricOptima
# Train ML model and start services
docker-compose --profile training up train
docker-compose up -d
# Access:
# - Dashboard: http://localhost:8501
# - API Docs: http://localhost:8000/docs# Install dependencies
pip install -r requirements.txt
# Train ML model
python -m src.ml.train
# Start API (terminal 1)
uvicorn api.main:app --reload
# Start Dashboard (terminal 2)
streamlit run app/streamlit_app.pyβββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Player Data ββββββΆβ ML Predictor ββββββΆβ Predictions β
β (Stats/Form) β β (Gradient Boost)β β (Points/Conf) β
βββββββββββββββββββ βββββββββββββββββββ ββββββββββ¬βββββββββ
β
βββββββββββββββββββ β
β Optimizer ββββββββββββββββ
β (Constraints) β
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β Optimal XI β
β (Best Team) β
βββββββββββββββββββ
- Recent batting/bowling averages
- Strike rate & economy rate
- Form trend (improving/declining)
- Consistency score
- Matches played (experience)
- Budget limit (default: 1000 points)
- Team size: 11 players
- Min 3 batsmen, 3 bowlers, 1 all-rounder, 1 wicket-keeper
- Max 7 players from same team
| Method | Endpoint | Description |
|---|---|---|
| GET | /players |
List all players with filters |
| GET | /players/{id} |
Get single player details |
| POST | /optimize |
Build optimal team |
| GET | /predictions |
Get ML predictions |
| POST | /teams/validate |
Validate team selection |
| GET | /health |
Health check |
curl -X POST "http://localhost:8000/optimize" \
-H "Content-Type: application/json" \
-d '{"budget": 1000, "team_name": "My Dream XI"}'CricOptima/
βββ src/
β βββ models/ # Data models (Player, Team, Match)
β βββ scoring/ # Fantasy points calculator
β βββ optimizer/ # Team optimization algorithm
β βββ ml/ # ML prediction model
β βββ data/ # Data layer & sample data
βββ api/ # FastAPI backend
βββ app/ # Streamlit dashboard
βββ tests/ # Test suite
βββ ml_models/ # Trained models
# Run all tests
pytest tests/ -v
# With coverage
pytest tests/ --cov=src --cov=api| Category | Points |
|---|---|
| Run | 0.5 |
| Four | +1 bonus |
| Six | +2 bonus |
| 50 runs | +10 bonus |
| 100 runs | +20 bonus |
| Wicket | 10 |
| 3-wicket haul | +5 bonus |
| 5-wicket haul | +10 bonus |
| Catch/Stumping/Run-out | 10 |
- π Live Integration: Real-time player data fetching via CricAPI.
- π User Auth: Secure JWT-based authentication with bcrypt hashing.
- πΎ Team Management: Save, load, and manage your optimized teams.
- βοΈ Smart Comparison: Head-to-Head win probability predictions.
- π² Monte Carlo Simulation: 1000x match simulation for variance analysis.
- π± Mobile First: Fully responsive Streamlit UI for all devices.
- π DevOps Ready: CI/CD pipeline with GitHub Actions.
- Player Consistency Ratings: New metric based on coefficient of variation.
- ROI Analysis: Cost vs. Points historical trend analysis.
- Venue Impact: Adjust predictions based on pitch conditions.
- Private Leagues: Compete with friends in custom leaderboards.
- Live Tracking: Real-time point updates via WebSocket during matches.
- Historical Backtesting: Validate model against past 5 years of IPL data.
- Original project from Internshala Python Training
- IPL teams and player data
- scikit-learn, FastAPI, and Streamlit communities
Built with β€οΈ for cricket fans and data enthusiasts





