Skip to content

jbj-02/fourth-down-optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NFL 4th Down Coach Tendency Model (fourth-down-optimizer)

This project predicts what an NFL coach is likely to call on 4th down — punt, field goal, or go for it — based on game situation context (distance, field position, score, quarter, game clock, season) plus the offensive coach. It includes an interactive Streamlit app that outputs P(go) and a “coach effect” vs a baseline.


Demo (Streamlit)

The app takes:

  • Yards to go (ydstogo)
  • Field position (yardline_100)
  • Quarter
  • Score differential (Offense − Defense; + means offense leads)
  • Game clock (minutes:seconds remaining)
  • Season
  • Offensive coach

It outputs:

  • Coach likelihood: P(go), P(punt), P(field_goal)
  • Coach effect vs baseline: coach P(go) − baseline P(go)
  • Optional expanders:
    • League tendency (situation-only model)
    • Value benchmark (expected WPA by action; exploratory)

Results (temporal holdout)

Trained on 2016–2022 and evaluated on 2023–2024 (neutral situations):

  • Accuracy: 0.8796
  • Macro F1: 0.8339
  • Log loss: 0.3217

Data

NFL play-by-play data (2016–2024) is cached locally as a parquet file: data/pbp_2016_2024.parquet.

Neutral situation filter (used for modeling & scorecards):

  • Quarter: Q2–Q4
  • Time remaining: > 2:00
  • Score differential: within ±10

The app can still be used outside of neutral situations, but it shows a warning because predictions may be less reliable.


Quickstart (Windows PowerShell)

1) Create and activate a virtual environment

py -m venv .venv
.\.venv\Scripts\Activate.ps1

2) Install dependencies

pip install -r requirements.txt

3) Run the full pipeline

.\run_all.ps1

4) Launch the app

.\run_app.ps1

About

Predicts NFL 4th down decisions (punt/FG/go) with coach-aware ML + Streamlit explorer.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published