This model predicts NFL game outcomes for each upcoming week by generating team ratings from webscraped data directly from NFL.com and applying a linear regression model. These ratings are then used to compare teams and predict the winner of matchups.
NFLPrediction/
├── Data/
├── Examples/
│ └── workflow.ipynb # Example walkthrough notebook
├── Utils/
│ ├── dataCollection.py # Fetches and preprocesses NFL data
│ ├── ratingGeneration.py # Generates team and player ratings
│ ├── modelFitting.py # Trains and evaluates prediction models
│ └── matchupPredictor.py # Predicts outcomes for a given matchup
├── .gitignore
└── README.md
Requirements: Python 3.8+
-
Clone the repository:
git clone https://github.com/your-username/NFLPrediction.git cd NFLPrediction -
Install dependencies:
pip install -r requirements.txt
-
Populate the
Data/directory by running functions in the data collection script:python Utils/dataCollection.py
The easiest way to get started is with the example notebook:
jupyter notebook Examples/workflow.ipynb- Data Collection — Scrapes and loads NFL team data including offensive and defensive stats
- Model Fitting — Uses a linear regression model to find correlation between stats and win percentage.
- Rating Generation — Computes offensive and defensive ratings for each team based on weights
- Matchup Prediction — Uses the model to output a win probability for each side.
It is important to note that when predicting matchups for an upcoming week, team ratings from the previous week must be used for the prediction. Below is an example of team ratings from the end of the last NFL season.
The overall team ratings can then be used to predict matchup outcomes as seen in the example below.
matchup("Denver Broncos", "Cleveland Browns", overallRatings)Projected Winner: Denver Broncos
Denver Broncos: 67.11%
Cleveland Browns: 32.89%