Investigating NBA Shot Data
Image from: https://www.stats.com/sportvu-basketball-media/
The Data Set:
The goal of this project was to investigate NBA shot data to better understand what variables affect shot accuracy and shot selection. The data set contained approximately 125,000 observations, with each observation corresponding to a shot that was taken during a game from the 2014-2015 NBA regular season. For each observation, approximately 20 different variables were tracked, including shooter's distance to the basket, distance from the shooter to the nearest defender, and much more. The data was recorded via SportVU technology, originally scraped from NBA Stats, and posted to Kaggle.
Accuracy vs. Shot Distance:
The first feature of the data set that I investigated was how shot accuracy varied with shot distance (1-dimensional). After plotting mean shot accuracy versus shot distance (given to the tenth of a foot in each observation), we notice an interesting feature in the graph:
The notable feature in the above graph is indicated by the yellow line: While accuracy among NBA players tends to generally decrease with shot distance, between approximately 10 to 20 feet, accuracy is roughly constant. One might naïvely expect that accuracy would be a strictly decreasing function of distance, reasoning that farther shots are strictly less likely to be made than closer shots (all else equal). So why isn't accuracy significantly decreasing as shooters get farther from the hoop between the interval of 10 to 20 feet? Certainly many factors could be responsible, but to list a few possibilities:
- Players practice free-throws (15 feet away from hoop) more frequently than other shots, thus they're more accurate from nearby distances.
- Defenders stay close to the basket, and guard their opponents differently depending on how close the opponent is from the basket--thus increasing the difficultly of closer shots (and the effects roughly balance out between 10-20 feet).
- Our initial intuition is wrong that farther shots are always more difficult, and the above graph depicts the general relationship between shooter accuracy and distance. (We could certainly test this in a controlled setting without defenders.)
Of the above hypotheses, the second is the easiest to test via the data set. We can do this by plotting the graph of how distance from the shooter to the nearest defender varies with shot distance:
It does, in fact, appear that within this 10-20 foot range that average closest defender distance increases as shot distance increases. Perhaps this can at least partially explain why shooting accuracy remains roughly constant within this range (closer shots are easier but more contested, longer shots are more difficult but less contested, and within the 10-20 foot range these effects essentially balance out with respect to accuracy). In order to test this hypothesis more directly, let's look at how shooting accuracy varies with distance, while keeping the distance from the shooter to the nearest defender ("Closest Defender Distance") constant. As the latter quantity was also given in increments of a tenth of a foot, it was appropriate to aggregate the data via 1 foot intervals in order to address sparseness.
We can notice that along most rows (where Closest Defender Distance is ~ constant) we see a more consistent decrease in accuracy within the 10-20 foot range, suggesting that indeed defender distance was at least partially responsible for the trend observed in the first graph. Of course to make more definitive conclusions we'd need to account for other relevant variables (shooter/defender height, for example) and perform appropriate statistical analyses.
Accuracy vs. Shooter Height:
The next part of the data that I investigated was shooter height and how it affected shot selection and shot accuracy. We can first look at a basic plot of mean accuracy versus shooter height to see:
At first glance, one might be tempted to conclude that taller players are better shooters, as their overall accuracy tends to be greater on average. However we can see from juxtaposing the following plots that this is likely due to a bias in shot selection:
Optimal Shot Selection:
The last part of the data that I investigated was shot selection. Naturally one would expect that the shots most frequently taken are likely to be the most optimal (from an expected value perspective). Already having plotted accuracy versus shot distance, it's simple to calculate and plot the expected value (of a shot) as a function of shot distance:
Interestingly enough, we can note that the largest EV shots take place at approximately 2.5 feet and 23 feet (3 pointers) from the basket, which are roughly the two distances from which the majority of shots are taken, as seen in the frequency graph on the right.
In the future, I'd like to potentially scrape the NBA Stats website myself to obtain two-dimensional data for shot distance and see how shot selection/accuracy is distributed according to actual location on the court (as opposed to simply distance from the basket). I'd also like to incorporate shooter/defender height disparity into the analysis of shooting accuracy as well.