Skip to content

yuvraajbains/NFL-Fantasy-MLPred

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NFL Fantasy ML Predictions

Overview

NFL Fantasy ML Predictions is a full-stack web page for generating, blending, and serving machine learning-based fantasy football player projections. The system leverages modern MLOps, robust backend APIs, and a responsive frontend to deliver actionable insights for fantasy football enthusiasts and analysts. This project was designed for the purpose of creating a personal project leveraging technologies that I have not actively used to make me more familiar with them.

Machine Learning Model Training and Prediction

The core of this project involves training advanced machine learning models to generate player fantasy point projections. The training pipeline is designed to be robust and flexible, leveraging state-of-the-art ensemble methods:

  • The primary model is a LightGBM (LGBMRegressor) gradient boosting machine, which is used when available for its efficiency and predictive power on structured data.
  • If LightGBM is not available, the pipeline falls back to an ensemble of HistGradientBoostingRegressor and RandomForestRegressor, averaging their predictions to improve generalization and reduce variance.
  • As a final fallback, HistGradientBoostingRegressor is used on its own.

The workflow includes:

  • Data ingestion and feature engineering from multiple sources, including player statistics, team context, and schedule-based features
  • Preprocessing with column transformers to scale numeric features and one-hot encode categorical variables
  • Train/validation split by season to ensure robust out-of-sample evaluation
  • Model training using the most advanced available ensemble method, optimizing for predictive accuracy on fantasy points (PPR)
  • Evaluation using metrics such as RMSE and MAE to assess model performance
  • Serialization of trained models as joblib artifacts for reproducibility and downstream use
  • Batch prediction to generate season-long player projections, which are saved as CSV files for further blending and API serving

This approach enables the system to leverage both historical data and contextual features, producing high-quality, data-driven projections that power the rest of the application.


Architecture

1. Backend (FastAPI, Python)

  • Framework: FastAPI for high-performance, async REST APIs.
  • Core Features:
    • Player Projections API: Serves real-time, per-player, per-week fantasy projections with confidence intervals.
    • Draft Simulation: Generates optimal draft teams using blended ML and expert projections, simulating human-like draft strategies.
    • Data Handling: Dynamically loads and processes model outputs and expert rankings, normalizing and blending them for downstream use.
  • ML Integration: Reads from precomputed model outputs and expert rankings, blending them using advanced normalization and weighted scoring.
  • Containerized: Dockerfile and docker-compose.yml for reproducible, scalable deployment.

2. Machine Learning & Data Science

  • Modeling: Utilizes scikit-learn, pandas, and joblib for model training, evaluation, and serialization.
  • Blending Logic: Custom scripts blend ML projections with expert ranks and qualitative features (e.g., "stars"), using MinMax scaling and weighted aggregation.

3. Data Sourcing & Feature Engineering

  • NFL Python Library: Data is programmatically ingested from a specialized NFL Python library, enabling access to up-to-date player stats, schedules, and injury reports directly from official league sources.
  • Rich CSV Datasets: The pipeline integrates a variety of CSV files containing:
    • Player-level season and weekly stats
    • Team aggregates and advanced metrics
    • Schedule and matchup impact
    • Injury history and status
  • Feature Engineering: These diverse data sources are joined and transformed to create a comprehensive feature set, capturing both quantitative and contextual factors that drive fantasy performance.

4. Frontend (React + TypeScript + Vite)

  • Modern Stack: Built with React 19, TypeScript, and Vite for lightning-fast development and production builds.
  • UI/UX: Responsive, visually appealing interface with modals for draft results, interactive team building, and real-time feedback.
  • Componentization: Modular React components for maintainability and scalability.
  • Styling: Tailwind CSS for rapid, consistent, and modern UI design.

5. DevOps & Data Management

  • Version Control: Strict .gitignore and DVC configuration to ensure only code and essential configs are versioned.
  • CI/CD Ready: Containerized for seamless deployment to cloud platforms like Railway.
  • Postgres & Redis: Integrated via Docker Compose for persistent storage and caching.

Key Features

  • End-to-End ML Pipeline: From raw data ingestion and feature engineering to model training, blending, and serving.
  • API-Driven: All core functionality is exposed via robust, documented REST endpoints.
  • Draft Team Recommendation: Simulates snake drafts, accounting for league size, pick order, and positional needs.
  • Blended Projections: Combines quantitative model outputs with expert qualitative input for superior accuracy.
  • Cloud-Ready: Easily deployable to Railway or any container-based cloud platform.

Project Showcase

Below are screenshots demonstrating the core user experience and UI polish of the NFL Fantasy ML Predictions platform:

1. Draft Settings Modal

Draft Settings Modal

2. Draft Results Modal

Draft Results Modal

3. Landing Page

Landing Page


License

MIT License


About

A full stack, machine learning based ESPN fantasy ppr prediction system for top 300 player projections. This provides automatic generation of a draft lineup based on the ppr and overall stats.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors