Skip to main content

A tool to predict the outcome of daily NBA games

Project description

nbapredictdaily

Predict NBA games using nbapredictdaily

This package is an extension of my master's dissertation project that has been specifically tailored for generating daily reports of predicted NBA game outcomes using ML classification models. The idea is to utilize the trained predictive models developed in this project to allow for users to quickly and easily generate highly accurate predictions on NBA games on a daily basis. This is accomplished by redesigning the webscrapers used in the project to gather, clean, and compile a prediction dataset exclusively representing games taking place on the day that the program is run. Once predictions are made, the results are stored in csv files in a directory created on the user's Desktop called "PREDICT_NBA".

At the moment, this package is only availabe on MacOS.

Background

The main project involved using a dataset with >20,000 rows representing each NBA game played from the 2013-2014 NBA season to the beginning of the 2022-2023 NBA season, containing information regarding recent team performance, player skill levels, and, crucially, minutes played by players on both teams in a given matchup. This dataset was used to train a logistic regression model, an MLP classifier, and a randon forest classifier. The best performing model, the logistic regression model, a mean testing accuracy of 69.7% across 20 different train-test-split random states. This model outperforms most game prediction models created by students and hobbyists that can be found online and rivals the predictive power of some professional sports betting sites' models. However, to be completely clear, this is not a tool intended to inform betting decisions.

Installation

To install, use the following terminal command:

pip install nbapredictdaily

Generate Predictions

To use the primary prediction functionality, use the following lines of Python code in a notebook or python file:

from nbapredict_daily.predict import DailyReport
daily_report = DailyReport()
daily_report.get_predictions()

Output

When run for the the first time, the program will create the "NBA_PREDICT" folder on the user's desktop, into which it will log all results and store the necessary documents. It will also display a Pandas DataFrame in the console. Therefore, the output includes:

  • A Pandas DataFrame containing today's prediction results with the following columns
    • ['Date', 'Predicted Winner', 'Predicted Loser', 'Probability (LR)', 'Probability (MLP)', 'Probability (RF)']
  • TodayGames.csv - Today's slate of NBA games
  • TodayPred.csv - Predictions for today's games
  • Predictions.csv - All predictions made by the user, appended with each run
  • TrainingData.csv - The data used to train the models. This will be appended with the new training data upon use of the retrain_model function
  • NewTrainingData.csv - Data for today's games that can be appended to the model's training data once the game outcomes are known
  • MODELS - A subfolder containing the trained models' .sav files for easy access on future runs

Retrain the Logistic Regression Model

After some predictions have been made and the true outcomes can be known (generally the following day), you can use the retrain_model function. This function will update the NewTrainingData.csv file with the correct game outcomes, append it to the main TrainingData.csv dataset, and retrain the logistic regression model, keeping it up to date and, ideally, enhancing its predictive capability.

To do this, run the following lines of code in a notebook or python file:

from nbapredict_daily.modules import NBAtools
NBAtools.retrain_model()

Documentation

Check out the source code here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbapredictdaily-1.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nbapredictdaily-1.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file nbapredictdaily-1.0.1.tar.gz.

File metadata

  • Download URL: nbapredictdaily-1.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for nbapredictdaily-1.0.1.tar.gz
Algorithm Hash digest
SHA256 28113b495ebf87b8c39a9eb1790f703b90c7abf7d04f8a702e02a75b87f21c8c
MD5 37968454c12f5efe71590a1248afe6e0
BLAKE2b-256 63d5463428f9ab12043b05872f3da9709a74d72f19b034ae2f62c6c90109e76f

See more details on using hashes here.

File details

Details for the file nbapredictdaily-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nbapredictdaily-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72178b1fd3aa5e0c915cdfe20861837ce62d499f5ce86dfef88d0493db1674e3
MD5 957f470a5a3c04bdd6e391ab7dab9f11
BLAKE2b-256 3a9d3101d835c799aeb581a48136761d489a36b4bb6d416e9620b43a03accf7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page