Written By: Aashai Avadhani
Missed the big basketball game last night? Or have you ever thought about if NBA teams use the court efficiently enough? These are the questions I aimed to answer from my NBA Visualizer Analysis Simulation. For the final term project for my introductory computer science course “Fundamentals of Programming and Computer Science,” I built an NBA visualizer that reads tracking data, visually displays the tracking data, and uses a social analysis model to determine how efficient NBA teams are using the spacing of the court when playing defense or offense. The tracking data was made available from a user’s GitHub profile where he stored the SportVU data for some NBA games of the 2015-2016 NBA season. The NBA released multiple data sets contain tracking play-by-play data (from the company SportVU) regarding occurrences of what occurred during a regulation NBA game. The data set contained the x and y coordinates of all players on the court as well as the location of the ball on the court. Iterating through the dataset, I aimed to link it to another data set in order to make the visualization of the game more realistic and immersive for the user.
Going more into the technical details, the entire project is built using the Python programming language. Using the pandas library, I used data frames to unpack over 100,000 lines of coordinates efficiently and iteratively to produce a simulation experience fast enough and reducing as much lag as possible. Furthermore, the simulation application extracts data from another data set that shows the scores, players on the court, and description of events at every major play conducted in the game. I linked the two data sets through the common unit of time, so the event would show the players, scores, descriptions, and the play at the correct time from the datasets.
The next part of the simulation that allows us to learn more about the statistical information of the game is the Convex Hull Team Formation Efficiency Statistic. The convex hull is a geometric property that I have used to match an NBA’s team formation when teams are moving around the court. It is the best formation that encompasses the overall shape of an NBA team since it covers the total area that the team covers on the court. I then calculated the area of the convex hull that the team forms and then compared that with the size of the half court area in order to determine how much of the area the team is using. Based on the principle that teams should maximize their area when playing defense or offense, it is imperative to understand how a team is spacing out when they are playing defense or offense. The simulation then determines the efficiency statistic (the area of the convex hull divided by the area of the half court) in order to determine how efficiently the team is using the space on the court when playing defense or offense. Furthermore, within the simulation, it is able to determine which team has a better team formation, which could theoretically lead us to learn how teams play the game offensively or defensively. We can see from an example with the Wizards that they tend to play zone defense since they are not matched up with players and the size of their convex hull is smaller than the offensive team's (the Suns) formation.
From this information of special analysis, we as viewers can analyze what formations NBA teams tend to use, or how an NBA team conducts themselves on defense or offense. We can also learn the offensive and defensive tactics NBA teams, whether the wizards orient their offense behind 2 players based on their position (John Wall and Bradley Beal) or the Warrior’s offensive formation is structured to score 3 pointers. This is a tool that can be used to learn the game of Basketball and overall, help viewers understand the knowledge of how their favorite teams play one of the world’s greatest game. The full code repository is on my github that you can check out at: https://github.com/AashaiAvadhani1
I received the tracking data from another repository github at: https://github.com/sealneaward/nba-movement-data