A comprehensive machine learning system for predicting NFL game outcomes using advanced analytics, TensorFlow neural networks, and real-time data processing.
- Advanced ML Model: TensorFlow-based neural network with hyperparameter optimization
- Data Processing Pipeline: Handles 500K+ data points with Pandas for feature engineering
- Real-time Predictions: Flask API with SQL database integration
- Modern Frontend: React-based dashboard with interactive visualizations
- Model Analytics: Performance tracking and accuracy monitoring
- Weather Integration: Considers weather conditions in predictions
- Team Statistics: Comprehensive team performance metrics
Gridiron_AI/
βββ backend/
β βββ models/ # TensorFlow ML models
β βββ api/ # Flask API endpoints
β βββ data_processor.py # Data processing pipeline
β βββ utils/ # Utility functions
βββ frontend/ # React application
βββ data/ # Data storage
βββ notebooks/ # Jupyter notebooks for analysis
βββ tests/ # Test suite
- Python 3.8+
- Node.js 16+
- npm or yarn
-
Clone the repository
git clone <repository-url> cd Gridiron_AI
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Python dependencies
pip install -r requirements.txt
-
Initialize the database
cd backend python -c "from api.app import init_db; init_db()"
-
Train the initial model
python models/nfl_predictor.py
-
Start the Flask API
python api/app.py
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Start the development server
npm start
- Access the dashboard at
http://localhost:3000 - Select teams for home and away
- Configure weather conditions (optional)
- Click "Predict Game Outcome" to get results
GET /api/health- Health checkPOST /api/predict- Make game predictionGET /api/teams- Get list of NFL teamsGET /api/team/{team}/stats- Get team statisticsGET /api/predictions- Get recent predictionsGET /api/model/accuracy- Get model accuracyPOST /api/model/retrain- Retrain the model
import requests
# Make a prediction
prediction_data = {
"home_team": "KC",
"away_team": "BUF",
"home_stats": {
"win_pct": 0.7,
"off_rating": 110,
"def_rating": 95,
"avg_points": 28,
"avg_yards": 380,
"turnover_diff": 0.5,
"momentum": 0.3,
"injuries": 2
},
"away_stats": {
"win_pct": 0.6,
"off_rating": 105,
"def_rating": 100,
"avg_points": 25,
"avg_yards": 360,
"turnover_diff": -0.2,
"momentum": -0.1,
"injuries": 4
},
"weather": {
"temp": 45,
"wind": 8,
"humidity": 60
}
}
response = requests.post('http://localhost:5000/api/predict', json=prediction_data)
result = response.json()
print(f"Predicted winner: {result['prediction']['predicted_winner']}")- Input Layer: 16 features (team stats, weather, rest days)
- Hidden Layers: 128 β 64 β 32 neurons with ReLU activation
- Output Layer: Single neuron with sigmoid activation
- Regularization: Batch normalization and dropout (30%)
- Optimizer: Adam with learning rate scheduling
- Team win percentages
- Offensive/defensive ratings
- Average points and yards
- Turnover differentials
- Rest day advantages
- Weather conditions
- Injury reports
- Team momentum
- Uses Optuna for automated hyperparameter tuning
- Optimizes layer sizes, dropout rates, learning rates
- Implements early stopping and learning rate reduction
- NFL team statistics
- Game outcomes
- Weather data
- Injury reports
- Rest day calculations
- Relative strength calculations
- Weather impact scoring
- Momentum indicators
- Composite team ratings
- Handles missing values
- Removes outliers
- Validates data integrity
- Processes 500K+ data points
- Interactive prediction form
- Real-time results display
- Model performance metrics
- Recent predictions history
- Prediction accuracy charts
- Team performance analysis
- Confidence distribution
- Win rate statistics
- Mobile-friendly interface
- Modern UI with glassmorphism
- Interactive visualizations
- Real-time updates
# API Configuration
FLASK_ENV=development
FLASK_DEBUG=True
DATABASE_URL=sqlite:///data/nfl_data.db
# Model Configuration
MODEL_PATH=models/nfl_predictor_model
BATCH_SIZE=32
EPOCHS=100# Default hyperparameters
HIDDEN_LAYERS = [128, 64, 32]
DROPOUT_RATE = 0.3
LEARNING_RATE = 0.001
VALIDATION_SPLIT = 0.2# Backend tests
pytest tests/
# Frontend tests
cd frontend
npm test- Unit tests for ML models
- API endpoint testing
- Frontend component testing
- Integration tests
- Accuracy: 65-75% on test data
- Precision: 0.68
- Recall: 0.72
- F1-Score: 0.70
- AUC: 0.75
- Prediction Time: <100ms
- Data Processing: 500K+ records
- API Response: <200ms
- Frontend Load: <2s
# Install production dependencies
pip install gunicorn
# Start production server
gunicorn -w 4 -b 0.0.0.0:5000 api.app:app
# Build frontend for production
cd frontend
npm run build# Backend Dockerfile
FROM python:3.9-slim
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "api.app:app"]- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- NFL data sources
- TensorFlow team
- React community
- Flask framework
For questions or support, please open an issue on GitHub or contact the development team.
Gridiron AI - Making NFL predictions smarter, one game at a time! π