How to Simulate NBA Games in Python

  Рет қаралды 19,063

Ken Jee

Ken Jee

Күн бұрын

Пікірлер: 50
@VikashKumar-yg1hm
@VikashKumar-yg1hm 4 жыл бұрын
Hi ken, your videos are wonderful. I have been going through a couple of your videos and found them quite informative & relevant. Thanks for sharing your diverse experience here and giving us a head up. Please keep putting new stuff.
@KenJee_ds
@KenJee_ds 4 жыл бұрын
Thanks for watching! I am glad they have been helpful!
@datalyfe5386
@datalyfe5386 4 жыл бұрын
I never thought about simulating games before. Definitely going to give it a try!
@KenJee_ds
@KenJee_ds 4 жыл бұрын
Definitely do! You get some pretty fun results!
@dibs3458
@dibs3458 3 жыл бұрын
Informational. Love your content, man. Keep it up!
@KenJee_ds
@KenJee_ds 3 жыл бұрын
Thanks for watching!
@tomkmb4120
@tomkmb4120 2 жыл бұрын
This was a really interesting video. I'd love to see more like this.
@KenJee_ds
@KenJee_ds 2 жыл бұрын
Glad you liked it! I have a few more related to basketball I think. You should be able to search "basketball" in my channel to find them
@tomkmb4120
@tomkmb4120 2 жыл бұрын
@@KenJee_ds Thanks Ken, I'll take a look!
@delt19
@delt19 5 жыл бұрын
Very informative video. Any thoughts how to handle simulation for data that is not normally distributed. I'm thinking of player FGM, for example, that doesn't seem to be normally distributed.
@KenJee_ds
@KenJee_ds 5 жыл бұрын
Hi DT - If the data is not normally distributed, my favorite approach is to use re-sampling. You just randomly pick from the actual outcomes to form the distribution. Another approach is to use multiple distributions based on thresholds. You could say that if a sample is over a threshold the simulation is generated based off of a different distribution that the previous one.
@joeholleran7079
@joeholleran7079 5 жыл бұрын
Ken, great stuff! Thanks for walking us through your simulation. Quick question: the way you calculate the score seems to skew the comparisons if one of the scores is high. For example: If one team score is say 140-139 it averages to approx 140. The other team score is 120-90. It averages 105. So the team that won by 1 gets the win in the sim cause they scored a lot of points. But the other team won by 30 and had a better defense. Do you see my point? I'm thinking you ought to subtract and return a margin of victory then compare the margin of victory. Maybe worth running simulations to see how different they are? Thanks again!
@KenJee_ds
@KenJee_ds 5 жыл бұрын
Hey Joe - Thanks for watching the video and responding! In isolation (1 simulation) there could be skew introduced, but since we are running the simulation over and over again, these differences should normalize. With this we should get a realistic projected outcome set. We are using GSW offense vs CLE def and CLE off vs GSW defense, so just like in any game, an offense or defense could play well and have a very high or low score. To your point, you could also have a distribution of the point differential at the end of the game; that would be completely valid. However, I don't think that this method introduces any skew (again because of the 1000's of simulations). Does this answer your question? Happy to talk more about this if I am still not getting it or am incorrect here. Feel free to reach out via email kenneth.b.jee@gmail.com Thanks! Ken
@joeholleran7079
@joeholleran7079 5 жыл бұрын
@@KenJee_ds thanks for the quick reply! Yes, I definitely see your point. And like you said one of the advantages of the Monte Carlo is the high number of sims to allow for the probabilities to normalize. I'm working on a NBA model for a python class and am using a monte carlo sim. I'll mess around with some ideas and email you if I find anything insightful. I'm thinking it may be useful to get a random sample of the point diff THEN apply that to a random sample of the team pts scored. And then compare that to the same thing from the opponent. I'll see if this yields any meaningful changes on the probability. Have a good one, Joe.
@KenJee_ds
@KenJee_ds 5 жыл бұрын
@@joeholleran7079 Would love to hear what you come up with! Definitely let me know if you get different results. Good luck on the project! Again, feel free to reach out if you have any questions. Best, Ken
@delt19
@delt19 5 жыл бұрын
Very informative video. Any thoughts how to habdle simulation for data that is not normally distributed. I'm thinking of player FGM, for example, that doesn't seem go be normally distributed.
@panosphilalithis6741
@panosphilalithis6741 4 жыл бұрын
Hi Ken I was wondering where I could find the data for the latest season and before 2014 as well, I love your videos and used the nba_api but it doesn't seem to have a suitable endpoint. If you have any idea that would be so helpful, thanks!
@KenJee_ds
@KenJee_ds 4 жыл бұрын
I think there is an updated dataset related to this on kaggle!
@panosphilalithis6741
@panosphilalithis6741 4 жыл бұрын
@@KenJee_ds awesome, can you link it if you get a chance?
@thebetter1015
@thebetter1015 4 жыл бұрын
Any chance you sell a simulation software like this? Or is there somewhere I could download it? Very interested!
@KenJee_ds
@KenJee_ds 4 жыл бұрын
Feel free to shoot me an email at kenjee.ds@gmail.com! Not currently for sale, but I would be happy to talk about a custom solution or show you how to use the code base!
@thebetter1015
@thebetter1015 4 жыл бұрын
@@KenJee_ds awesome. I just sent an email to you using my personal email. Thank you!
@danrich1194
@danrich1194 2 жыл бұрын
I have a problem with the def game sim its telling me that im missing a ns argument
@tbnrsports188
@tbnrsports188 4 жыл бұрын
Hi Ken! Thank you for this video, I just used your code and built my own little model! Using 2020 data and looking back at the NBA games from back in March I would've correctly picked 9 of the 13 NBA over/unders correctly. This is a small sample size, but I believe the model I have is pretty accurate. However, I was wondering how I would make it more accurate? Like what new data points I should add to predict the score. I'm very excited about the return of the NBA.
@KenJee_ds
@KenJee_ds 4 жыл бұрын
Thanks for following along! Something that in theory could make it more realistic would be to do this based on minutes played for each play. You could create distributions for their points scored per minute and multiply that by each minute you expect them to play in a game. May be a little harder for the defensive type stuff, but in theory you could do the same thing. This gives a big more granularity to the simulation and could potentially be more accurate. No promises though haha!
@tbnrsports188
@tbnrsports188 4 жыл бұрын
@@KenJee_ds Awesome, Thank you for your help!
@surajsuresh6723
@surajsuresh6723 4 жыл бұрын
Hey Ken Can I use this model for my work. I’m thinking of creating something similar for soccer
@KenJee_ds
@KenJee_ds 4 жыл бұрын
Feel free to! I would appreciate it if you referenced it though!
@surajsuresh6723
@surajsuresh6723 4 жыл бұрын
@@KenJee_ds I would definitely tag you once I'm done on LinkedIn. I'm staryng to work on projects and post them. This will take time as my exams are on but will definitely tag you once it's done. Thank you so much
@KenJee_ds
@KenJee_ds 4 жыл бұрын
@@surajsuresh6723 Happy I could help!
@mkaberli
@mkaberli 5 жыл бұрын
Thanks for the video, but why do yo have such a small screenshot of the code? I’m watching this on an iPad and my eyesight sucks. Also, what is the point of having your image in the lower right-hand corner. Does you image make it easier to comprehend what concepts and ideas your expressing? All that negative space is distracting from your content, which is interesting e
@KenJee_ds
@KenJee_ds 5 жыл бұрын
Thanks for the feedback. This was one of the earlier videos I made, hopefully the more recent ones will be clearer. I also have a write-up of this if that would be easier to follow along with: www.playingnumbers.com/2019/12/how-to-simulate-nba-games-in-python/
@mkaberli
@mkaberli 5 жыл бұрын
Ken Jee: thank you. I appreciate it.
@guddusah2314
@guddusah2314 4 жыл бұрын
Very good video i like it
@derekjohnson5415
@derekjohnson5415 4 жыл бұрын
Great stuff!
@KenJee_ds
@KenJee_ds 4 жыл бұрын
Thanks for watching Derek!
@christopherchambers1622
@christopherchambers1622 4 жыл бұрын
Hi I am new to Python and am trying to set up the data and code in the program. How do i get the data over and start to work on the team stats?
@KenJee_ds
@KenJee_ds 4 жыл бұрын
Hi Christopher - You should put your data in the same folder as where your code is saved after downloading it from kaggle. Then the pd.read_csv('files.csv') should work. I hope this helpes!
@christopherchambers1622
@christopherchambers1622 4 жыл бұрын
Ok thanks, would using kaggle to do the sim work as well?
@jcvillainfo
@jcvillainfo 4 жыл бұрын
Thanks!
@KenJee_ds
@KenJee_ds 4 жыл бұрын
Thanks for watching!
@a_vickyp8360
@a_vickyp8360 4 жыл бұрын
#5: I come from the future, so I will answer your question: Yes, keep producing content, people will like it!!! he he Excellent video, I have some data from another sport and I'm on the EDA, but this gives me great ideas! Thank you!! #66daysofdata
@KenJee_ds
@KenJee_ds 4 жыл бұрын
hahaha Looks like past me took your advice!
The Best Way to Predict NBA Minutes Played
9:39
Ken Jee
Рет қаралды 6 М.
Predict NBA Games With Python And Machine Learning
58:33
Dataquest
Рет қаралды 52 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Sports Modelling Python Monte Carlo
10:04
Wagered On Tilt
Рет қаралды 2,8 М.
How to Scrape NBA Data Using the nba_api Python Module
16:29
The NBA Data Scientist
8:06
Bloomberg Originals
Рет қаралды 559 М.
How YOU Can Land a Sports Analytics Job
8:04
Ken Jee
Рет қаралды 76 М.
The 4 Types of Sports Analytics Projects
7:05
Ken Jee
Рет қаралды 34 М.
How to scrape SPORTS STATS websites with Python
12:53
John Watson Rooney
Рет қаралды 61 М.
Predicting the Winning Team with Machine Learning
29:37
Siraj Raval
Рет қаралды 226 М.
How to Scrape NBA Stats API with Python
15:01
Learn With Jabe
Рет қаралды 17 М.
7 Industries AI will Aggressively Disrupt
10:45
Ken Jee
Рет қаралды 7 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН