Skip to content

ivoryshoulder/NBA-Machine-Learning-Sports-Betting

 
 

Repository files navigation

NBA Sports Betting Using Machine Learning 🏀

A machine learning AI used to predict the winners and under/overs of NBA games. Takes all team data from the 2007-08 season to current season, matched with odds of those games, using a neural network to predict winning bets for today's games. Achieves ~75% accuracy on money lines and ~58% on under/overs. Outputs expected value for teams money lines to provide better insight.

Packages Used

Use Python 3.8. In particular the packages/libraries used are...

  • Tensorflow - Machine learning library
  • XGBoost - Gradient boosting framework
  • Numpy - Package for scientific computing in Python
  • Pandas - Data manipulation and analysis
  • Colorama - Color text output
  • Tqdm - Progress bars
  • Requests - Http library
  • Scikit_learn - Machine learning library

Usage

Make sure all packages above are installed.

$ git clone https://github.com/kyleskom/NBA-Machine-Learning-Sports-Betting.git
$ cd NBA-Machine-Learning-Sports-Betting
$ pip3 install -r requirements.txt
$ python3 main.py -xgb -odds=fanduel

Odds data will be automatically fetched from sbrodds if the -odds option is provided with a sportsbook. Options include: fanduel, draftkings, betmgm, pointsbet, caesars, wynn, bet_rivers_ny

If -odds is not given, enter the under/over and odds for today's games manually after starting the script.

Flask Web App

This repo also includes a small Flask application to help view the data from this tool in the browser. To run it:

cd Flask
flask --debug run

Getting new data and training models

# Create dataset with the latest data for 2022-23 season
cd src/Process-Data
python -m Get_Data
python -m Get_Odds_Data
python -m Create_Games

# Train models
cd ../Train-Models
python -m XGBoost_Model_ML
python -m XGBoost_Model_UO

Contributing

All contributions welcomed and encouraged.

About

NBA sports betting using machine learning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.6%
  • PureBasic 38.8%
  • HTML 4.6%
  • Jupyter Notebook 2.0%