kyleskom/NBA-Machine-Learning-Sports-Betting
NBA sports betting using machine learning
NBA Sports Betting Using Machine Learning
What it is – A Python project that predicts NBA game winners (money‑line) and total points (over/under) by training machine‑learning models on historic team statistics and sportsbook odds. It also computes the expected value of each bet and can suggest stake sizes using the Kelly Criterion.
Key components
- Data collection –
Get_Datascrapes daily team stats from NBA APIs;Get_Odds_Datapulls odds and scores from Sportsbook Review (SBR) for a list of supported books (FanDuel, DraftKings, etc.). Both store raw data in SQLite databases. - Feature engineering –
Create_Gamesmerges the two databases, adds derived fields such as days‑rest, and produces a training‑ready matchup table. - Models – Pre‑built scripts train two families of models:
- XGBoost (gradient‑boosted trees) for money‑line and totals.
- A simple feed‑forward neural network (TensorFlow) for the same tasks.
- Logistic‑regression scripts are also provided.
- Prediction script –
main.pypulls today’s schedule, builds the same feature set, loads the saved models, and prints:- Win probability for each team.
- Expected value of betting the listed odds.
- Optional Kelly‑criterion fraction of bankroll to wager.
- Web UI – A minimal Flask app (
Flask/) lets you browse the latest predictions in a browser.
How to run it
# Install dependencies
pip install -r requirements.txt
# Update the data (first time only)
cd src/Process-Data
python -m Get_Data
python -m Get_Odds_Data
python -m Create_Games
# Train the models (optional – pre‑trained models are shipped)
cd ../Train-Models
python -m XGBoost_Model_ML --dataset dataset_2012-26 --trials 100 --splits 5 --calibration sigmoid
# …repeat for the other scripts you want
# Make a prediction for today
cd ../../
python3 main.py -xgb -odds=fanduel # use XGBoost and pull FanDuel odds automatically
You can add -nn to use the neural‑net model, -A to run all models, or -kc to display the Kelly stake.
Typical use case – A sports‑betting enthusiast runs the script each day to get a data‑driven estimate of which NBA team is undervalued by the sportsbook and how large a bet would be optimal under a Kelly‑based bankroll strategy.
Limitations –
- The models are trained on data up to the current season; they do not incorporate live‑game information (e.g., injuries after the lineup is announced).
- The neural‑network scripts are hard‑coded to specific dataset paths and may need manual editing for custom data.
- Accuracy depends on the quality of the scraped stats and odds; any change in the source APIs can break the pipeline.
Contributing – The README invites contributions that modify model behavior or data pipelines; contributors should update the documentation accordingly.
All information above is taken directly from the repository’s README; no additional features have been inferred.
Related
- Project
- Project
- Project
- Project