Investigating NBA Shot Data

Jack Enyeart
Posted on May 1, 2017

Image from:

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.

About Author

Jack Enyeart

Jack Enyeart

Jack received his Master's in mathematics from Duke University, with a focus in probability theory. He is now an aspiring data scientist, attending NYCDSA's 12 week bootcamp. In his free time, Jack enjoys cooking, watching movies, solving problems...
View all posts by Jack Enyeart >

Related Articles

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp