A Django-based sport prediction system that uses rule-based algorithms and DeepSeek AI to generate predictions for sport matches.
- Match Management: Store fixtures with probabilities and odds
- Prediction Engine: Three prediction types:
- Baseline: Higher probability wins
- Profitable: Compare implied probability vs sportsbook odds
- Balanced: Combine probability + odds alignment
- AI Integration: DeepSeek API integration for enhanced predictions
- Analytics Dashboard: Track accuracy, visualize trends, and compare predictions
- Admin Dashboard: Manage matches, teams, and predictions with CSV import/export
- Backend: Django 5.0+ (Python 3.11+)
- Database: SQLite (default, easy migration to PostgreSQL)
- AI Engine: DeepSeek API
- Frontend: Django Templates with Bootstrap 5 & Chart.js
-
Clone the repository:
cd "football prediction system"
-
Create a virtual environment (recommended):
python -m venv venv # On Windows venv\Scripts\activate # On Linux/Mac source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure DeepSeek API Key: The API key is configured in
football_prediction_system/settings.py. You can also set it as an environment variable:export DEEPSEEK_API_KEY="your-api-key-here"
-
Run migrations:
python manage.py makemigrations python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
-
Access the application:
- Main site: http://127.0.0.1:8000/
- Admin panel: http://127.0.0.1:8000/admin/
-
Via Admin Panel:
- Go to
/admin/matches/match/ - Click "Add Match"
- Fill in team names, date, probabilities, and odds
- Save
- Go to
-
Via CSV Upload:
- Go to
/admin/matches/match/ - Select matches you want to export (or start fresh)
- Use the "Export selected matches as CSV" action to see the format
- Create a CSV with columns:
team_a, team_b, date, prob_a, prob_b, odds_a, odds_b, draw_prob - Import manually by creating matches one by one (CSV import action can be added)
- Go to
-
Rule-based Predictions:
- Navigate to a match detail page
- Click "Generate Predictions"
- System will calculate baseline, profitable, and balanced predictions
-
AI Predictions (DeepSeek):
- Click "Generate with AI" on a match detail page
- System will use DeepSeek API to generate enhanced predictions
- AI predictions are stored separately and can be compared with rule-based ones
-
Bulk Generation:
- Go to
/admin/predictions/prediction/ - Select matches without predictions
- Use "Generate rule-based predictions" action
- Go to
- Navigate to
/predictions/weekly/ - View prediction strings for the current week
- See breakdown by match
- Navigate to
/analytics/ - View accuracy metrics for all prediction types
- See weekly trends and distribution charts
- Compare predictions in the comparison table
football_prediction_system/
├── football_prediction_system/ # Main project settings
│ ├── settings.py # Django settings
│ ├── urls.py # Root URL configuration
│ └── wsgi.py # WSGI configuration
├── matches/ # Matches app
│ ├── models.py # Team, Match models
│ ├── admin.py # Admin configuration
│ └── views.py # Match views
├── predictions/ # Predictions app
│ ├── models.py # Prediction model
│ ├── engine.py # Rule-based prediction logic
│ ├── deepseek_client.py # DeepSeek API client
│ └── admin.py # Prediction admin
├── analytics/ # Analytics app
│ ├── models.py # Analytics models
│ └── views.py # Analytics dashboard
├── users/ # Users app
│ ├── models.py # Custom User model
│ └── admin.py # User admin
└── templates/ # HTML templates
├── base.html # Base template
├── matches/ # Match templates
├── predictions/ # Prediction templates
├── analytics/ # Analytics templates
└── users/ # User templates
id: Primary keyname: Team name (unique)logo_url: Optional logo URL
id: Primary keyteam_a: Foreign key to Team (home)team_b: Foreign key to Team (away)date: Match date/timeprob_a: Team A probability (0.0-1.0)prob_b: Team B probability (0.0-1.0)odds_a: Team A oddsodds_b: Team B oddsdraw_prob: Draw probability (0.0-1.0)actual_result: Actual match result ('1', '3', or '0')
id: Primary keymatch: Foreign key to Matchbaseline: Baseline prediction ('1', '3', or '0')profitable: Profitable predictionbalanced: Balanced predictionai_baseline: AI-generated baseline (optional)ai_profitable: AI-generated profitable (optional)ai_balanced: AI-generated balanced (optional)created_at: Creation timestamp
The system uses DeepSeek API for AI-powered predictions. Configure the API key in settings.py:
DEEPSEEK_API_KEY = os.environ.get('DEEPSEEK_API_KEY', 'your-default-key')Set in settings.py:
AUTO_GENERATE_PREDICTIONS = True # Auto-generate when matches are createdExample CSV for importing matches:
team_a,team_b,date,prob_a,prob_b,odds_a,odds_b,draw_prob
Everton,Bournemouth,2024-01-15 15:00:00,0.29,0.46,3.45,2.17,0.25
Arsenal,Liverpool,2024-01-20 17:30:00,0.45,0.35,2.22,2.86,0.20To migrate from SQLite to PostgreSQL:
-
Install PostgreSQL adapter:
pip install psycopg2-binary
-
Update
settings.py:DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'football_predictions', 'USER': 'your_user', 'PASSWORD': 'your_password', 'HOST': 'localhost', 'PORT': '5432', } }
-
Run migrations:
python manage.py migrate
python manage.py testpython manage.py makemigrationspython manage.py collectstaticThis project is open source and available under the MIT License.
For issues or questions, please open an issue on the repository.