top of page
Search

NBA Game Outcome Analyser

  • Writer: Kito Theron
    Kito Theron
  • Oct 26, 2024
  • 2 min read

Updated: Oct 27, 2024

This project was created in R to assign a probability to the outcome of each game for the NBA 2024-2025 regular season. Using this data I wanted to automatically decide which bets on different sites were worth taking according to my model.


I used the odds-api (https://the-odds-api.com/sports-odds-data/nba-odds.html) to get the data from various sports betting sites (Such as Draftkings and FoxBet).


To make my predictions I used the data set of the NBA games from the previous season as my training data which included all of the scores from the previous season including which team was away and home. I took this data from the official NBA stats website https://www.nba.com/stats/teams/boxscores.


I then created my model using the Generalized Additive Models for Location, Scale and Shape (gamlss) library https://www.gamlss.com . This library took 3 drivers; the home team, the away team and the score difference of the home and away teams. This meant larger wins would be factored as a larger positive for the winning team and it also meant that home court advantage would be factored into my model. The model I created predicted the probability that the home team would win the game (p(HomeScoreDiff>0)) given the names of the home and away teams using a binomial distribution.



I then extracted the data inside of the odds-api and reformatted it to be a percentage chance they were giving each outcome happening, you will notice their odds of the home team winning and away team losing do not sum to 100 as this is where they make their money. I then compared this data to my model and assigned the colour green to odds which were good and red to ones which were bad. Here is a screenshot of what some of this data looks like.


As you can see the odds my model created are very similar to what the bet-makers are suggesting which suggests it is fairly accurate, this model however doesn't account for lots of things such as player injuries and trades since the dataset I have used. In the future I would like to adapt my model to work based on the players on each team and update automatically as injuries and trades happen.


If you would like to see my code for this project it is available on my GitHub https://github.com/KitoSTheron

 
 
 

Comments


© 2035 by Train of Thoughts. Powered and secured by Wix

bottom of page