NFL Prediction Analytics
ProductionPre-game NFL winner predictor for Duke AIPI 510, with S3 data, MLflow tracking, a Lambda API, and a CloudFront app.
- Python
- TypeScript
- scikit-learn
- MLflow
- FastAPI
- AWS Lambda
- Amazon S3
- CloudFront
Problem & Motivation
The question is whether the home team wins, answered before kickoff. It is a binary classification on the nflverse games file: regular-season games from 2020 through week 10 of 2026, ties removed, 1,759 games. The target is home_win, and the score that matters is accuracy against the always-pick-the-home-team baseline.
This is Duke AIPI 510 coursework, model version 1.0 from November 2026. It is an unofficial project and is not affiliated with the National Football League. The live app and the prediction API are in service.
System Architecture
One settings file drives the pipeline. nflverse games are cleaned into a seven-column table, stored in a private S3 bucket, and read back so later steps start from the cloud copy. Training fits a standard scaler and a logistic regression, writes models/model.joblib, and logs the run to MLflow. The same FastAPI app serves locally and on Lambda through Mangum. API Gateway exposes POST /predict and GET /health. The Vite app, React and TypeScript, is built to a private bucket and served by CloudFront. A second Lambda writes feedback-form messages to DynamoDB.
flowchart LR
games["nflverse games"] --> s3["Amazon S3"]
s3 --> train["MLflow training"]
train --> lambda["Lambda FastAPI"]
browser["Browser"] --> web["CloudFront"]
browser --> api["API Gateway"]
api --> lambda
lambda --> feedback["DynamoDB"]
Key Engineering Trade-offs
- The model takes two inputs, both computed only from earlier games in the same season: win-percentage differential, and points scored minus points allowed per game. That blocks leakage. It also means the model never sees injuries, weather, travel, or rest. On the 2025 validation split it reached 63.10 percent accuracy against a 53.87 percent home-team baseline, and it still leans toward the home team.
- The split is by season, not by random rows: train 2020–2024, validate 2025, test 2026 weeks 1–10. A random split would mix future games into training. Week 1 has no prior games, so both inputs are zero and every opening game gets the same home-field probability.
- The Lambda package carries the saved model, so the cloud prediction matches the laptop API, including the Docker train-and-serve image. The cost is a rebuild and redeploy when the model changes. GitHub Actions runs the Python tests, the web tests, the docs site, and the web-app deploy.