Skip to content

CricOptima is an advanced fantasy cricket optimization platform designed to help users build winning teams using data science and linear programming.

License

Notifications You must be signed in to change notification settings

millenniumsingha/CricOptima

Repository files navigation

🏏 CricOptima

Streamlit App Python FastAPI Streamlit Docker

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!


πŸ“š Documentation


πŸš€ Key Features

Build optimal fantasy cricket teams using machine learning predictions and constraint optimization algorithms.

πŸ“Έ Screenshots

Dashboard Constraints Setup Player Analytics
Dashboard Constraints Analytics
Optimization Results Head-to-Head Simulation
Results Head-to-Head Simulation

✨ Features

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

πŸš€ Quick Start

Option 1: Docker (Recommended)

# 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

Option 2: Local Installation

# 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

πŸ“Š How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Player Data   │────▢│   ML Predictor  │────▢│   Predictions   β”‚
β”‚   (Stats/Form)  β”‚     β”‚ (Gradient Boost)β”‚     β”‚  (Points/Conf)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                         β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚
                        β”‚    Optimizer    β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚  (Constraints)  β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   Optimal XI    β”‚
                        β”‚ (Best Team)     β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

ML Features Used

  • Recent batting/bowling averages
  • Strike rate & economy rate
  • Form trend (improving/declining)
  • Consistency score
  • Matches played (experience)

Optimization Constraints

  • 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

πŸ”Œ API Reference

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

Example: Get Optimal Team

curl -X POST "http://localhost:8000/optimize" \
  -H "Content-Type: application/json" \
  -d '{"budget": 1000, "team_name": "My Dream XI"}'

πŸ“ Project Structure

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

πŸ§ͺ Testing

# Run all tests
pytest tests/ -v

# With coverage
pytest tests/ --cov=src --cov=api

πŸ—ΊοΈ Roadmap

  • Advanced Analytics (Q1 2026): Player consistency ratings and ROI analysis.
  • Social Features (Q2 2026): Private leagues and custom leaderboards.
  • Real-time Tracking: WebSocket integration for live point updates.

See CHANGELOG.md for full release history and details.

πŸ™ Acknowledgments

  • 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

About

CricOptima is an advanced fantasy cricket optimization platform designed to help users build winning teams using data science and linear programming.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages