rd11490 / NBA_Tutorials

Tutorials for processing nba data
MIT License
157 stars 41 forks source link

A simple way to get players at the start of a period #3

Closed pxpwoa closed 5 years ago

pxpwoa commented 5 years ago

There is a sample way of using API of NBA.com to return the the players playing in initial seconds of period, like this api to return the start of 1st period: https://stats.nba.com/stats/boxscoretraditionalv2/?gameId=0041700404&startPeriod=0&endPeriod=14&startRange=10&endRange=240&rangeType=2 startRange must be setted to greater than 0.

rd11490 commented 5 years ago

So this is how I do it in my data pipeline. The issue is that it does not account for corner cases. The endpoint will not return a list of players if there is not an event inside of that range. There are also cases where a substitution happens in that range, or where the api only returns 3 or 4 players. As you go further back in time, this method becomes less and less reliable. I decided to go the route I went in the tutorial instead of this route so that the reader didn't have to delve into all of the strange corner cases and write a bunch of special code to handle them.

pxpwoa commented 5 years ago

You are right. Some corner cases will impact the accuracy of the way I suggest. As I focus on the realtime analysis of the game, I am intersted in looking the way can calculate the possession at the beginning of the quarter, instead of after that. I will check the way I suggest, and look for the way to fix the problem of reliablility.

rd11490 commented 5 years ago

I've found the best way is then to find first N events, use time constraints based on the time of those events. If any are subs then apply subs appropriately.

pxpwoa commented 5 years ago

It looks like that the project is not working in the game early, like 0011300108,0011300115.

rd11490 commented 5 years ago

interesting, i'll look into these two tonight.

rd11490 commented 5 years ago

Found the bug with those two. Also realized I was still using advanced boxscore instead of traditional