Skip to content

Alexander-Rees/FantasyFootballAnalysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏈 Enhanced Fantasy Football Analysis Tool

A comprehensive Python tool for analyzing fantasy football player performance and identifying buy-low/sell-high opportunities using advanced metrics and machine learning techniques.

Features

Advanced Metrics

  • Expected Fantasy Points (xFP) - Converts opportunity quality into expected points
  • Buy-Low Scoring - Position-specific algorithms (0-100 scale)
  • Usage Metrics - TPRR, WOPR, Snap Share, Route Participation
  • Red Zone Analysis - Inside-5/Inside-10 opportunities
  • Team Context - PROE, Pace, Air Yards Share

Data Sources

  • Sleeper API - League settings, rosters, scoring
  • NFL Data - Play-by-play, weekly stats, team data
  • SumerSports - Advanced metrics and historical data
  • MySportsFeeds - Injuries, depth charts (optional)

Interactive Analysis

  • Web-based Data Viewer - Sort, filter, and analyze players
  • Buy-Low Identification - Automated candidate detection
  • Position-Specific Analysis - WR/TE, RB, QB focused metrics
  • Export Capabilities - CSV, Excel, HTML reports

Quick Start

1. Installation

git clone https://github.com/Alexander-Rees/FantasyFootballAnalysis.git
cd FantasyFootballAnalysis
pip install -r requirements.txt

2. Configuration

cp env_example.txt .env
# Edit .env with your API keys and league settings

3. Run Analysis

# Run enhanced analysis with advanced metrics
python src/analysis/enhanced_processor.py

# Start interactive data viewer
cd data/outputs
python -m http.server 8081
# Open http://localhost:8081/enhanced_fantasy_viewer.html

Key Metrics Explained

Buy-Low Score (0-100)

Position-specific composite score based on:

  • WR/TE: TPRR (35%) + Route% (25%) + WOPR (20%) + Air Yards% (15%) + PROE (5%)
  • RB: xFP (30%) + Snap% (25%) + Routes/DB (20%) + Inside-5 (15%) + RYOE (10%)
  • QB: Dropbacks (35%) + Designed Rushes (25%) + PROE/Pace (20%) + EPA+CPOE (20%)

xFP Gap

Expected Fantasy Points minus Actual Fantasy Points

  • Positive = Buy Low (underperforming expectations)
  • Negative = Sell High (overperforming expectations)

Usage Metrics

  • TPRR - Targets per Route Run (most predictive WR/TE metric)
  • WOPR - Weighted Opportunity (1.5×Target Share + 0.7×Air Yards Share)
  • Snap Share - % of team offensive snaps
  • Route Participation - % of team dropbacks with player running route

2025 Season Results

Top Buy-Low Candidates

  • WR/TE: Brian Thomas (xFP Gap: 12.4), Xavier Legette (xFP Gap: 12.0)
  • RB: Jonathan Taylor (xFP Gap: 22.4), Tony Pollard (xFP Gap: 22.4)
  • 35 total candidates identified across all positions

Sell-High Candidates

  • Malik Nabers - High points but negative xFP gap (-12.2)
  • Rome Odunze - Overperforming expectations (-17.8 gap)

Project Structure

FantasyFootballAnalysis/
├── src/
│   ├── analysis/              # Advanced metrics calculator
│   │   ├── advanced_metrics.py
│   │   └── enhanced_processor.py
│   ├── data_sources/          # Data collection modules
│   ├── transforms/            # Position-specific transforms
│   └── utils/                 # Utility functions
├── data/
│   ├── raw/                  # Raw data files
│   ├── processed/            # Processed data
│   └── outputs/              # Final outputs and viewer
│       ├── enhanced_fantasy_viewer.html
│       ├── enhanced_*_2025.csv
│       └── buy_low_*_2025.csv
├── docs/                     # Documentation
└── tests/                    # Unit tests

Usage Examples

Identify Buy-Low Candidates

from src.analysis.enhanced_processor import EnhancedFantasyProcessor

processor = EnhancedFantasyProcessor()
wr_data, rb_data, qb_data = processor.run_enhanced_processing()

# Filter for high buy-low scores
buy_low_wr = wr_data[wr_data['buy_low_flag'] == True]
print(buy_low_wr[['player', 'buy_low_score', 'xFP_gap', 'fantasy_points']])

Analyze Volume Metrics

# Top targets with high TPRR
high_volume_wr = wr_data[
    (wr_data['targets'] >= 15) & 
    (wr_data['tprr'] >= 0.25)
].sort_values('tprr', ascending=False)

Configuration

Environment Variables

# Required
SLEEPER_LEAGUE_ID=your_league_id
SEASON=2025
WEEKS=1,2

# Optional
MSF_API_KEY=your_msf_key

League Settings

The tool automatically pulls scoring settings from your Sleeper league, but you can override them in src/config.py.

Data Viewer

The interactive web viewer provides:

  • Sortable tables - Click any column header
  • Advanced filtering - Min thresholds for all metrics
  • Color coding - Green for buy-low, yellow for high scores
  • Real-time search - Filter by player name or team
  • Export capabilities - Download filtered data as CSV

License

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

Acknowledgments

  • Sleeper API for league data
  • NFL Data for play-by-play statistics
  • SumerSports for advanced metrics
  • Fantasy Footballers for methodology insights

About

Visualization tool for most important Fantasy football metrics with AI analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published