/r/NBAanalytics

3,739 Subscribers

9

NBA Dataset to run SQL queries

Is there an NBA dataset available to run sql queries on? The one on kaggle by Wyatt doesn't seem up to date, unless I'm doing something wrong there. Thanks!

5 Comments
2024/10/02
20:34 UTC

2

Player Impact Estimate for download?

Does anyone know where you can download PIE (Player Impact Estimate) for individual players? Doesn't seem to be on basketball-reference

12 Comments
2024/09/27
07:15 UTC

1

Player and position strengths

I've been working player NBA metrics to learn more about player impact. Player strength is hard, but finally have something to show/tell.

Iv have a couple bias i'm trying to reduce with my dataset which people here will agree on, but are hard to quantify.

Bias 1. Current player strength metrics all have a "lineup bias". Given Player X, if player X is on a strong line, their calculated "Player Strength" will be higher than if they were on a weaker line. Playing with better teammates typically will give a person better stats.

Bias 2. Positions matter, Center, Forward and Guard all play differently. So good stats for a Forward are different than good stats for a guard.

My results to date are for Bias 2. Position. I made a model for each position and then looked at the feature importance for each position.

The Data:

  • Starters from 2008 to now taken from nba_api.
  • Only looked at Guard, Center and Forward
  • Focused on stats that don't depend on playing time.
  • Simple win/loss as the target.
  • Models for each position were created, allowed me to look into the impact of each stat for the position.

The initial results (normalized):

guard ={
    "E_OFF_RATING": 0.280,
    "DEF_RATING": 0.247,
    "TS_PCT": 0.215,
    "OBPM": 0.118,
    "EFG_PCT": 0.105
}

forward = {
    "E_OFF_RATING": 0.343,
    "DEF_RATING": 0.271,
    "TS_PCT": 0.265,
    "OBPM": 0.089
}

center = {
    "E_OFF_RATING": 0.216,
    "DEF_RATING": 0.206,
    "TS_PCT": 0.199,
    "OBPM": 0.191,
    "EFG_PCT": 0.040,
    "FG_PCT": 0.118
}

Interpreting the results.

Each stat in the position is how impactful it is on the players performance. E_OFF_RATING is weighted to 28.0% of a guards total power. Iv ignored stats with low feature importance.

on https://www.sharpsresearch.com/nba/match/0022301077/ iv made a table and have made "Player Strengths" which is the sum of players feature importance * their scaled stats.

guard strength =0.280×E_OFF_RATING+0.247×DEF_RATING+0.215×TS_PCT+0.118×OBPM+0.105×EFG_PCT

Note the website takes like 10 seconds to load atm due to tech debt.

Finally, ill need to adjust to normalize the last10 stats before calculating the positional strength int he table which hasnt been done yet.

0 Comments
2024/09/25
14:09 UTC

22

Do NBA Draft Combine Metrics Predict NBA Success?

edit: looks like the pics/visualizations aren’t showing up in this post on mobile for some reason, but you can see them here: https://www.formulabot.com/blog/do-nba-draft-combine-metrics-predict-nba-success

Kevin Durant, one of the greatest scorers in NBA history, famously couldn't put up a single rep of 185 on the bench at the combine. That begs the question--do combine metrics matter? Do they meaningfully predict NBA success in any way?

^(Spoiler alert: not really)

Methodology

Data collection:

  • Combine metrics: I used Python to scrape combine results from 2000-2023 from NBA.com, narrowing down the metrics to max vertical leap, lane agility time, three-quarter court sprint, and bench press. I also wanted to include height and weight, so I calculated height and weight ratios to adjust for height confounding.
  • NBA success: I decided to operationalize NBA "success" via Bball Index's all-in-one advanced impact metrics, LEBRON, which is further broken down into O-LEBRON and D-LEBRON for offensive and defensive impact, respectively. I scraped all 3 in R to use as outcome variables in my analyses.
  • Data pre-processing was conducted in R.

Analyses:

  • I ran linear regression analyses predicting all 3 outcomes from all 6 combine metrics individually (total of 18 models)
  • I then broke down each analysis by position for a total of 90 models.
  • I also ran a random forest model predicting the 3 outcomes from all 6 combine metrics combined.
  • All analyses were conducted using Formula Bot's chat feature. You can view the chat log here.

Results

Linear regression analyses (all positions):

After adjusting for multiple comparisons, only D-LEBRON was significantly associated with select metrics:

https://preview.redd.it/don1ir7rdsqd1.png?width=1300&format=png&auto=webp&s=f828029d6523e1032f68f091e6c7d3546c26c8f1

Surprisingly, vertical leap was negatively associated with D-LEBRON while slower lane agility and three-quarter court sprint times were associated with D-LEBRON.

Linear regression analyses (by position):

After adjusting for multiple comparisons, no single regression was significant due to small sample sizes and low statistical power.

https://preview.redd.it/ta6j9vwvesqd1.png?width=1300&format=png&auto=webp&s=eb215911111279f7e8ec4370fc248817c3c269dc

But if we ignore multiple comparison adjustments, there were some interesting significant effects:

  • Three-quarter court sprint time was negatively associated with both LEBRON and O-LEBRON (i.e., quicker times, higher LEBRON) for point guards only (not pictured above). The effect size for O-LEBRON was the largest in our entire dataset at -0.38.

  • Wingspan ratio was positively associated with D-LEBRON for power forwards and especially centers. The effect size for centers was 0.14, which was larger than the effect for any other position.

Here's a more in-depth visualization of the latter effect:

https://preview.redd.it/8lb3fpt8fsqd1.png?width=1300&format=png&auto=webp&s=b8828094cd7a16f8132c97db655e51938fbc17ef

Random forest models:

https://preview.redd.it/fbkoz7kdfsqd1.png?width=1228&format=png&auto=webp&s=9edde8eccaa8a66a64464e51b68e920be7c32bec

The LEBRON and O-LEBRON models were terrible fits (i.e., no meaningful prediction), but the D-LEBRON model had a decent fit, with all 6 combine metrics collectively explaining around 8% of the variance in defensive impact.

Takeaways

  • For offense, three-quarter sprint speed is the only metric that might reliably translate to NBA success—but only for point guards.
  • For defense, all metrics combined provide a little bit of predictive utility, explaining about 8% of the total variance in D-LEBRON.
    • Looking at the metrics individually, slow lane agility times and a high weight ratio seem to be the most important overall for D-LEBRON, although there are inconsistent effects (some positive, some negative) depending on position.
  • Wingspan ratio is the only metric with a consistent positive association with D-LEBRON across all positions. The effect is especially pronounced for centers.

A more in-depth write-up of my analyses and findings is available here: https://www.formulabot.com/blog/do-nba-draft-combine-metrics-predict-nba-success

5 Comments
2024/09/24
17:02 UTC

4

NBA scores predicting

Yesterday I finally invented a way to predict NBA games. Maybe 🤔

I use NBA API, calculate some averages, then I ask GPT about them, then create some embedding vectors, then logistic regression. In the end I have probabilities of a team scoring more than each possible score plus minus 20 from the real score. So the first 20 should have a higher probability of "more", the second 20 should have a higher probability of "less".

What do you think is the best way to test this algorithm? What metrics should I use to test it well and either against bookmaker predictions or at least against real scores, comparing the average accuracy to bookmakers?

0 Comments
2024/09/21
14:52 UTC

1

Looking For A Committed Owner To Fill A Spot In My Fantasy NBA 20 Team League!

Hello,

If anyone is interested in potentially joining a 20 team fantasy NBA league on ESPN, please feel free to reach out to me. This league has been running for 10+ years and is very competitive, serious, fun, and exciting!

It's head-to-head match-ups, with points format. (It's not categories).

12 teams make the playoffs. There is an entry fee set at 20.

If you wish to hear more details, I'd be happy to share them with you. You can email me at: hardcorebball@gmail.com

I'm looking to fill these spots ASAP!

Thank you!

0 Comments
2024/09/20
12:41 UTC

3

Does anybody have stats on which players were most impacted by NBA’s midseason rule changes on fouling calling for drives?

It’s reported by David Locke that the NBA is pleased and keeping the rule change they made during All-Star break of the 23-24 season. This rule change impacting how often the offensive players get foul calls when driving.

So, I was wondering if any of y’all had stats on which NBA players were most affected by this rule change be it TS% or something else. Like I guess TS before vs after All Star Break? If you have something else that’s fine too.

Thank You!

1 Comment
2024/09/20
10:33 UTC

16

Best NBA Writers

I wanted to highlight the best NBA writers in the field right now. Unsurprisingly, most of them are writing on Substack or Medium.

Neil Paine: https://neilpaine.substack.com/

Great source of data-driven work in all sports with massive audience. If you're looking for specifically basketball content, you might have to wait till the season starts. Still a remarkable writer and helped expand my worldview as a sports fan.

The Zone Master: https://thezonemaster.substack.com/

Hidden gem with less than 100 subscribers. Honestly the best amateur analytics writer in the field right now. - the ideas are innovative(check out the player tracking model) and the explanations are crisp for people inexperienced in data analytics. If you're looking for purely basketball analytics work, I would recommend this blog as my #1.

Logan Adams: https://www.loganadamsnba.com/

Great draft write-ups, and heavy emphasis on conceptual understanding over outcomes. His Prospects and Concepts series is going to be amazing this year. Check out his post on Nolan Traore, very informative and an emphasis on the parts that numbers can't really say much about.

Some others I like: Nic Thomas, JSuttHoops, Nick Kalinowski, Basketball Poetry.

4 Comments
2024/09/05
17:52 UTC

5

If we make a new metric called RMoWS(rap mentions over win shares), could Mo Bamba possibly be the goat by that stat?

0 Comments
2024/09/05
10:29 UTC

12

Check out this NBA Mini-Game I made using python

Check out this minigame I made in python using box scores from NBA API! 

Basically, you draft a 10-player NBA lineup, and then simulate a season to see how they perform.
Each player's performance in each game is based on a randomly selected game of theirs from last season.

https://www.playhoopgm.com/

https://preview.redd.it/h66fdym5j3kd1.png?width=1426&format=png&auto=webp&s=a4e49c89aee480fc15a36350e6c646f457f82aac

https://preview.redd.it/yt3w7y46j3kd1.png?width=1910&format=png&auto=webp&s=0ae5363c74439947ecc9e3bb32c20a25c761c503

0 Comments
2024/08/21
22:48 UTC

4

Chose Data Science as a major(Just graduated from Tunisian and HS thus total beginner) so would you recommend it as an introductory tool ?

for the record,I'm a complete beginner

I love Basketball thus I think it would be perfect to utilize NBA stats as a way to introduce myself to the topic since it's something I'm familiar with and if I like it why not become a sports analyst.

So for reference,I graduated from a Tunisian HS but we had a big emphasis on math since I was in the mathematics branch(last things I studied were things such as integrals/primitives/spatial geometry/stats/probability and arithmetic etc) which would like normal knowledge for an undergraduate seeking DS but if I were to compare test I got in Tunisia vs ones I've seen online in US,the difference is night and day.

The test I've passed/excelled at are much more comparable to US top AP tests or even some test in Uni.

So is Basketball Reference enough/can I start with this as an entry level student or is it not feasible?

3 Comments
2024/08/10
15:19 UTC

5

Unpacking the NBA Finals: Boston's Mastery Over Dallas

Hey NBA fans! I recently published an article on my Substack analyzing how the Boston Celtics clinched their 18th championship by outplaying the Dallas Mavericks. The piece uses detailed play by play data from the NBA. Highlights include:

  • Strategic Shot Selection and Execution: Analyzing Action and Shot Types
  • Precision and Placement: Analyzing Shot Location
  • From Shot Selection to Player Efficient Offensive Production: Analyzing EOP
  • Defense Wins Championships? Analyzing Hustle Plays

Check it out using the link below and let me know your thoughts!

https://sltsportonomix.substack.com/p/unpacking-the-nba-finals-analyzing

0 Comments
2024/06/27
15:19 UTC

11

NBA Streamlit Apps

Hey guys,

I built these NBA streamlit apps. I would really appreciate it if you check them out and let me know what you think and any areas of improvement.
Thanks
https://3dnbashotvisualizer.streamlit.app - This app plots NBA games from 2002 - present in a 3D form so you can see the shot paths of every shot. It also has many filters so you can customize what shots you want to see.

https://nbashotvisualizer.streamlit.app - This app is similar to the 3D but it is 2D and is player shot charts rather than games. You can select multiple seasons from a player and customize with filters. It also has a variety of shotcharts available like make/miss, heatmap, KDE, etc.

https://nbasalarycentral.streamlit.app - This app is a NBA salary predictor. It uses multiple features such as per game and advanced stats to predict a players value and predict a salary based on that value. It also has a bunch of other features and visualizations.

Thanks again.

5 Comments
2024/06/27
10:01 UTC

5

NBA shot chart court dimensions

Doing a project with NBA api data and was looking at NBA court dimensions. At first I was confused by the datum which is in feet x 10. This lead me checking the dimensions of publicly posted code and it seems many left out a critical detail, the 6" between the rim and the hoop. In fact, the NBA rule book clearly notes the center of the hoop is 15" from the plane of the backboard.

Many of these codes list the baseline as -47.5 but it should be -52.5, which is 5.25 feet (4' + 1' 1/4" [15"]).

https://preview.redd.it/l3kheavhnd7d1.png?width=671&format=png&auto=webp&s=4366db05994d33b8a9b2f3e3a9e0395864acbe5c

Code listed here would need to be revised:
How to Create NBA Shot Charts in Python - Savvas Tjortjoglou

College Basketball Shot Mapping with Python | by Amitparikh | Medium

3 Comments
2024/06/18
19:12 UTC

5

NBA Totals Predictor

Dad and I were traveling for work last week, found ourselves staying at the casino Thursday night. Both of us live in Boston so we figured we would catch the Celtics on the big screen.

Dad doesn't bet, but I do. Told him I liked the over 226.5, he tailed. When in Rome. The game finished at 236.

Riding home he was talking about how I should build a model for Totals. I have been working on some NFL models that I have posted about a couple times on other subs. ( wagerwerks.com )

By Friday night I had a working model.

1. 5/24: Predicted 214, finished at 217. Over 207.5 ✅

2. 5/25: Predicted 227, finished at 225. Over 222.5 ✅

3. 5/26: Predicted 214, finished 223. Over 207.5 ✅

4. 5/27: Predicted 223, finished 207. Under 223.5 ✅

5. 5/28: Predicted 212, finished ?

1 Comment
2024/05/28
17:05 UTC

0

Synergy Account

Was there any way I could use Synergy for free? There stats seem so sick, but man is it expensive

1 Comment
2024/05/24
16:05 UTC

3

Minute distribution across years in the NBA by cluster (playing style).

https://preview.redd.it/32z9qjina52d1.png?width=2880&format=png&auto=webp&s=9e92087015912104e29534a864f652f2090af3f7

Jokic is in cluster_2 and follows the light blue line.

It's very interesting to see the sharp decrease in variance and increased mean for cluster_4 after four years in the NBA. Cluster_2 seems to have a significantly greater minutes per season mean compared to every other cluster, in every year.

Unsurprisingly, every cluster also shows a steady decrease in mean minutes per season around 10 years into an NBA career.

1 Comment
2024/05/23
09:29 UTC

5

Is there any way to get tracking data at the level of individual shots?

Hi, so I was looking for a way to get tracking data (defender distance specifically) on individual shots so that I can integrate it with play-by-play data. Currently, you can get tracking data on shots at the season-level or even the single-day-level, either directly from nba.com (Players Shooting Dashboard Closest Defender | Stats | NBA.com) or from nba_api. However, I haven't found a way to get data on single shots. Is there any way for the public to access that type of data?

7 Comments
2024/05/18
13:46 UTC

17

Revolutionizing NBA Team Composition with Modern Portfolio Theory

I've published my last post on Substack where I apply Modern Portfolio Theory from finance to NBA team building. I wanted to combined my finance expertise and passion for sports, espacially basketball, for a long time. The post is about blending strategic investment principles with basketball team management to uncover new insights into forming winning teams. If that sounds interesting, come check it out and let me know your thoughts.

https://sltsportonomix.substack.com/p/revolutionizing-nba-team-composition?r=2mhplq

3 Comments
2024/05/06
12:37 UTC

1

Cleveland Cavaliers vs Orlando Magic Series Predictions | 2024 NBA Playoffs

0 Comments
2024/04/18
05:39 UTC

7

Teaching an NBA Statistics Course - Looking for Input

Hi! My name is Torsten Maier and I teach Industrial Engineering at Kettering University. I have a background in statistics and data analytics for manufacturing but a personal passion for the NBA. I have decided (with backing from my department) to teach an NBA Statistics course (starting in October). The goal of the course is to teach engineering students basic statistical and data analytic concepts but in a fresh application area that the students hopefully are passionate about and find fun and engaging.

I'm looking for any type of input from the broader community. This could range from specific content creators (Thinking Basketball is my favorite) that I should include in the course to specific ideas/topics that I should be sure to include (like the many different types of +/- stats).

Thanks ahead of time to anyone willing to throw in their two cents!

5 Comments
2024/04/17
18:36 UTC

3

NBA Challenge Rewind: Unveiling Top Insights from Analytics Experts

I recently hosted an event called the NBA Data Modeling Challenge, where over 100 participants utilized historical NBA data to craft SQL queries, develop dbt™ models, and derive insights, all for a chance to win $3k in cash prizes!

The submissions were exceptional, turning this into one of the best accidental educations I've ever had! it inspired me to launch a blog series titled "NBA Challenge Rewind" — a spotlight on the "best of" submissions, highlighting the superb minds behind them.

In each post, you'll learn how these professionals built their submissions from the ground up. You'll discover how they plan projects, develop high-quality dbt models, and weave it all together with compelling data storytelling. These blogs are not a "look at how awesome I am!"; they are hands-on and educational, guiding you step-by-step on how to build a fantastic data modeling project.

We have five installments so far, and here are a couple of my favorites:

  1. Spence Perry - First Place Brilliance: Spence wowed us all with a perfect blend of in-depth analysis and riveting data storytelling. He transformed millions of rows of NBA data into crystal-clear dbt models and insights, specifically about the NBA 3-pointer, and its impact on the game since the early 2000s.
  2. Istvan Mozes - Crafting Advanced Metrics with dbt: Istvan flawlessly crafted three highly technical metrics using dbt and SQL to answer some key questions:
  • Who is the most efficient NBA offense? NBA defense?
  • Why has NBA offense improved so dramatically in the last decade?

Give them a read!

0 Comments
2024/04/16
18:04 UTC

0

Every Regular Season Final Standings

This is probably easy for y'all but I just am not good yet at automated webscraping, and Power Query gets on my nerves. Is there a repository or dataset somewhere that would have every regular season final standings? I can use R or Python (or just a csv would work.)

I have stathead and basketball reference but clicking for every season and page seems tedious.

5 Comments
2024/04/15
18:31 UTC

2

Opponent Shooting Stats on NBA .com

Does anyone know if the Opponent Shooting stats page on NBA .com covers shots that the listed player guarded/contested, or is it just the opposing team's shooting stats when the listed player is on the court (regardless if the listed player contested the shot or not).

Stat page available here: https://www.nba.com/stats/players/opponent-shooting?DistanceRange=By+Zone&PerMode=Totals

1 Comment
2024/04/15
18:12 UTC

2

using tracking data to analyze perimeter defense/closing out?

does anyone have experience with doing something like this? Are there existing packages that facilitate this kind of visualization/analysis?

4 Comments
2024/04/15
05:43 UTC

2

Is there a net rating stat that’s weighted for opponent difficulty?

I was looking through the net ratings of different lineup combinations and I was wondering if there was a stat that would weigh the offensive and defensive efficiencies of those minutes against each opponents offensive and defensive efficiencies? So say if a certain lineup combination has played 20 of their 200 minutes vs the pacers(2nd offrtg, 24th defrtg), those 20 minutes would be weighted generously for their defensive rating but not so much for their offensive rating.

1 Comment
2024/04/10
19:17 UTC

3

We built a tool to automatically extract game state from NBA frames: https://vlm-demo.nos.run/

We built an API for automatically extracting game state (score, clock time, quarter) from frames in an NBA stream. We can support virtually anything that is visually indicated (shot clock, players on the court, fouls, TOs, even things like ref behavior) and would love suggestions for what might be useful from an NBA analytics standpoint? Try it out with your own inputs here: https://vlm-demo.nos.run/ (select the `sports.nba` schema). If you want to experiment with the underlying API, you can clone the repo https://github.com/autonomi-ai/vlm-cookbook. Check out our discord too https://discord.gg/a6suHC9B5E.

0 Comments
2024/04/08
20:33 UTC

1

NBA players by nationality 2024 dataset

Hi, I am working on a school project for NBA players by nationality to show the growth of basketball in Canada and internationally as a whole. Is there somewhere I could get the dataset for the 2024 season with the number of players playing in the NBA from each country?

4 Comments
2024/04/08
03:11 UTC

3

NBA Free Throw Attempt Breakdown

Does anybody know the breakdown of the different NBA free throw scenarios: what percentage of the time a player attempts one free throw vs. two free throws vs. three free throws at a time? Obviously, two is the most common scenario, but I'd like to find the exact percentages for a Monte Carlo Simulation.

3 Comments
2024/04/04
00:43 UTC

1

Dataset of all NBA players/seasons ever?

Hey y'all, I couldn't find the average career length of NBA players in terms of games played, so I tried to find it myself, and I was wondering if anyone knew how to find a complete dataset of all NBA players ever, or at least every individual player season ever. I worked off of data from 1998 to 2022 that I found online, but couldn't find a larger range. I figured this is something someone might already have.

As a note, the median number of games played was 135 and the mean was 252.03 for that smaller dataset.

1 Comment
2024/04/03
20:43 UTC

Back To Top