Skip to content

a369kuma/Gridiron_AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏈 Gridiron AI - NFL Game Outcome Predictions

A comprehensive machine learning system for predicting NFL game outcomes using advanced analytics, TensorFlow neural networks, and real-time data processing.

πŸš€ Features

  • 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

πŸ—οΈ Architecture

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

πŸ› οΈ Installation

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • npm or yarn

Backend Setup

  1. Clone the repository

    git clone <repository-url>
    cd Gridiron_AI
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Python dependencies

    pip install -r requirements.txt
  4. Initialize the database

    cd backend
    python -c "from api.app import init_db; init_db()"
  5. Train the initial model

    python models/nfl_predictor.py
  6. Start the Flask API

    python api/app.py

Frontend Setup

  1. Navigate to frontend directory

    cd frontend
  2. Install dependencies

    npm install
  3. Start the development server

    npm start

🎯 Usage

Making Predictions

  1. Access the dashboard at http://localhost:3000
  2. Select teams for home and away
  3. Configure weather conditions (optional)
  4. Click "Predict Game Outcome" to get results

API Endpoints

  • GET /api/health - Health check
  • POST /api/predict - Make game prediction
  • GET /api/teams - Get list of NFL teams
  • GET /api/team/{team}/stats - Get team statistics
  • GET /api/predictions - Get recent predictions
  • GET /api/model/accuracy - Get model accuracy
  • POST /api/model/retrain - Retrain the model

Example API Usage

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']}")

🧠 Model Architecture

Neural Network

  • 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

Features

  • Team win percentages
  • Offensive/defensive ratings
  • Average points and yards
  • Turnover differentials
  • Rest day advantages
  • Weather conditions
  • Injury reports
  • Team momentum

Hyperparameter Optimization

  • Uses Optuna for automated hyperparameter tuning
  • Optimizes layer sizes, dropout rates, learning rates
  • Implements early stopping and learning rate reduction

πŸ“Š Data Processing

Data Sources

  • NFL team statistics
  • Game outcomes
  • Weather data
  • Injury reports
  • Rest day calculations

Feature Engineering

  • Relative strength calculations
  • Weather impact scoring
  • Momentum indicators
  • Composite team ratings

Data Quality

  • Handles missing values
  • Removes outliers
  • Validates data integrity
  • Processes 500K+ data points

🎨 Frontend Features

Dashboard

  • Interactive prediction form
  • Real-time results display
  • Model performance metrics
  • Recent predictions history

Analytics

  • Prediction accuracy charts
  • Team performance analysis
  • Confidence distribution
  • Win rate statistics

Responsive Design

  • Mobile-friendly interface
  • Modern UI with glassmorphism
  • Interactive visualizations
  • Real-time updates

πŸ”§ Configuration

Environment Variables

# 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

Model Parameters

# Default hyperparameters
HIDDEN_LAYERS = [128, 64, 32]
DROPOUT_RATE = 0.3
LEARNING_RATE = 0.001
VALIDATION_SPLIT = 0.2

πŸ§ͺ Testing

Run Tests

# Backend tests
pytest tests/

# Frontend tests
cd frontend
npm test

Test Coverage

  • Unit tests for ML models
  • API endpoint testing
  • Frontend component testing
  • Integration tests

πŸ“ˆ Performance

Model Metrics

  • Accuracy: 65-75% on test data
  • Precision: 0.68
  • Recall: 0.72
  • F1-Score: 0.70
  • AUC: 0.75

System Performance

  • Prediction Time: <100ms
  • Data Processing: 500K+ records
  • API Response: <200ms
  • Frontend Load: <2s

πŸš€ Deployment

Production Setup

# 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

Docker Deployment

# 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"]

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • NFL data sources
  • TensorFlow team
  • React community
  • Flask framework

πŸ“ž Support

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! 🏈

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors