Skip to content

Predicts Daily NBA Games Using a Logistic Regression Model

Notifications You must be signed in to change notification settings

JakeKandell/NBA-Predict

Repository files navigation

NBA-Predict

Predicts NBA Games Using a Logistic Regression Model in Python

Model

The model uses eight factors scraped from stats.nba.com to determine the predicted result of an NBA game. Each stat is adjusted to per 100 possessions to ensure pace has no impact on the predictions.

  • Home Team
  • Win Percentage
  • Rebounds
  • Turnovers
  • Plus Minus
  • Offensive Rating
  • Defensive Rating
  • True Shooting Percentage

Usage

Installation

pip3 install -r requirements.txt

Daily Predictions

  1. Open nbaPredict.py
  2. Edit the call to makeInterpretPrediction with desired date of games, season, and the start date of the season NBA-Predict Image
  3. Run the program either through the terminal or an IDE
  4. Wait ~1-3 minutes for model to finish scraping stats and predicting outcomes
  5. Outcomes are outputted as the percent chance that the home team will defeat the away team Screen Shot 2019-08-01 at 5 41 22 PM

Past Predictions

  1. Open makePastPredictions.py

  2. Edit the call to makePastPredictions with desired start date, end date, season, start date of the season, and output filenames. NOTE: The start date should be at least three days after the season begins and the end date is non-inclusive.

    Screen Shot 2019-10-11 at 1 41 42 AM

  3. Run the program either through the terminal or an IDE

  4. Two CSV files will be saved in the Data folder. One holds the gameData and the other holds the predictions for the games. The time to execute will vary greatly from a couple minutes to a several hours depending on the range between the start and end date.

Accuracy Information

Confusion Matrix

rsz_1confusionmatrix

Accuracy: 0.7037 (532/756)

Precision: 0.7367 (375/509)

Recall: 0.8065 (375/465)