Skip to content

neeljshah/nba-win-probability

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NBA Win Probability Engine 🏀

Real-time in-game win probability with live SHAP explainability — deployed FastAPI + Streamlit

Python XGBoost FastAPI Streamlit

Results

Metric Value
Brier Score 0.089
Log Loss 0.213
AUC-ROC 0.941
Calibration Error 0.012

What It Does

  • Predicts win probability at every play-by-play event in real time
  • Explains each prediction with SHAP values (which factors matter most)
  • Exposes a /predict REST endpoint and live Streamlit dashboard
  • Trained on 500K+ plays across 5 NBA seasons

Architecture

Raw play-by-play (nba_api)
    → Feature engineering (score diff, pace, possession, time)
    → XGBoost + isotonic calibration
    → SHAP TreeExplainer
    → FastAPI /predict endpoint
    → Streamlit live dashboard

Tech Stack

Python XGBoost SHAP FastAPI Streamlit scikit-learn nba_api Docker Plotly

Quick Start

pip install -r requirements.txt
python data/pull_pbp.py          # Pull NBA play-by-play data
python model/train.py            # Train + calibrate model
uvicorn api.main:app --reload    # Start API
streamlit run app/dashboard.py  # Launch dashboard

API Usage

curl -X POST http://localhost:8000/predict \
  -H "Content-Type: application/json" \
  -d '{"score_diff": 5, "time_remaining": 420, "possession": 1, "pace": 98.4}'
# → {"win_prob": 0.714, "shap_values": {...}}

About

Real-time NBA win probability — XGBoost + SHAP explainability + FastAPI + Streamlit dashboard.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages