<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sebastien Darius on Medium]]></title>
        <description><![CDATA[Stories by Sebastien Darius on Medium]]></description>
        <link>https://medium.com/@sebasdarius?source=rss-3f0fcb707157------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fJkomBkieUCuOIRX3j89LQ@2x.jpeg</url>
            <title>Stories by Sebastien Darius on Medium</title>
            <link>https://medium.com/@sebasdarius?source=rss-3f0fcb707157------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:23:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sebasdarius/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Basketball Analytics, Part 2: Shot Quality]]></title>
            <link>https://medium.com/data-science/part-2-shot-quality-5ab27fd63f5e?source=rss-3f0fcb707157------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ab27fd63f5e</guid>
            <category><![CDATA[basketball-analytics]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[nba]]></category>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Sebastien Darius]]></dc:creator>
            <pubDate>Thu, 15 Jul 2021 22:13:11 GMT</pubDate>
            <atom:updated>2021-07-16T21:12:57.245Z</atom:updated>
            <content:encoded><![CDATA[<h4>Yes 3’s are better than long 2’s, but that’s not the whole story.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*rNYrbvTzFNZZkgdTlhLCtQ.jpeg" /><figcaption>From Wikimedia Commons</figcaption></figure><p>So we’ve reached the point that you’ve been waiting for. In this post, I’m going to explain why no player should ever shoot a midrange jumper ever.</p><p>Of course I’m not really going to do that. Very few things in sports are that cut and dry. But we are going to discuss one of the important points of contention for those who are skeptical of analytics. By the end of this, you should have some pretty good answers as to why the midrange shot has fallen so far out of favor. But our analysis will also raise at least as many questions as it answers.</p><h3>What does the data say?</h3><p>Let’s look at this in the simplest way possible. If we take all field goals from the 2020–2021 NBA regular season, how do these shots from different locations stack up to one another?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*VWQ7j5XvronFyzk8YZdS5A.png" /><figcaption>Highlight Table created with Tableau | Image by Author</figcaption></figure><p>There is a clear winner in terms of optimizing shot location. Shots that are very close to the basket are good. But the surprising thing is how quickly efficiency falls as we move away from the basket. There is a huge difference in efficiency between midrange jumpers and shots at the rim (Essentially layups and dunks).</p><p>Although 3-pointers are slightly more difficult than midrange jumpers (They have a lower FG%), they are more efficient. And this isn’t a small difference either. The average 3-pointer is .16 points per shot (PPS) more efficient than the average midrange jumper. Most NBA teams have a pace at around 100 possessions per 48 minutes. So over the course of a game, we would expect a team that shoots only 3 pointers to outscore a team that only shoots midrange jumpers by 16 points! That’s a difference too big to ignore.</p><h3>Are there any exceptions?</h3><p>The next step we might take to examine this question is to see if there are some players who buck the trend. In statistics, we like to aggregate things together and take averages. But we can benefit from getting more precise. After all, there are some players that we consider to be midrange specialists. So let’s see if these players tend to be more efficient from the midrange than from 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0PzSriyukbDTmBbHy_8DA.png" /><figcaption>Pie Chart created with Tableau | Image by Author</figcaption></figure><p>I looked to see how many players were actually more efficient on midrange attempts than on 3-pointers in the 2021 season. My sample only included players with at least 100 total field goals and 20 midrange and 3-point attempts. Out of these 274 players, only 21 of them were more efficient on midrange shots. That’s fewer than 8% of all players. Every other player was more efficient from 3-point range than from the midrange. And yes, this includes elite midrange shooters like Chris Paul and Kawhi Leonard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*qo-bJUuw26GaSnG2B1x3GQ.png" /><figcaption>Text Table created with Tableau | Image by Author</figcaption></figure><p>So even though it is important for us to treat each player differently, it’s not a good idea to ignore the overwhelming evidence based on only a few players.</p><h3>What this all means</h3><p>The end goal of all this analysis is to inform decision making. So what takeaways can we take from this data? The obvious answer would be to take fewer midrange jumpers and more layups and 3-pointers. But it’s not that simple. There are two teams in a basketball game, and the other team wants to prevent you from executing your game play. This means that the “best shot” on a given play might change depending on the context. What’s the opposing team’s defensive scheme? Who’s on the court? How much time is left in the game? What’s the score? These are all relevant questions when players decide which shots to take or not to take.</p><p>One way to look at the shot selection question is to realize that efficiency does not exist in a vacuum. Joe Harris led the league in 3-point percentage with 47% on 6.4 attempts per game. So one might say: “The Nets should just let him shoot a 3-pointer every single time down the court.” While that would be interesting to see, every basketball fan understands intuitively why this wouldn’t work out. One of the reasons why Joe Harris is so efficient is that he tends to take good shots and leave bad shots alone. Unless the team made some drastic shift in their overall strategy, the only way for Joe Harris to drastically increase the number of shots he takes would be to take more bad shots. That in turn would decrease his overall efficiency.</p><p>All that is to illustrate the point that there’s only so much we can take from this simple analysis. We can’t tell NBA offenses exactly how they should run, but we can make some general suggestions based on the data we saw.</p><h4>Don’t take long contested 2-pointers</h4><p>This one should make sense if you’ve read this far. Long 2’s are the worst type of shot, and the worst type of long 2 is one with a defender in your face. With the exception of late clock and late game situations, these shots are better left alone (Unless your name is Kevin Durant, in which case every shot is open).</p><h4>Perimeter players should cut out long catch and shoot 2&#39;s</h4><p>A big part of the 3-point shooting revolution has been an emphasis on the concept of spacing. Teams want to put good shooters on the floor and have them stand outside the three-point line when they don’t have the ball rather than inside of it. Why? Well the first reason is essentially what our whole analysis was about. We’d rather go for three points than two.</p><p>But there’s another reason. In general, you want players to be as spread out as possible. If players are all crowded inside the three-point line, that makes it easier for the other team to play help defense. This makes it more difficult for ball handlers and post players to get open shots. But this also makes it harder for shooters to get open and stay open. It’s much easier to close out on a 18-ft jumper than a 22-ft jumper.</p><h4>Coaches should emphasize schemes that result in 3’s and layups</h4><p>This one is pretty obvious. Call plays that get you good shots.</p><p>Here’s a list of what we <strong>cannot</strong> conclude based on this data:</p><ul><li>Players should never shoot midrange jumpers.</li><li>Players shouldn’t practice shooting midrange pull up jumpers.</li><li>Bad shooters should shoot more 3-pointers.</li><li>Teams should keep shooting from deep even when they’re cold.</li></ul><p>A couple of these may be questions that are worth studying, but they are not a result of the analysis that we’ve done.</p><p>Three pointers have done a lot to change the NBA game. They’ve also helped offenses to improve a ton. There obviously isn’t a perfect relationship between the 3&#39;s and efficiency. However, the dramatic increase in 3-point attempts has coincided with a dramatic increase in offensive efficiency for NBA teams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eoN4EbQGh_ph4G3ncCxW4Q.png" /><figcaption>Line Chart created with Tableau | Image by Author</figcaption></figure><p>Player tracking data will undoubtedly give teams more and better tools to study the topic in more depth. Also, Thinking Basketball recently put out <a href="https://www.youtube.com/watch?v=mi2zD-5uu1o">a great video</a> which discusses how and why certain stars still can make great use of the midrange shot.</p><p>If you’d like to see the Python code used for this analysis, check out this <a href="https://github.com/sebasdarius/data_science_portfolio/blob/master/Intro_to_Basketball_Analytics/Part_2_Shot_Quality/Analysis.ipynb">Jupyter notebook</a>. All data is from Basketball-Reference.com.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ab27fd63f5e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/part-2-shot-quality-5ab27fd63f5e">Basketball Analytics, Part 2: Shot Quality</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basketball Analytics Part 1: The Advanced Box Score]]></title>
            <link>https://sebasdarius.medium.com/part-1-advanced-box-score-6ce33e638fce?source=rss-3f0fcb707157------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ce33e638fce</guid>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[nba-analytics]]></category>
            <category><![CDATA[basketball-analytics]]></category>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[nba]]></category>
            <dc:creator><![CDATA[Sebastien Darius]]></dc:creator>
            <pubDate>Tue, 29 Jun 2021 17:57:14 GMT</pubDate>
            <atom:updated>2022-04-06T17:44:24.226Z</atom:updated>
            <content:encoded><![CDATA[<h4>Possessions, Efficiency, and the Four Factors</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*8OsiU-0b9sIeoAQwuk2z8A.png" /><figcaption>From Wikimedia Commons</figcaption></figure><p>This first part acts as a starting point for getting familiar with analytics. I’ll cover some “advanced” stats that actually aren’t so complicated once you know where they come from.</p><h3>Possessions</h3><p>One of the fundamental concepts in basketball analytics is that of the possession. A new possession begins when control of the ball switches from one team to another, or when a quarter ends. Under this definition, an offensive rebound continues an already existing possession instead of starting a new one.</p><p>The beauty behind this concept of a possession is that within a particular game, the two opposing teams will always have the same number of possessions in regulation, give or take 1 or 2 possessions.Why? Each team will begin 2 quarters with possession of the ball. So they’ll get at most 2 opportunities to get an extra possession at the end of the quarter. Because there are so few chances to gain extra possessions compared to the opposing team, we can say that the main object of an NBA offense is to maximize their points per possession. <strong>We call these per possession numbers “rate statistics”.</strong></p><p>We will tend to use possessions as our fundamental unit of measurement while examining performance. So let’s look at some “advanced” stats that use this point of view.</p><h3>Offensive, Defensive and Net Rating</h3><p>A team’s offensive rating is the number of points per 100 possessions a team scores. For example, the Milwaukee Bucks scored 8,649 points on 7,423 possessions during the 2020–2021 season. So they had an offensive rating of 116.5.</p><p>On the other hand, they gave up 8,225 points to their opponents on defense. So they had a defensive rating of 110.8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*awbytmiIOTlxiyLRi5ijMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*Hrq4zuB8vpj2NtFduKb_zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*OdejbW4v5lKQFONer27qDQ.png" /></figure><p>In general, a team wants to have a high offensive rating and a low defensive rating. This would mean that they scored efficiently on offense and gave up few points on defense. Net rating simply calculates the difference between a team’s offensive and defensive ratings. And of course a high net rating signifies a strong team. Net rating is a great measure of a team’s overall strength. As a matter of fact, it’s more accurate predictor of future performance than win percentage.</p><p>These ratings give a more accurate description of a team’s offensive and defensive prowess than per game stats. Teams that play at a faster pace will have more possessions and more opportunities to score. But as we established before, more possessions for one team also means more possessions for the other team.</p><p>One popular example of this was the “7 seconds or less” Phoenix Suns team coached by Mike D’Antoni. In the 2005–2006 season, the team averaged 108.4 PPG on offense (Led the league)and 102.8 PPG on defense (3rd highest in the league). Because of these numbers, they developed a reputation as a great offensive team and a terrible defensive team. But this was a fast paced team (hence the nickname) which also led the league in possessions. Once we adjust for pace, we see that they had an offensive rating of 110.2 (Led the league) and a defensive rating of 104.7 (15th highest in the league). So this tells us that the Suns were actually a great offensive team and a completely average defensive team.</p><h3>The Four Factors</h3><p>Let’s take a look at a few other examples of advanced stats that are potentially more informative than their more traditional counterparts.</p><h4>Effective Field Goal Percentage (eFG%)</h4><p>We traditionally have used field goal percentage to measure a players shooting efficiency on field goals. The problem with field goal percentage is that it counts made 2-pointers and 3-pointers the same. If I take 10 field goals and make 6 of them, my field goal percentage is 60%. But the number of those made shots that were 2&#39;s vs. 3&#39;s is really important. It could be the difference between 12 points and 18 points.</p><p>In the 2020–2021 season, Damian Lillard and Nikola Vucevic averaged the same number of field goals a game, and Lillard scored more points per game on those field goals. However, Vucevic(.477 FG%) had a higher field goal percentage than Lillard(.451 FG%), largely because he takes more shots closer to the basket. However, effective field goal percentage assigns an extra 50% for each made 3-pointer. When we make that correction, we see that Lillard (.554 eFG%) was actually more efficient than Vucevic (.540 eFG%) from the field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/187/1*YFlCdJpep6jWN60OR9xMPA.png" /></figure><h4>Turnover Percentage (TOV%)</h4><p>Turnover percentage is simply the percentage of a teams possessions that end in a turnover. Another way to think of it is the number of turnovers per 100 possessions. This is a more effective stat than turnovers per game for the same reason that offensive and defensive rating are more effective than PPG. You don’t want to penalize a team just because the play at a faster pace. Unlike the rest of the Four Factors, an offense wants to minimize its turnover percentage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/136/1*BxNiCWKymyBuaLbmjCdFwg.png" /></figure><h4>Rebounding Percentage</h4><p>The traditional stat for rebounds is rebounds per game. We’ve already discussed how pace affects per game stats. But for rebounds, there’s an added problem. As we all know, rebounds can only occur on a missed shot. So a team that rarely misses will have fewer opportunities for offensive rebounds than a team that misses a lot. Likewise a team that forces many misses will have more opportunities for defensive rebounds.</p><p>Since we want to isolate and key in on just rebounding, we use rebounding percentage. This is the percentage of all available rebounds that a team collects. This can be split up into offensive (ORB%) and defensive rebounding percentage (DRB%). That distinction is useful because some players and teams are more adept at grabbing rebounds on a particular side of the court than on the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*spFF6Dz4iSZ-_zGpasV37g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*zWlUdq5CT9Dhz-p9WYAoEg.png" /></figure><h4>Free Throw Rate</h4><p>This stat represents the ability of a team to get to the free throw line and make those free throws. We’re basically asking ourselves the question, how many of our team’s shot attempts end up in made free throws.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/1*C1xiq8UIRaQFPWM_V9wmiw.png" /></figure><p>The four statistics mentioned above are called the Four Factors. What’s so special about these four stats? Why couldn’t we use some other stats and call those the Four Factors? The reason is that these four represent all of the different ways a basketball possession can end. You will either end up with a made field goal, a turnover, a defensive rebound, or a made free throw. This means that if a team were to win across each of the Four Factors, they are essentially guaranteed to win the game.</p><p>The Four Factors can technically be thought of as 8 factors, 4 on offense and 4 on defense.</p><p>There are many other basketball statistics that are useful for analyzing player and team performance. While we can’t go over each one, my advice would be to start focusing on per possession stats rather than per game or per minute stats. This is especially true for players who have a large enough sample size. If you get your basketball data from either NBA.com or Basketball Reference, you can easily find glossaries that give brief descriptions of their stats. That way, you can have confidence that the stat is measuring what you think it is.</p><h3>Further Reading</h3><p>Thinking Basketball has <a href="https://www.youtube.com/watch?v=gJAoM-eF_f8">a video</a> that covers the same topics discussed in the article. And <a href="https://statsbylopez.files.wordpress.com/2016/01/jqas-2007-3-3-1070.pdf">this article</a> covers the concept of possessions and advanced stats in more detail.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ce33e638fce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analytics for NBA Fans]]></title>
            <link>https://sebasdarius.medium.com/analytics-for-nba-fans-5573f6b144ca?source=rss-3f0fcb707157------2</link>
            <guid isPermaLink="false">https://medium.com/p/5573f6b144ca</guid>
            <category><![CDATA[nba]]></category>
            <category><![CDATA[basketball-analytics]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[basketball]]></category>
            <dc:creator><![CDATA[Sebastien Darius]]></dc:creator>
            <pubDate>Sun, 27 Jun 2021 22:46:27 GMT</pubDate>
            <atom:updated>2024-03-06T22:56:10.389Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nTdCHRESLHVJc1gznFOVww.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@wugod1852">Corleone Brown</a> on Unsplash</figcaption></figure><h3>“Man I think all that stuff is stupid!”</h3><p>NBA fans will not be surprised to hear that this was Charles Barkley’s reaction to a question about basketball analytics on NBA TV’s Open Court. <a href="https://www.youtube.com/watch?v=mnX-V89oWKI&amp;t=346s">On this particular episode</a>, a panel of basketball legends discussed the changing NBA landscape. These giants of the game gave great insight into the effect of analytics on the modern NBA. But to anyone watching the program, one undeniable fact stands out: The general public, including these legends, are distrustful of analytics. And they have a right to be.</p><p>The fact is that most of the resources for learning about sports analytics are geared towards professionals who are already fluent in statistics. And the attempts to introduce these concepts to fans have not given the subject the thoroughness that it needs. That means that there’s no practical way for the average fan to understand what the heck we’re talking about when we mention Real Plus Minus or Win Shares.</p><p>That’s why I’m starting this series tailored to NBA fans. This series has two goals. The first is to explain the statistics needed to have a working understanding of sports analytics. My plan is to explain what you actually need to know in simple terms. The second goal is of course to show how these general statistical concepts can be applied to basketball.</p><p>Now I know some of you are thinking: “I’m with Charles on this one. I don’t need to know any of this. Just watch the games.” Allow me to respond while taking a look at some of my favorite quotes from that episode of Open Court.</p><p>Note: I am arguing for why analytics should be used as a part of the process in the game of basketball. I am by no means dismissing the expertise of players, coaches and others who have far more experience than I do. In the words of Jalen Rose: “Analytics should be a tool, not the toolbox.”</p><blockquote>“Whatever happened to good old fashioned scouting?”</blockquote><blockquote>-Reggie Miller</blockquote><p>Reggie Miller makes an important point here. We need folks who understand the game on a deep level to watch and give their insights. And while I will address that point some more later, in person scouting is necessary but not sufficient. There’s a reason why box scores were invented in the first place. No scout can go to or study film on every game. And even if they could, there’s no way for a human to physically remember everything that happens in the game (Unless you write it down, otherwise known as recording stats.) Scouting and statistics each give a partial picture of how players and teams perform. That’s why our goal should be to marry the two to have a more complete understanding of the sport.</p><p>There are real life examples of basketball knowledge that was discovered through data. For example, we now know that between 8 and 23 feet, field goal percentages don’t really decrease that much the further you step away from the basket. And we also know that the secret behind <a href="https://fansided.com/2014/11/01/geometry-distance-corner-3s/">the efficiency of corner threes</a> is not that they’re closer, but that they tend to be more open because they are harder to rotate to. Looking at the game through a different lens is extremely valuable.</p><blockquote>“They’re taking the intelligence out of decisions and eliminating the on the job training that we all experienced.”</blockquote><blockquote>-Isaiah Thomas</blockquote><p>Many people feel that the “numbers guys” are bringing a totally outside discipline where it doesn’t belong. But consider this: there are countless areas of knowledge (including academic fields) that started off being non-mathematical in nature, but have benefitted from the use of math. If you pursue a degree in sociology, political science or psychology, odds are that you’ll need to take some kind of statistics class. It’s a necessary tool in your toolbox that is used to verify and enhance your knowledge in that field.</p><p>There are even some areas where we’ve found mathematical methods that are more useful than traditional methods. For example, computer translation has come extremely far (You can reasonably trust Google translate while visiting a foreign country). But it was experts in statistics and machine learning, not linguists, who were <a href="https://www.freecodecamp.org/news/a-history-of-machine-translation-from-the-cold-war-to-deep-learning-f1d335ce8b5/">able to push it to such a level</a>. This is of course one limited example, but the point is that math is a lot more flexible and powerful than many might think.</p><blockquote>“Whoever made that up can’t even draw the last play for somebody to get an open shot.”</blockquote><blockquote>-Chris Webber</blockquote><p>Here, Chris Webber mentions something that I think is crucial for anyone using data to analyze basketball. Being an expert in statistics does not make you an expert in basketball. Data can only get us so far, especially in a sport as complex as basketball. The data analyst can use numbers to describe, diagnose and predict basketball performance. But ultimately, coaches and players have to decide how to turn those insights into action.</p><p>For example, we all know that according to the numbers, teams should shoot as many layups, free throws and open threes as possible. But that doesn’t really tell you how to do that. So analytics departments in NBA organizations communicate with coaches to get a better understanding of the practical actions the coach can take that can result in better shots. For example, the coaches may decide to start calling more plays that tend to result in shots in the paint. This would be a continuing process where the coach looks at data to figure out how effective the tweaks to his strategy are.</p><p>The last thing I want to mention is that we all use numbers. Every fan, player and coach takes notice of points scored, assists, field goal percentages and other stats. However, we also know that numbers are flawed. Statistical bias and randomness are everywhere. The ultimate goal of analytics is to put all of these numbers into perspective to gain a better understanding of what they all mean.</p><p>I hope that you’ll stay tuned as the series is released over the next several weeks.</p><h4>Part 1: Advanced Box Score</h4><p><a href="https://sebasdarius.medium.com/part-1-advanced-box-score-6ce33e638fce">https://sebasdarius.medium.com/part-1-advanced-box-score-6ce33e638fce</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5573f6b144ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basketball Hall of Fame Predictions with Python]]></title>
            <link>https://medium.com/analytics-vidhya/basketball-hall-of-fame-predictions-with-python-b7cee3724112?source=rss-3f0fcb707157------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7cee3724112</guid>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[random-forest]]></category>
            <category><![CDATA[sklearn]]></category>
            <dc:creator><![CDATA[Sebastien Darius]]></dc:creator>
            <pubDate>Fri, 22 May 2020 20:10:23 GMT</pubDate>
            <atom:updated>2023-04-22T16:37:45.475Z</atom:updated>
            <content:encoded><![CDATA[<p>The Hall of Fame is often a source of contention among basketball fans. Only the best of the best should be allowed in, but there are so many factors that go into the voters’ decisions. Here, we attempt to model their decision making and estimate players’ probabilities of being voted in.</p><p>A Tableau story containing visualizations related to this project can be found <a href="https://public.tableau.com/profile/jean6960#!/vizhome/BasketballHallofFameProbability/BasketballHallofFameProbabilities">here</a>.</p><p>The ipython notebook containing the code for this project can be found <a href="https://github.com/sebasdarius/data_science_portfolio/blob/master/Basketball_HOF/Model_Selection.ipynb">here</a>.</p><p>We used data scraped from <a href="https://www.basketball-reference.com/">basketball-reference.com</a>. We included gathered regular season and playoff stats, all-star game appearances, and various awards. We also used the same criteria as basketball-reference.com to decide which players our model would use to train. We only consider players who played the majority of their professional careers in the NBA and who have amassed at least 50 career win shares.</p><h3><strong>Model Building</strong></h3><p>First things first, we import some of the libraries that we’ll need to work with and read in our data file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1340b725f5f5d99d9c66f3970ff1408/href">https://medium.com/media/e1340b725f5f5d99d9c66f3970ff1408/href</a></iframe><p>Next, we create some features that we suspect could be very predictive. This is where domain knowledge can be very useful in machine learning. We also split our data into training, validation, and test sets. Since in real life, we would use past data to make predictions on future events, we use that approach to split our data.</p><p>We also remove the players who are not yet eligible to be voted in. The Hall requires players to be retired for at least 3 years before being considered.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10a2294cd51e60b69e46b023683db7cd/href">https://medium.com/media/10a2294cd51e60b69e46b023683db7cd/href</a></iframe><p>Next, we hand-select some features that we think are likely worth looking at. We identified 26 features that are like to be predictive. With a larger dataset, we may be able to start off with the full range of features. But with this small dataset (141 training observations), too many variables will make it hard for our models to learn.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c435528ebde9776a4176c89ffe5bc2e5/href">https://medium.com/media/c435528ebde9776a4176c89ffe5bc2e5/href</a></iframe><p>We also create a function called print_metrics to print out the accuracy and loss functions for our models.</p><p>We use Brier Score as our metric. We’re using this metric because it heavily penalizes large errors, and we don’t want our final probabilities to be very far from the truth.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fa371cbed5b4763e8678f6a3325a8a5/href">https://medium.com/media/5fa371cbed5b4763e8678f6a3325a8a5/href</a></iframe><h4>Logistic Regression</h4><p>The first model that we’ll try will be a logistic regression model. This is a good first choice because it’s a simple algorithm, meaning that it will be less likely to overfit than a more complex one. It also has a probabilistic interpretation which is important for our needs.</p><p>To select features for out logistic regression, we use sklearn’s recursive feature elimination (RFE) which fits our model and removes a feature on each step based on the coefficients of the previous step.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92f64ce42355d7c2f15c5c33e03ce5a1/href">https://medium.com/media/92f64ce42355d7c2f15c5c33e03ce5a1/href</a></iframe><p>Output:</p><pre>6 selected features<br>[&#39;Count_mvp&#39;, &#39;All_stars&#39;, &#39;Championships&#39;, &#39;box_plus_minus&#39;, &#39;value_over_replacement_player&#39;, &#39;ppg&#39;] <br><br>Training Accuracy:  0.8272251308900523 <br>Validation Accuracy:  0.9 <br>Out of Bag Accuracy:   <br>Training Loss:  0.10711748964899732 <br>Validation Loss:  0.0705776399962272</pre><p>When we print the coefficients of our optimal logistic regression model, we get the following.</p><pre>                               Coefficients<br>Count_mvp                          1.569915<br>All_stars                          2.117843<br>Championships                      1.551612<br>box_plus_minus                     1.191951<br>value_over_replacement_player     -1.241967<br>ppg                                0.437403</pre><p>We’ve found something unusual which is that the coefficient of “value over replacement player” is negative. This is surprising because this is a player metric that should be higher the better a player is. The negative coefficient is almost certainly a result of colinearity with some other feature. So we’ll just eliminate it from the model.</p><p>When we do, we get the following coefficients.</p><pre>Training Accuracy:  0.8272251308900523 <br>Validation Accuracy:  0.9 <br>Out of Bag Accuracy:   <br>Training Loss:  0.1148539455765552 <br>Validation Loss:  0.07083869752849309<br><br>                Coefficients<br>Count_mvp           1.681519<br>All_stars           2.267450<br>Championships       1.590180<br>box_plus_minus      0.114319<br>ppg                 0.228630</pre><p>Note: It seems like our model is performing better on the validation set than on the training set, which is also unusual. But this is probably due to the small size of the validation set.</p><h4>Random Forest</h4><p>Now we’ll try out one more type of model, a random forest. This algorithm also doesn’t tend to overfit very much, which makes it another good choice.</p><p>Again we use an sklearn feature to extract features for the model. This time, instead of using coefficients to remove features, we use sklearn’s feature_importance_. feature_importance_shuffles each feature and checks to see how much the model performance suffers from that feature being shuffled. The more the performance drops, the more important that feature is.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2338e89957ea10f074c21e9c5c5868cc/href">https://medium.com/media/2338e89957ea10f074c21e9c5c5868cc/href</a></iframe><p>Output:</p><pre>5 selected features<br>[&#39;All_stars&#39;, &#39;Championships&#39;, &#39;player_efficiency_rating&#39;, &#39;win_shares&#39;, &#39;ppg&#39;]</pre><pre>Training Accuracy:  0.9790575916230366 <br>Validation Accuracy:  0.8666666666666667 <br>Out of Bag Accuracy:  0.8743455497382199 <br>Training Loss:  0.029356830069540672 <br>Validation Loss:  0.08266228037366541</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*xiMQ11YPi4X88KB8zWXB2w.png" /><figcaption>Random Forest Feature Importances</figcaption></figure><p>As a sanity check, we create partial dependence plots for each of our predictor variables to see if we get positive relationships between each of our features and our target. Partial dependence plots let us interpret our model by seeing how it would make predictions for our training examples for different values of a particular feature. They essentially allow us to see the relationship between a feature and the target, at least according to the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/043ad255c20f138d5a288cbe2ebf4abf/href">https://medium.com/media/043ad255c20f138d5a288cbe2ebf4abf/href</a></iframe><p>Output for Points per Game and Championships:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*uI1VwPVEyVvf9W9Xl4t84Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*mhp6AltYAUuHfHOfJhSyEQ.png" /></figure><p>Although some of the plots have small initial dips, they all increase in the long run. So we can have confidence that the model isn’t finding some weird relationships between our variables.</p><h3>Combining Estimators</h3><p>Now we’ll see if we can get even better results by averaging the outputs of our two estimators.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9162a248b61c96ca1beb0b05e70c6424/href">https://medium.com/media/9162a248b61c96ca1beb0b05e70c6424/href</a></iframe><p>Output:</p><pre>Training Accuracy:  0.9476439790575916 <br>Validation Accuracy:  0.9666666666666667 <br>Training Loss:  0.06099515571971145 <br>Validation Loss:  0.03333333333333333</pre><p>This model seems to be doing better than the individual models. So we’ll keep this as our final model.</p><h4>Testing</h4><p>The last step is to test the model on our test set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a403af7e418f5baf2f173e7287f59b3/href">https://medium.com/media/3a403af7e418f5baf2f173e7287f59b3/href</a></iframe><p>Output:</p><pre>Ensemble: <br>0.8571428571428571 0.1364061293309076</pre><p>Even though we took precautions, it looks like our model may have overfit a bit. Without much data, it’s very hard to construct a reliable validation set to prevent this from happening. However, the model still seems to be working pretty well, especially in terms of accuracy.</p><h4>Model Visualization</h4><p>Lastly, let’s visualize how well our model performed on the test and training sets.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc97ec03bf0ec64b136ee4827f9edab8/href">https://medium.com/media/dc97ec03bf0ec64b136ee4827f9edab8/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*4VRLVg3BEQkunxdHi2w0pw.png" /></figure><p>We can see that our model clearly did much better on the training set than the test set. One noticeable observation is that most of the large errors in the test set are players that the model is confident will make the hall of fame.</p><p>Moreover, the biggest errors seem to be two very recently eligible players. This may suggest to us that the model may not be wrong and that some of these players may actually make the hall of fame, even though they haven’t made it yet.</p><p>So we were able to build a pretty decent classifier considering all the factors that go into a Hall of Fame career. With sklearn’s built-in features, some feature engineering, and using an ensemble of classifiers, we were also able to improve our model. We also made some data visualizations that helped us to interpret our models.</p><p>Thanks for reading!</p><p>Tableau Dashboard: <a href="https://public.tableau.com/views/BasketballHallofFameProbability-Darius/BasketballHallofFameProbabilities?:language=en-US&amp;:display_count=n&amp;:origin=viz_share_link">https://public.tableau.com/views/BasketballHallofFameProbability-Darius/BasketballHallofFameProbabilities?:language=en-US&amp;:display_count=n&amp;:origin=viz_share_link</a></p><p>Jupyter Notebook: <a href="https://github.com/sebasdarius/data_science_portfolio/blob/master/Basketball_HOF/Model_Selection.ipynb">https://github.com/sebasdarius/data_science_portfolio/blob/master/Basketball_HOF/Model_Selection.ipynb</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7cee3724112" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/basketball-hall-of-fame-predictions-with-python-b7cee3724112">Basketball Hall of Fame Predictions with Python</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>