<?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[Hockey Stats - Medium]]></title>
        <description><![CDATA[Sharing data-driven analysis of a game of skill and a game of chance. - Medium]]></description>
        <link>https://medium.com/hockey-stats?source=rss----fa79b6b46d84---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Hockey Stats - Medium</title>
            <link>https://medium.com/hockey-stats?source=rss----fa79b6b46d84---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:33:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/hockey-stats" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Visualizing Top NHL Skater Stats Throughout Their Careers]]></title>
            <link>https://medium.com/hockey-stats/visualizing-top-nhl-skater-stats-throughout-their-careers-7af23aa30316?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/7af23aa30316</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[rstats]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Thu, 28 Jul 2022 15:40:32 GMT</pubDate>
            <atom:updated>2022-07-28T12:16:05.108Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*luhIaEKirruuE7ek" /><figcaption>Photo by <a href="https://unsplash.com/@braden_barwich?utm_source=medium&amp;utm_medium=referral">Braden Barwich</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We <a href="https://medium.com/hockey-stats/at-what-age-do-nhl-players-reach-their-career-high-point-totals-bf9f4a999ddf">previously</a> looked at what age NHL players scored their career-high point totals. Here, we look at a few of the best players and track their numbers over the course of their careers.</p><h3>Data</h3><p>2000–2009 skater data was pulled using the R package <a href="https://cran.r-project.org/web/packages/nhlapi/index.html"><em>nhlapi</em></a>. The top 10 players with the highest single season-point totals were included.</p><h3>Points</h3><p>Figure 1 corresponds to the top 5 skaters, whereas the bottom plot corresponds to 6–10. Some skaters, like Patrick Kane, have been very consistent the entirety of their careers. Others, like Dany Heatley, had a quick rise and fall, in part due to his injury-riddled career.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*-W5kMKT0MgxGwAW72JIYVA.png" /><figcaption>Figure 1</figcaption></figure><h3>Points per Game</h3><p>Figure 2 visualizes points per game. This more clearly illustrates Dany Heatley’s decline in his late 20s and Crosby’s career steadiness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*ELByX8UJig3wSFnNH2ZLpA.png" /><figcaption>Figure 2</figcaption></figure><h3>Goals</h3><p>Finally, Figure 3 showcases goal totals for the same players. Clearly, Alex Ovechkin is one of, if not the best, goal scorers of all time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*yM8nNP_0GnRIW8LWe5ssVA.png" /><figcaption>Figure 3</figcaption></figure><h3>Summary</h3><p>Some players are amazingly consistent while others have their ups-and-downs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7af23aa30316" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/visualizing-top-nhl-skater-stats-throughout-their-careers-7af23aa30316">Visualizing Top NHL Skater Stats Throughout Their Careers</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[At What Age Do NHL Players Reach Their Career-High Point Totals?]]></title>
            <link>https://medium.com/hockey-stats/at-what-age-do-nhl-players-reach-their-career-high-point-totals-bf9f4a999ddf?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/bf9f4a999ddf</guid>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[hockey-stats]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Tue, 26 Jul 2022 02:34:41 GMT</pubDate>
            <atom:updated>2022-07-26T16:14:17.539Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4AmC9YEKfjTy8Q5vYtiT6Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@taylor_friehl?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Taylor Friehl</a> on <a href="https://unsplash.com/s/photos/hockey?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Is it worth investing a large chunk of the salary cap into an aging player on the other side of their prime?</h4><h3>Introduction</h3><p>Big name trades involving the likes of Matthew Tkachuk (24yo) and Jonathan Huberdeau (29yo) have once again raised the question of whether it is a worthy investment to sign big contract players eclipsing the peak of their careers. Here, we take a quick look at the distribution of ages at which players achieved their career-high point totals.</p><h3>Data</h3><p>2000–2009 skater data was pulled using the R package <a href="https://cran.r-project.org/web/packages/nhlapi/index.html"><em>nhlapi</em></a>. Goalies were excluded from this visualization. In total, there were 804 unique skaters that were further subdivided into five groups based on their age ([1,2] (2,5] (5,9] (9,13] (13,21)]) at which they hit their career-high point totals.</p><h3>Results</h3><p>The density plot below visualizes the ages of NHL skaters at which they scored their career-high point totals. The different colors correspond to five different percentile bins based on career length, where red corresponds to players that only played 1–2 seasons (0–20%), while purple corresponds to players that played between 13–21 seasons (80–100%).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*fF1fxUKpJ_KKDGrglq3zNw.png" /></figure><p>Generally, all five groups peaked early and tapered off quickly. Of particular interest was the purple group (80–100%), which was relatively flat in comparison to the other groups. For these skaters that had longer careers (a rough indicator of proficiency), there was more variability over when a player achieved their max point total, with the peak around the 27yo mark. Following, there was a steady decline indicating that fewer and fewer players had their most productive seasons moving into their mid-30s.</p><p>There were some notable findings. For example, Joe Pavelski had his career-high points total (81 points) in the 2021–2022 season at the ripe age of 37. Equally impressive was when Patrice Bergeron scored 79 points in the 2018–2019 season in just 65 games (points per game of 1.22) at the age of 33. On the other extreme, Sidney Crosby achieved his career-high points total of 120 at the age of 19!</p><h3>Conclusion</h3><p>Based on the results, it is rare for players to hit their career-high point totals late in their careers. <em>This does not mean their production completely drops off the table at a certain age, just that they do not quite reach that same peak level as before </em>— stay tuned for an upcoming post examining this idea more closely. In conclusion, teams ought to err on the side of caution when signing large-contract players that are nearing the end of their 20s.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf9f4a999ddf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/at-what-age-do-nhl-players-reach-their-career-high-point-totals-bf9f4a999ddf">At What Age Do NHL Players Reach Their Career-High Point Totals?</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Trading for NHL Draft Picks Worth the Risk?]]></title>
            <link>https://medium.com/hockey-stats/is-trading-for-nhl-draft-picks-worth-the-risk-dda45490fe37?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/dda45490fe37</guid>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Tue, 12 Jul 2022 12:32:32 GMT</pubDate>
            <atom:updated>2022-07-21T04:40:32.602Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zY11RU-Hp8gi7Di8" /><figcaption>Photo by <a href="https://unsplash.com/es/@timtrad?utm_source=medium&amp;utm_medium=referral">Tim Trad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Piling up draft picks is exciting, but they may develop into fewer serviceable players than you might expect.</h4><h4>Outline</h4><ol><li>Intro</li><li>Data</li><li>Results and Discussion</li><li>Code</li><li>Connect</li></ol><h3>Intro</h3><p>All the excitement surrounding the 2022 NHL draft called into question the risks and rewards of trading current NHL players for draft picks. For example, how often do draft picks actually develop into serviceable NHL players? In this article, we will investigate this as well as look at the associations between overall draft position and draft round with basic metrics like games played, seasons played, and points.</p><h3>Data</h3><p>5096 records from 2000–2021 were downloaded from <a href="https://www.hockey-reference.com/draft/">hockey-reference.com</a>. Any analyses involving points excluded goalies. Most analyses excluded the 2018–2021 drafts to allow for sufficient time for most draft picks to make the NHL (Figure 1). Only the first 7 rounds of drafts were kept for most analyses as the more recent drafts only have 7 rounds.</p><h3>Results and Discussion</h3><h4><strong>Most draft picks never play in the NHL</strong></h4><p>Below, Figure 1 shows that only 3% of draft picks from the 2021 draft played at least one NHL game in the same 2021–2022 season. This percentage jumped to 12%, then 27% for the 2020 and 2019 draft classes, one and two years removed since their respective drafts. Four years removed since the draft year, 43% of the picks from the 2017 class had played at least one game. These percentages hovered around this high 40s — low 50s for the classes that follow, indicating that it takes a few years to reach this plateau and that often the majority of draft picks never make the NHL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*JLHgfXKiUkgkDjJo628M4Q.png" /><figcaption>Figure 1</figcaption></figure><p>Expectedly, this was skewed towards lower draft picks (Figure 2). 94% of first round draft picks (between 2000–2017) played at least one game, 79% of which played at least 82 games (season length). 68% of second round picks played at least one game, while only 41% of which played 82+ games. On the other extreme, only 25% of 7th round picks played one NHL game or more, 11% of which played a full season or more. The Pearson correlation coefficient between draft round vs 1+ games played was -0.95, indicating that the later the round a player is selected, the less likely the player is to ever play an NHL game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*KZ_PmWIcerXBbdo7AkdZ0A.png" /><figcaption>Figure 2</figcaption></figure><p>This strong negative correlation remains when looking only at the top 100 draft selections (Figure 3). 100% of first overall picks play at least one NHL season, but this percentage quickly dropped off moving down the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*oQ3G5m4QHUMsi9pjfH-9tQ.png" /><figcaption>Figure 3. The gray regions correspond to 95% confidence intervals from the loess method.</figcaption></figure><h4>Earlier draft picks tend to have higher points per game</h4><p>While earlier draft picks tend to have higher points per game, there remains a high level of variability (Figure 4). Notable players include Nikita Kucherov (58th), Brad Marchand (71st), Jake Guentzel (77th), Brayden Point (79th), and Kirill Kaprizov (135th), who all have some of the highest scaled points per game values but were selected well outside of the first round. Still, at the very top sits Connor McDavid (1st overall, 2015), followed by Sidney Crosby (1st overall, 2005) and Evgeni Malkin (2nd overall, 2004).</p><p>The scaled points per game values were calculated by first calculating each skater’s point per game, then subtracting said values from mean of their respective draft classes. The purpose of this step was to reduce the effect of years in the NHL on points and create a class-by-class comparison. Of note, this analysis included both forwards and defensemen. Also, only points per game was analyzed, which by no means is the only metric to compare players.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*_sTTUAwn7gOhKQzWDcMfew.png" /><figcaption>Figure 4. Green line shows the linear relationship while the blue line is a loess curve. The Spearman correlation coefficients are shown in the top corner.</figcaption></figure><p>In summary, there is substantial risk in trading current players for draft picks, especially as selections are lower down the draft board. Of course, there remains the enticing, massive plus side if a team is fortunate to draft a Kirill Kaprizov or Brad Marchand.</p><h3>Code</h3><p>Available here: <a href="https://github.com/Christianlee19/hockey-stats/tree/main/bin/article_scripts/07-2022_draft">https://github.com/Christianlee19/hockey-stats/tree/main/bin/article_scripts/07-2022_draft</a>.</p><h3>Connect</h3><p>Feel free to connect with me at my new <a href="https://twitter.com/cal_hockeystats">twitter account</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dda45490fe37" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/is-trading-for-nhl-draft-picks-worth-the-risk-dda45490fe37">Is Trading for NHL Draft Picks Worth the Risk?</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Web Application Interfacing the NHL API in R with Shiny]]></title>
            <link>https://medium.com/hockey-stats/building-a-web-application-interfacing-the-nhl-api-in-r-with-shiny-b498bd0dd92c?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/b498bd0dd92c</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[sports-statistics]]></category>
            <category><![CDATA[r-shiny]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Sat, 02 Apr 2022 00:40:38 GMT</pubDate>
            <atom:updated>2022-04-02T00:40:38.639Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRSXo0KDOLNSaOJbjCGj8g.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/photo/man-people-woman-playing-6557738/">cottonbro</a></figcaption></figure><h4>A brief discussion of the process of making a desktop <a href="https://calee.shinyapps.io/hockeystatsapp/">hockey data visualization application</a> with Shiny.</h4><h3>Outline</h3><ol><li>Rationale</li><li>Current features</li><li>Upcoming features</li><li>Discussion</li><li>Code and references</li></ol><h3>Rationale of building the app</h3><p>There were three main motivations behind this project. First, I wanted to see for myself the capabilities of <em>Shiny</em> applications and the process behind building one. Second, I figured it would also be a great way to share data visualizations and allow users to interact with plots. Third, I wanted to test the <a href="https://cran.r-project.org/web/packages/nhlapi/nhlapi.pdf"><em>nhlapi</em> R package</a> created by Jozef Hajnala. Previously, I have outlined the process of <a href="https://medium.com/hockey-stats/two-approaches-to-scrape-data-from-capfriendly-using-rselenium-and-rvest-ab29c08e314f">scraping NHL data </a>and I wanted to see how that compared to interfacing the API directly.</p><h3>Current features</h3><p>The <a href="https://calee.shinyapps.io/hockeystatsapp/">app</a> currently has three main pages:</p><h4>Live player stats</h4><figure><img alt="Example figure displaying live NHL player stats from https://calee.shinyapps.io/hockeystatsapp/" src="https://cdn-images-1.medium.com/max/1024/1*SzN5uSb3SY_G9Qp-A_zJ2A.png" /></figure><p>This page showcases a radar plot comparing updated season totals for two user-selected players from a list of 40 skaters, the “top” 20 forwards and 20 defensemen. This list will be expanded in the future, but it is currently restricted as to maintain adequate loading speeds. Below the plot is a table of results where users can toggle between season totals, per game, or per 60 min stats.</p><h4>Live team stats</h4><figure><img alt="Example figure displaying live NHL team stats from https://calee.shinyapps.io/hockeystatsapp/" src="https://cdn-images-1.medium.com/max/1024/1*iQ51WwhNt7xs2vvhWu24fw.png" /></figure><p>This page allows users to select the X-axis and Y-axis variables for all 32 NHL teams with updated season totals. Currently, points are colored by their division rank. This plot is also wrapped using <em>ggplotly</em>, such that hovering over the points reveals more information.</p><h4>Blog</h4><figure><img alt="Gallery of blog posts from https://calee.shinyapps.io/hockeystatsapp/" src="https://cdn-images-1.medium.com/max/1024/1*PNHlF78rmZKLsI52iCujGg.png" /></figure><p>This showcases and links to articles posted here on Medium at <a href="https://medium.com/hockey-stats">hockey-stats</a>.</p><h3>Upcoming features</h3><ol><li>Live-game stats</li><li>League leader visualizations</li><li>User-selection of a specific season(s) and/or season-ranges (currently only 2021–2022)</li><li>Expanded player lists and goalies</li></ol><h3>Discussion</h3><p><em>Shiny</em> itself is intuitive and is a great visualization tool. Of note, <strong>deployment is extremely straightforward</strong> and hosting is also <strong>free</strong> with basic accounts. This component was completed in a matter of minutes.</p><p>As for challenges, the application does not scale perfectly on mobile. Considering I only tested the app on two laptops throughout the development process, it still looks decent on other devices. This is an area that will require more attention in the future and likely some more mobile-friendly design.</p><p>The <em>nhlapi</em> R package is user-friendly and great for accessing basic player and team data. At times I just had to write a couple of special extraction functions to access nested data. It is faster than scraping data and has the benefit of efficiently updating in real time. However, the latter has the benefit of being able to see data before pulling it and not limited by documentation.</p><p>Overall, building the application was an enjoyable process and I look forward to incorporating more features in the future. Any and all suggestions are welcome!</p><h3>Code and references</h3><p>Code is available <a href="https://github.com/Christianlee19/hockey-stats/tree/main/bin/hockeystatsapp">here</a>.</p><h4>References</h4><p><a href="https://cran.r-project.org/web/packages/nhlapi/nhlapi.pdf"><em>nhlapi</em></a> by Jozef Hajnala.</p><p><a href="https://shiny.rstudio.com/"><em>Shiny</em></a> from RStudio.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b498bd0dd92c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/building-a-web-application-interfacing-the-nhl-api-in-r-with-shiny-b498bd0dd92c">Building a Web Application Interfacing the NHL API in R with Shiny</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparing Current NHL Superstars with NHL All-Time Greats]]></title>
            <link>https://medium.com/hockey-stats/comparing-current-nhl-superstars-with-nhl-all-time-greats-650af0ba0f87?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/650af0ba0f87</guid>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[nhl]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Tue, 25 May 2021 12:02:16 GMT</pubDate>
            <atom:updated>2021-05-25T12:02:12.933Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*twr10TJkfi_MgHISCDpkcQ.jpeg" /><figcaption>Photo from Mike Zeisberger, <a href="https://www.nhl.com/news/connor-mcdavid-auston-matthews-part-of-wave-of-young-impact-players/c-291814680">NHL.com</a></figcaption></figure><p>Here we use k-means and hierarchical clustering of basic career stats to compare the top NHL skaters of all time and within the 2020–21 season. Just how good is McDavid? For now, let’s just say he is in good company…</p><h3>Data</h3><p>For this analysis, we consider career summary data for all NHL skaters since 1917 from <a href="http://www.nhl.com/stats/skaters?reportType=season&amp;seasonFrom=19171918&amp;seasonTo=20202021&amp;gameType=2&amp;filter=gamesPlayed,gte,1&amp;sort=points,goals,assists&amp;page=0&amp;pageSize=100">NHL.com/stats</a>. There is some missing information for earlier players, like plus/minus, so some analyses are restricted to those with complete rows. To automate the process of gathering the data, I scraped the tables using <em>RSelenium</em> and <em>rvest</em>. The code is available at the bottom of the article and a step-by-step tutorials of the process is available <a href="https://medium.com/hockey-stats/how-to-scrape-nhl-com-dynamic-data-in-r-using-rvest-and-rselenium-ba3b5d87c728">here</a>.</p><p>I performed some basic cleaning and preparation, like averaging the stats over games played (GP), and only keeping data for players with at least 75 GP. In the end, our main data frame contained ~4500 rows of players’ career averages.</p><h3>Identifying the top 100 NHL players by points</h3><p>First, to explore the data, I ranked the top 100 skaters by their points-per-game (PPG) average across their career and visualized them in the heatmap below. Quite a few active players crack the list: (in order of appearance) McDavid, Crosby, Malkin, Ovechkin, Panarin, Kucherov, Darisaitl, P. Kane, Matthews, Stamkos, Marner, MacKinnon, Pastrnak, Backstrom, Gaudreau, Eichel and Rantanen. Many of these players are just hitting their peaks now, while others are towards the tail end of their careers. It is worth mentioning this does slightly confound the analysis as we are looking at career averages and there is an expected drop-off in production over time, while some players may still have their best seasons ahead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P_ECWfPUgOzEba31lFdaUw.png" /><figcaption>Minimum 75 GP</figcaption></figure><p>Only five defensemen crack the top 100: Orr, Cameron, Coffey, Potvin and Bourque. 50/100 skaters were/are centers, 16 left wingers and 29 right wingers. Expectedly, at the top of the list, sits Gretzky and Lemieux. In this plot, white corresponds to a value of 0.5 (half a goal or assist per game), which goes to show just how exceptional these players are. Across all players in the entire dataset, the median G/GP and A/GP are 0.13 and 0.22, respectively. The minimum value in this elite group is 0.25 (Craig Janney for G/GP).</p><p>Interestingly, we can see some players were very much goal scorers, like Lalonde and Malone, while others, like McDavid and P. Forsberg, are/were more so playmakers. Then, there were other beasts, like Lemieux and Bossy, who had both the passing and scoring touch. Continuing on this thread of finding patterns across players, next we dive into unsupervised clustering.</p><h3>Clustering the top 100 NHL skaters of all-time</h3><p>For now, we just focus on the same two dimensions: G/GP and A/GP. Based on these two metrics, we can ask how many <em>types</em>, maybe even <em>tiers</em>, of players there are within this elite group.</p><h4>k-means clustering</h4><p>Comparing the within cluster sum of squares indicates that there exist seven clusters. Below, the top 20, Auston Matthews (45), and the bottom 5 players are labeled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iT7okGs71OpLFU8Jnhu61w.png" /></figure><p>Based on G/GP and A/GP, cluster 5 represents the best of the best: Gretzky, Lemieux, Orr, and McDavid. Often times we talk about how players today compare to those of previous generations. Here we see that McDavid truly is on pace to be one of the all time greats. Sitting just beyond cluster 5 are names like Crosby in cluster 7 and P. Forsberg in cluster 3.</p><p>Cluster 4 is another exceptional group composed of Dionne, Esposito and Bossy who all had above average G/GP and A/GP across the top 100. As mentioned early, Lalonde and Malone were goal scorers. In the map, they group together far along the X-axis to form cluster 1. Perhaps if Matthews can put together a few more Rocket Richard winning seasons, he may just join them.</p><h4>Hierarchical agglomerative clustering</h4><p>Using a bottom-up clustering approach, we can see the formation of similar clusters. As also captured by k-means, McDavid and Orr (far left) show very similar G/GP and A/GP numbers. In fact, they more closely resemble Forsberg than Gretzky and Lemieux because their G/GP averages are/were not quite as high as the latter pair.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JVhbWgHc578P7VNZ2Uhb_Q.png" /><figcaption>Ward’s Distance</figcaption></figure><p>To reiterate, these analyses have solely focused on G/GP and A/GP. There are several other important and interesting categories that we consider next, however, not all players have the data available so we will just focus on the more recent 2020–21 regular season (as opposed to career numbers).</p><h3>Clustering the top 100 skaters from the 2020–21 regular reason across multiple categories</h3><p>This figure includes short-handed points (SHP), plus-minus, shots (S), goals (G), assists (A), power-play points (PPP), points (P) and even-strength points (EVP), all averaged over games played. The clustering was also applied to both the players and metrics: from the dendrogram of rows, we see that EVP/GP and P/GP are the most similar, and closely related to PPP/GP and A/GP. Interestingly, S/GP and G/GP cluster together, then with SHP/GP and plus-minus/GP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5AX9XLFs31J4n4na4Bt6hw.png" /></figure><p>Along the X-axis are additional position annotations: 40 centers, 27 left wingers, 22 right wingers and 11 defensemen. For the most part, there do not appear to be many large clusters by position except for one discernible defensemen cluster (middle, dark green) characterized by a high A/GP and PPP/GP, and low G/GP and EVP/GP.</p><p>The far, bottom-left cluster represents the point machines, including the likes of McDavid, Draisaitl, Panarin, MacKinnon, Rantanen and Matthews. At the top-left are the the penalty-kill threats characterized by exceptionally high SHP/GP numbers: Marchand, Bergeron, Zibanejad, E. Kane, Toffoli, Aho, O’Reilly, Buchnevich, and Necas.</p><h3>Conclusion</h3><p>To summarize, we used k-means clustering and hierarchical agglomerative clustering to compare the top NHL players of all time (by P/GP) using G/GP and A/GP. We found that McDavid’s numbers mirror those of NHL legends like Gretzky, Lemieux and Orr. We also took a closer look at the most recent 2020–21 season and identified sub-clusters of skaters looking across eight different categories. Most notably, the majority of top defensemen grouped together based on their high A/GP and PPP/GP, and low G/GP.</p><p>Future work can certainly expand the number of categories and number of players. Corsi, Fenwick, and other advanced stats would make for an interesting analysis and would likely incorporate more defensemen into the lists. I also simply used P/GP to rank players but there are certainly other, more nuanced metrics that can be used.</p><h3>Code availability</h3><p>Code for scraping the data can be found <a href="https://github.com/Christianlee19/hockey-stats/blob/main/bin/article_scripts/05-2021_hiearchical_clustering/001_scrape_master.R">here</a>. Code for cleaning, analyzing and visualizing the data can be found <a href="https://github.com/Christianlee19/hockey-stats/blob/main/bin/article_scripts/05-2021_hiearchical_clustering/002_clustering.R">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=650af0ba0f87" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/comparing-current-nhl-superstars-with-nhl-all-time-greats-650af0ba0f87">Comparing Current NHL Superstars with NHL All-Time Greats</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How has regular season NHL goal scoring changed over time?]]></title>
            <link>https://medium.com/hockey-stats/how-has-regular-season-nhl-goal-scoring-changed-over-time-733c6b527c8d?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/733c6b527c8d</guid>
            <category><![CDATA[hockey-stats]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[sports-features]]></category>
            <category><![CDATA[sports]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Sat, 08 May 2021 16:02:31 GMT</pubDate>
            <atom:updated>2022-11-08T14:24:43.537Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HOGy5uevOTbEhVne" /><figcaption>Photo by <a href="https://unsplash.com/@rc_scout?utm_source=medium&amp;utm_medium=referral">Richard Ciraulo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We often talk about how much the game of hockey has changed. It is faster, more skilled, less physical, has improved gear and new strategies, etc.. Here we will take a closer look at some data to see if and how scoring and other basic metrics have changed over time.</p><h3>Gathering the data</h3><p>For this article, we will use <a href="http://www.nhl.com/stats/teams?aggregate=0&amp;reportType=season&amp;seasonFrom=19171918&amp;seasonTo=20202021&amp;gameType=2&amp;filter=gamesPlayed,gte,1&amp;sort=a_seasonId&amp;page=0&amp;pageSize=100">NHL.com/stats</a> team summary data from the inaugural 1917–18 season to the current 2020–21 season. This contains basic information like goals, points, wins, etc., summed over each season. The dataset is not entirely complete as earlier seasons are missing information like shots on goal (SOG) and faceoff percentages (FOW%).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FnVDZrr5gMUTVodKuX7z-Q.png" /><figcaption>Screenshot of NHL.com/stats</figcaption></figure><p>To automate the process of gathering the data, I scraped the website using <em>RSelenium</em> and <em>rvest</em>. This process is covered in detail <a href="https://medium.com/hockey-stats/how-to-scrape-nhl-com-dynamic-data-in-r-using-rvest-and-rselenium-ba3b5d87c728">here</a> and the code is linked at the bottom. It is also worth mentioning that this data was scraped on May 2nd, 2021, meaning the entire 2020–21 shortened season is not yet finished. Additionally, we are also only looking at regular season data here. Playoffs to come!</p><h3>Analyzing regular season NHL data</h3><p>Before looking into goal scoring, saves, etc., let’s first just take a look at season length. Each point represents a team’s season total, and since teams typically play the same number of games, they are mostly overlapping here. The colors here correspond to a decade of seasons and are consistent with the rest of the plots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*wcSaODx_VmNGr0jEMa6l2Q.png" /></figure><p>An interesting piece of history is that the Montreal Wanderers only played 6 games in the inaugural season, thwarted by a fire burning down their home arena, whereas the other three teams played 22 games. The Toronto Arenas went on to win the first Stanley Cup that season. We also observe that a few points deviate from the trend in the last two seasons. This is because the 2019–20 regular season was cut short due to the pandemic and the 2020–21 regular season was not over when I downloaded the data. The other dips correspond to lockout seasons. Nonetheless, the overall fact remains that NHL seasons have increased in length.</p><h4>Goals for over games played (1917-2021)</h4><p>Now moving into the most interesting metric: goals. Each point in the plot below corresponds to the team average goals for (GF) / games played (GP) over the course of a season. The NHL started with just four teams and has grown to 32, hence the increase in density of points over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Odzj5udP8oSrg50YRJ0GsQ.png" /><figcaption>Black = Edmonton Oilers</figcaption></figure><p>As we can see, NHL games were initially very high in scoring, with season-long averages of nearly 5 GF/GP (therefore about 10 goals per game). This quickly began to drop all the way to 2 GF/GP until the 1930s when the averages increased and steadied around 3 GF/GP. In the 70s, goals started to spike again reaching a max of nearly 4 GF/GP in the mid 80s. Afterwards, there was a steady decline to the 2000s where GF/GP eventually began to gently increase to today’s game where the average is just under 3 GF/GP.</p><p>The seasons from 1997–98 to 2003–04 are commonly referred to as the “dead puck era” because of the dip in production. During this period of time, more physical and slower play was the name of the game, whereas today revolves around skillful and fast skaters.</p><p>Nowadays, we often debate how McDavid’s place in history will stack up against players like Crosby and even Gretzky. The question always seems to come back to whether it is even possible to compare them because the game is so different. Is McDavid’s 2020–21 (24 years old for the Oilers)1.83 points-per-game (PPG) average akin to Gretzky’s 1985–86 (also 24 years old for the Oilers) 2.69 PPG average?</p><p>Firstly, note that we are now talking about PPG, which includes goals and assists. As a very rough test, we can first ask whether there is a significant difference between GF/GP between their respective seasons (unfortunately our data set does not contain season PPG numbers but GF/GP should still capture the idea). This does not compare the players directly but instead asks generally about scoring across the league at these time points. The league average was 3.97 GF/GP in 1985–86, which was significantly higher (pvalue = 1.195e-09) than the current 2.88 GF/GP of the 2020–2021 season. Naively, if we adjust for this ~27% decrease in scoring, then Gretzky’s PPG would sit around 2. Still higher than McDavid’s but closer than it might appear just looking at the stat lines!</p><p>However, it should be restated that this is not a thorough test by any stretch of the imagination. We can see from the black dots that the Oilers had an extremely high GF/GP during the Gretzky Era, largely driven by him. Likewise, McDavid boosts the current GF/GP average, but likely to a lesser extent. Simply adjusting for percent change does not capture all the complexities, so perhaps this something to be explored in a future article.</p><h4>Shots on goal (1959–2021)</h4><p>Next we take a look at SOG to see if volume of shots can in part explain the fluctuation in goals. Interestingly, when we compare SOG over time, the season averages are relatively constant. There were a few years during the late 90s and early 2000s where SOG dipped and correlated with a decrease in GF/GP, however, team SOG/GP averages hovered around 32 for the most part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*jePqT8maCkc7RcWFm4KaFg.png" /></figure><p>What this would suggest is that SOG, certainly when considering them in isolation, do not explain the variability in GF/GP. It is worth noting that here we are just talking about SOG, not shot attempts (SA) which includes off-target shots, hit posts and blocked shots. It would be interesting to see how SA and defensive stats, like shot blocks, have changed over time and have perhaps leveled out SOG.</p><h4>Save percentage (1959–2021)</h4><p>A major topic of debate is how goaltending has changed since the beginning of the NHL. Often times people will argue that today’s goalies are better, bigger and have improved tactics and gear. As a result, people claim it must be harder to score in today’s game.</p><p>Unfortunately, NHL.com/stats does have this data from as early as 1917, but we are still able to look as far back as 1959. Initially, Sv% was ~91%, then there was a steep decrease from the 1970’s to mid 1980s. In other words, a higher percentage of shots were finding the back of the net. Again this overlaps with the heart of Gretzky’s career, but we can also see that his team, the Oilers, held some of the lowest recorded Sv% in the history of the NHL. As the saying goes, a good offense is the best defense…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*qCrDDXBQRzEcaFiYa1ddmg.png" /></figure><p>Since these are team averages over the course of a season, a single player should not have too much influence on the trend, however, Gretzky undoubtably contributed to the drop in Sv%! Over the next 10 years, Sv% climbed its way back up to ~92% where it still hovers around today, although the tail end of the graph indicates this is beginning to drop again.</p><h4>Power play percentage (1977–2021)</h4><p>Finally, here we just compare PP% over time, beginning in 1977. Aside from a slight decline during the 1990s from ~20% to ~16%, PP% has been been more or less constant. Interestingly, the decline in the 1990s also overlapped with a local decrease in GF/GP and SOG, but increase in Sv%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*OONAyHQZRtKV2f2_aH87uQ.png" /></figure><p>Every season there are teams that really struggle with converting on power plays and others sitting around 30%. For example, in the 2020–21 season, the Ducks sit last in the league at an abysmal 9.2%, while the Oilers are again at the top with 27.2%. As we have seen <a href="https://medium.com/hockey-stats/identifying-the-best-predictors-of-nhl-game-outcomes-using-random-forest-b4c11f46bc97">before</a>, PP% is a major predictor for game outcomes!</p><h3>Conclusion</h3><p>The NHL today is a very different league than it used to be. Looking across 100+ seasons of data, we observed that GF/GP has fluctuated over time, while other stats, like SOG and PP%, have been relatively constant. There exist many speculations and explanations as to why metrics might vary or stagnate. Some point to the bigger and better goalies, others point towards improved strategy and more defensive game plans, or to more penalty minutes, or even to the spreading of talent across the league as it continues to grow in size. The list goes on and on. Any thoughts are welcome below!</p><p>This dataset and analysis was solely focused on basic regular season data. Upcoming articles will take a deep dive into playoff numbers as well as other categories and advanced stats.</p><h3>Code availability</h3><p>Code for scraping the data can be found <a href="https://github.com/Christianlee19/hockey-stats/blob/main/bin/article_scripts/05-2021_nhl_over_time/001_scrape_master.R">here</a>. Code for cleaning the data and creating the visualizations can be found <a href="https://github.com/Christianlee19/hockey-stats/blob/main/bin/article_scripts/05-2021_nhl_over_time/002_analyze_over_time.R">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=733c6b527c8d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/how-has-regular-season-nhl-goal-scoring-changed-over-time-733c6b527c8d">How has regular season NHL goal scoring changed over time?</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identifying the Best Predictors of NHL Game Outcomes Using Random Forest]]></title>
            <link>https://medium.com/hockey-stats/identifying-the-best-predictors-of-nhl-game-outcomes-using-random-forest-b4c11f46bc97?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/b4c11f46bc97</guid>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[random-forest]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Wed, 24 Mar 2021 15:03:11 GMT</pubDate>
            <atom:updated>2022-07-27T20:28:51.888Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*THKbgZM5QT6Tc0uGQe311w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@priscilladupreez?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Priscilla Du Preez</a> on <a href="https://medium.com/s/photos/ice-hockey-forest?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Dozens of different metrics are discussed by NHL statisticians and fans to better understand the game. Here, we develop a Random Forest model in R to pinpoint which stats are the most useful for predicting game outcomes.</h4><h4>Outline</h4><ol><li>Defining the question</li><li>Data scraping</li><li>Data cleaning and preparation</li><li>Random Forest implementation</li><li>Assessing the model</li><li>Conclusion</li><li>Code and references</li></ol><h3><strong>What are the best predictors of winning or losing an NHL game?</strong></h3><p>nhl.com/stats contains upwards of 20 different statistical categories each containing ~20 columns and thousands of rows. While there is some overlap between categories, there remains a surplus of variables, certainly too many to analyze one-by-one. We also do not want to consider variables in isolation because metrics capture different and/or complementary information.</p><p>Here, we will implement Random Forest to identify the most important features (metrics like shots on goal, faceoff wins, etc.) and learn a model that we can use to make predictions on new data. We will not be delving into the algorithm in great detail here, but <a href="https://towardsdatascience.com/understanding-random-forest-58381e0602d2?gi=b036eefa5c42">this</a> article is a good starting point. For now, just know that Random Forest builds hundreds of decision trees based on samples of features and observations, and then uses the average or majority vote to make final predictions. To help with the intuition, below is a single decision tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*SQpysTqyilTtR6klNohx2A.jpeg" /><figcaption>rpart.plot decision tree</figcaption></figure><p><em>X5v5.S..Sv</em> is the shooting + save %, <em>Net.PP</em> is the net power play % and <em>PK </em>is the penalty kill %. The first split is based on <em>X5v5.S..Sv,</em> such that a team with a value &lt; 98 has a 0.16 win probability, accounting for 41% of the total samples. On the other extreme, if a team has a score ≥ 102, then there is a 0.85 win probability with 40% coverage. A team with a <em>X5v5.S..Sv </em>between 98 and 102 and a <em>Net.PP</em> &lt; 16 has a 0.30 win probability and 10% coverage.</p><h3>Gathering the dataset</h3><p>This is the longest and most difficult part of the process because nhl.com/stats only allows us to download 100 records at a time. Manually downloading all of the records would be overly time-consuming and error-prone. Fortunately, I have covered data scraping in R <a href="https://medium.com/hockey-stats/how-to-scrape-nhl-com-dynamic-data-in-r-using-rvest-and-rselenium-ba3b5d87c728">before</a> in detail and the code used in this article is available at the end.</p><p>To gather game data from all teams, I selected “Teams” &gt; “By Game” and deselected “Sum Results”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b653GXD7wBX-91tXTcKnVQ.png" /><figcaption>Screenshot from nhl.com/stats</figcaption></figure><p>I decided to focus on these five reports: Summary, Faceoff Percentages, Miscellaneous, Penalties and Shot Attempt Percentages. There are several more available but these five seemed to provide enough coverage of interesting metrics. I also decided to include records from the 2017–2018 to 2019–2020 seasons to create a large dataset.</p><p>As a result, we were left with a 7415 x 105 data frame where each row corresponded to a specific game, home or away, and each column corresponded to a metric/feature.</p><h3>Cleaning the data and adding new features</h3><p>After preliminary filtering of missing data, duplicate columns, etc., the data frame was reduced to 6319 x 38. Below is a screenshot of the first three rows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pgLv0_tWU-YXbo2mQaRSBA.png" /></figure><p>Some of these stats are interesting but should not be used in their current form. For example, <em>X5v5.Sv</em> stands for 5-on-5 save percentage. A value of 100.0, as in row two, means the Oilers did not allow a single goal during even strength play. Since this type of statistic contains information about goals during the game itself, this could lead to inflated prediction accuracies and obvious conclusions; hockey is won by outscoring your opponent, so teams are always attempting to maximize shooting and save percentages. Nothing new there.</p><p>Instead, I created additional columns corresponding to values from previous matchup(s) and previous game(s), where matchups are those against the same team. This allowed to us to test if knowing how a team performed previously provided any predictive value for the upcoming game. I also created two additional columns, <em>OZDZ.FO_diff </em>and<em> Shot_diff,</em> to represent the difference between offensive and defensive faceoffs and total shots on goal, respectively.</p><h3>Random Forest implementation</h3><p>I began by imputing NAs then splitting the data into a training and testing set. I used the out-of-bag (OOB) error to tune the <em>mtry</em> parameter, which specifies the number of features randomly sampled at each split. As we mentioned earlier, sampling features at each node is one way that Random Forest reduces overfitting and increases generalizability. If everything goes correctly, the OOB accuracy and test set accuracy should be similar.</p><pre>oob_values = vector(length=20)<br>for(i in 1:20) {<br>  print(i)<br>  temp = randomForest(win ~ ., data=train, <br>                           mtry=i, ntree=500, <br>                           na.action = na.roughfix)<br>  oob_values[i] = temp$err.rate[nrow(temp$err.rate),1]<br>}</pre><p>17 proved to give the smallest OOB so that is what we will use in the final model. Another parameter that can be tuned is the number of trees, but for now we will just generate 1000:</p><pre>mod = randomForest(win ~ ., <br>                      data=train,<br>                      ntree=1000, <br>                      proximity=TRUE, <br>                      importance=TRUE,<br>                      na.action = na.roughfix,<br>                      mtry=which(oob_values == min(oob_values)))</pre><h3>Assessing the model</h3><p>When using Random Forest, OOB error is a metric used to assess model accuracy. OOB comes from Bootstrap Aggregation (Bagging), a process in which samples are randomly sampled <em>with replacement</em>. As a result, for each tree in the Random Forest, there remains untouched samples that can be used for internal testing. Below are the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*ThSJRpu9bB4Se4IHSG44ow.jpeg" /></figure><p>The average OOB estimate of the error rate was 30.36%, 31.10% for losses and 29.74% for wins (panel A). In other words, our predictions were correct 69.64% of the time, and marginally better for wins than losses. When I ran our model on the test set (panel B), we achieved similar results with an accuracy of 71.03%.</p><p>For hockey, ~70% is high accuracy. I suspect this is due to specific stats, like power play % and penalty kill %, that contain some information about goals or the lack thereof. Let’s take a look.</p><h4>Feature importance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*7iWBXtKQSKa_9Qp7ufqULA.jpeg" /></figure><p>In both panels, we have the various hockey statistics on the y-axis and a measure of variable importance on the x-axis. Mean decrease in accuracy refers to the loss in accuracy after permuting/shuffling values of a given feature. Mean decrease in Gini refers to the decrease in node homogeneity when permuting a variable. In our case, perfect homogeneity would mean all observations are wins or losses following a split. For both measures, a higher number equates to more importance. Topping our lists are <em>OZDZ.FO_diff, Net.PP, Net.PK, BkS, etc..</em></p><p>While these figures do indicate importance, they do not incorporate directionality. For that, we turn to SHAP plots which show the relationship of features with predictions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nNMusmXd1nzCL1k20Z3mMA.png" /></figure><p>In the SHAP plot, each point is an observation from the training data. The color corresponds to the original values, whether it is relatively high (red) or low (blue). For <em>Net.PP</em>, we see that the red dots are typically on the right/positive side of the x-axis while the blue dots show the opposite trend. Therefore, <em>Net.PP</em> is positively correlated with wins. Going into more detail, <em>Net.PP </em>is<em> </em>a<em> </em>given team’s power play goals minus conceded short handed goals as percentage of total power play opportunities. Therefore, a percentage close to 100 means the power play is highly productive, whereas a negative percentage means the power play is a liability. The same logic and correlation applies to <em>Net.PK</em>. This would suggest that NHL teams should spend more time honing their special teams and less time in other areas (lowly ranked features).</p><p>Another top features is <em>OZDZ.FO_diff</em>. A positive value<em> </em>means a team had more offensive zone faceoffs than defensive zone faceoffs. Intuitively, a higher <em>OZDZ.FO_diff </em>corresponds to more wins, however, we actually observed the opposite trend; teams that won typically had more defensive than offensive faceoffs. This is captured by the SHAP plot and the decision tree below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*j-2w-u3F_YQI8-Z2-y-IqA.jpeg" /></figure><p>Perhaps players and teams do well starting from their own zone because it provides an opportunity for a fast breakout. Or, maybe a team tends to have a negative <em>OZDZ.FO_diff</em> if they play a more defensive game. This could be the scenario if a team is winning a game and the coach wants to deploy a more defensive style instead of maintaining high offense. There are many explanations so this may even require a separate and dedicated post.</p><p>The statistics that we created, e.g. <em>points_previous_X_games </em>and<em> points_previous_X_mathcups</em>, rank towards the middle-bottom of the pack. This suggests that knowing how a team performed previously, in terms of points, offers little predictive value. This is particularly true when only looking back at a single game or matchup. Creating other variables, like goal differentials from previous games, could tell a different story and will be included in upcoming analyses.</p><h3>Conclusion</h3><p>We were able to scrape and clean data, create new features and implement Random Forest. We achieved ~70% prediction accuracy and determined that <em>OZDZ.FO_diff, Net.PP </em>and<em> Net.PK </em>were among the most important features<em>.</em></p><p>In future work, I will rerun this after removing any features containing goal information. That will include removing PP, PK, etc.. Additionally, I think it would be worthwhile to incorporate more counts alongside percentages since the latter does not capture magnitude. For example, a SAT% of 60 could result from a number of combinations: 60 vs 40 SAT (difference of 20), 42 vs 28 (difference of 14), etc.. In some cases, how much a statistic varies between opposing teams may contain valuable information.</p><p>Finally, I also want to run another analysis that only considers prior information so I can make complete predictions on game outcomes. This will mean incorporating more features like <em>points_previous_X_games</em>, <em>points_previous_X_matchups</em>, etc..</p><h3>Code</h3><p>There are three scripts for this article that can be found <a href="https://github.com/Christianlee19/hockey-stats/tree/main/bin/article_scripts/02-2021_random_forest">here</a>.</p><h3>References</h3><ol><li>Medium <a href="https://towardsdatascience.com/understanding-random-forest-58381e0602d2">article</a> on Random Forest</li><li><a href="https://uc-r.github.io/regression_trees">Regression trees</a> from UC Business Analytics</li><li><a href="https://towardsdatascience.com/explain-your-model-with-the-shap-values-bc36aac4de3d">SHAP values</a></li><li><a href="https://www.youtube.com/watch?v=6EXPYzbfLCE&amp;ab_channel=StatQuestwithJoshStarmer">Youtube video</a> from StatQuest</li><li><a href="https://github.com/StatQuest/random_forest_demo/blob/master/random_forest_demo.R">Code</a> from StatQuest</li><li><a href="http://www.nhl.com/stats/">NHL stats</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4c11f46bc97" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/identifying-the-best-predictors-of-nhl-game-outcomes-using-random-forest-b4c11f46bc97">Identifying the Best Predictors of NHL Game Outcomes Using Random Forest</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Hockey Stats 101: Zone Starts (Part 4 of 4)]]></title>
            <link>https://medium.com/hockey-stats/advanced-hockey-stats-101-zone-starts-part-4-of-4-1548b894541c?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/1548b894541c</guid>
            <category><![CDATA[hockey-statistics]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[hockey-stats]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[sports-statistics]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Thu, 07 Jan 2021 03:03:31 GMT</pubDate>
            <atom:updated>2021-01-07T03:39:50.372Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cZVk1LsPzqXFoZYM" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Here we take a closer look at the last of the main advanced stats, zone starts. This also serves as a primer for future articles delving into the validity and usefulness of hockey stats to make machine learning-based predictions.</h4><h3>Agenda</h3><ol><li>Zone starts definition &amp; theory</li><li>Season-average association of <strong>player</strong> zone starts with points</li><li>Season-average association of <strong>team</strong> zone starts with points</li><li><strong>Game-by-game</strong> association of team zone starts with wins</li></ol><h3>Data</h3><p>2019–2020 season total player data was downloaded from <a href="https://www.hockey-reference.com/leagues/NHL_2020_skaters-advanced.html">hockey-reference.com</a>. 2018–2019 home game data was scraped from nhl.com/stats. A tutorial on how do to this in R can be found <a href="https://medium.com/hockey-stats/two-approaches-to-scrape-data-from-capfriendly-using-rselenium-and-rvest-ab29c08e314f">here</a>. Afterwards, I applied some basic cleaning and filtering, for example, keeping players with &gt; 20 games played.</p><h3>Zone Starts</h3><p>As the name suggests, zone starts simply refers to the number of faceoffs in each end of the ice and not in the neutral zone. Note, these stats consider the number of faceoffs, not the number of wins. There are two main categories:</p><blockquote>oZS% = offensive zone faceoffs / (offensive zone faceoffs + defensive zone faceoffs)</blockquote><blockquote>dZS% = defensive zone faceoffs / (offensive zone faceoffs + defensive zone faceoffs)</blockquote><p>A team has an offensive zone faceoff if the opposing goalie covers the puck, opposing team ices the puck, gives up a penalty, etc.. Therefore, zone starts are theoretically a measure of offensive pressure, however, they are imperfect because a puck starting in one end of the ice doesn’t mean it stays there.</p><p>Zone starts can serve as a measure of player deployment since a team is often allowed to make a line change prior to the faceoff. For example, if one team ices the puck, then the other team is awarded an offensive faceoff and can make a change, while the defensive team cannot. Sometimes a specific line is better suited for a given situation so the coaches act accordingly. As a result, a player can tally an offensive, or defensive, faceoff even if he played no part in getting the puck to a given zone. Unfortunately, this does confound using zone starts as a measure of offensive pressure at the individual skater level.</p><h3>Average player zone starts over the 2019–2020 season</h3><p>The distribution of player zone starts from the 2019–2020 season is left-skewed with a mean just below 50. The grey lines demarcate +- 2 standard deviations from the mean, indicating the large majority of skaters had an oZS% between 35-63%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*Yo89hvqyO0av0TE2byzuFw.jpeg" /><figcaption>Distribution of oZS%</figcaption></figure><p>Below, we see the top and bottom 10 skaters by oZS%. Torey Krug tops this list with a staggering 68.4 oZS%, meaning when he was on the ice (or put on the ice), far more faceoffs were in his opponent’s end than his own. Jay Beagle and Tyler Motte of the Canucks are at the bottom of the list, indicating most of their faceoffs were in their own end. However, this is not necessarily indicative of their play and/or lack of offensive pressure. Perhaps they were frequently deployed in the case of a defensive zone faceoff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*X_Mm6hVOWBm48IZ8gkjkOg.png" /><figcaption>Top and bottom 10 by oZS%</figcaption></figure><h3>How do player zone starts relate to individual points?</h3><p>Below, we visualize points per game versus oZS%. Labeled are the top 10 forwards by oZS% + Draisaitl, McDavid and Panarin (top 3 by points per game).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*vwqRZdjgPyDd7YjkXUoaSA.jpeg" /><figcaption>ppg vs oZS%</figcaption></figure><p>There is a lot of variation, however, forwards with a higher oZS% generally have higher points per game averages. This makes sense under the notion that more offensive faceoffs = more pressure = more scoring opportunities. Draisaitl is again an interesting case because he had a relatively low oZS% for his league-leading point per game average.</p><p>One confounding factor is that this analysis used points per game which is not limited to even-strength play. Although, when we use EV points per game, we see a similar overall trend:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jo32o45BNOZsBak6Ca6s-g.jpeg" /><figcaption>EV ppg vs oZS%</figcaption></figure><p>Finally, this relationship is much weaker when considering defensemen. Scoring is not their primary role and thus points per game is not the best measure of their play. Some defensemen, like Andreas Englund, had 3 points over 24 games despite having a 65.3 oZS%. Other defensemen with a large offensive upside, like Cale Makar and Torey Krug, had both high oZS% and points per game averages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*qeynIA_gNPKe5p0y3tXBnA.jpeg" /><figcaption>ppg vs oZS%</figcaption></figure><h3>Season total team points versus zone starts</h3><p>While there is a positive correlation between oZS% and individual points, to determine if zone starts has much use for predicting game outcomes or standings, we have to consider team points. Below, we see each team’s point total after the 82-game 2018–2019 season versus oZS%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*_hseZaxLWb3UtpSo9VRlIw.jpeg" /><figcaption>x-axis: OZ FO/ (OZ FO + DZ FO)</figcaption></figure><p>For the most part, teams with higher oZS% had higher point totals. One standout was the Lightning who ended the season with a staggering 128 points but an oZS% &lt; 50. They won a record-tying 62 games in the 2018–2019 season, which goes to show that oZS% does not paint a full picture of team performance. Finally, it is also worth noting that the range of oZS% by the end of the season is quite narrow as the majority of teams are within ~5% of each other.</p><h3>Game-by-game association of zone starts and wins</h3><p>Now, to evaluate how zone starts relates to individual game outcomes, we will consider each home game of the 2018–2019 regular season.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*BFL6OcswDDJCOdwzAKUEeQ.jpeg" /></figure><p>Surprisingly, home teams that lost in regulation (0 points), tended to have an oZS% &gt; 50. Therefore, despite having a majority of offensive faceoffs, more goals were allowed than scored, and vice versa for the away team. Similarly, a team that lost in overtime (1 point) tended to have an oZS% &gt; 50, while a team that won (2 points) tended to have an oZS% &lt; 50. Perhaps the most interesting finding is that there are several instances in which a team lost despite having an oZS% close to 80. The opposite cases also exist where teams won despite having an oZS% of 20.</p><p>Overall, these distributions are fairly wide and share considerable overlap. The results are also counter-intuitive and contradictory to the season-total outcomes, so this game-by-game analysis may be capturing a spurious relationship. One explanation for this inconsistent relationship is that the former analysis considered each team individually while the latter considered all teams combined. Teams are not created equally so averaged effects may be heavily skewed. Another major consideration is that zone starts only incorporates even-strength faceoffs whereas a lot of point production occurs on the power play. Additionally, the sample sizes of faceoffs during individual games are small, so these associations are more influenced by <em>puck luck </em>and game-to-game variation.</p><h3>oZS% on win percentage</h3><p>Based on the violin plots above, I next asked how oZS% was related to win percentage. To do this, I first grouped game oZS% into 15 equally sized bins and averaged the number of wins. Interestingly, as the proportion of offensive faceoffs increases, the win percentage decreases. The first bin contains games in which the home team had an oZS% ~32. Despite having more <strong>defensive</strong> faceoffs, the home team actually won ~80% of those games. At the other end, teams with an oZS% of ~70 had a game win percentage &lt; 35%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*czGnvg4n3HnJpUIWg5NPag.jpeg" /></figure><p>This figure alone suggests that an average team is more likely to win if they have more defensive zone faceoffs than offensive zone faceoffs. However, a closer look revealed that teams were not evenly distributed across the bins. For example, the Calgary Flames occupied bin 15 (highest oZS%) 9 times and lost all 9 times, whereas the Vegas Golden won 5/6 games within this bin. On the flip side, teams like the New Jersey Devils occupied bin 1 (lowest oZS%) and won 5/6 times. This led me to believe that the correlation between zone faceoffs and wins was driven by a subset of teams.</p><p>To study this, I again binned games by oZS%, now into 5 groups to accommodate smaller sample sizes. Below, the size of circle corresponds to the number of games within a given bin. Each of these subsets only contained the 41 home games for each team since I used the same data from the previous two figures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtVOICYfC-Dj3a_9FGoJgw.jpeg" /><figcaption>2018–2019 home game results</figcaption></figure><p>Generally, the same pattern emerges in which home teams won the majority of games when they had a smaller fraction of oZS%, and lost the majority of games when they had a larger fraction of oZS%. Similarly to what was captured by the violin plots, the team-based line plots also show a large amount of fluctuation in the middle bins where the oZS% was close to 50.</p><p>A few exceptions to the overall trend include the Jets, Panthers, Lightning and Golden Knights. Interestingly, the Devils had very few games in which they had a high oZS% (small circle in bin 5) and showed no pattern with win percentage.</p><h3>Conclusion</h3><p>Zone starts is another theoretical measures of offensive pressure and player deployment, however, as we have discussed, it is imperfect because a puck starting in one end of the ice doesn’t guarantee possession and production. Across an entire season, we observed that a higher oZS% correlated with more player and team points. However, when evaluating oZS% on a game-by-game basis, we found that winning teams, more often than not, had a low oZS%. This was influenced by small sample sizes and team-effects, so oZS% should be used very cautiously when making game predictions.</p><p>On its own, zone starts don’t appear to be overly informative. Perhaps when incorporating additional variables, like faceoff wins, it would become more useful since there are several other factors that influence whether an offensive faceoff actually leads to a goal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1548b894541c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/advanced-hockey-stats-101-zone-starts-part-4-of-4-1548b894541c">Advanced Hockey Stats 101: Zone Starts (Part 4 of 4)</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Hockey Stats 101: PDO (Part 3 of 4)]]></title>
            <link>https://medium.com/hockey-stats/advanced-hockey-stats-101-pdo-part-3-of-4-d3f319f2e1f1?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/d3f319f2e1f1</guid>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[ice-hockey]]></category>
            <category><![CDATA[hockey-statistics]]></category>
            <category><![CDATA[hockey-stats]]></category>
            <category><![CDATA[nhl]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Fri, 01 Jan 2021 23:03:28 GMT</pubDate>
            <atom:updated>2021-01-01T23:03:28.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yf0AfJ44C5t1-gQL" /><figcaption>Photo by <a href="https://unsplash.com/@chrisliverani?utm_source=medium&amp;utm_medium=referral">Chris Liverani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Here we take a closer look at PDO and make some visualizations along the way. This also serves as a primer for future articles delving into the validity and usefulness of hockey stats to make machine learning-based predictions.</h4><h3>Agenda</h3><ol><li>PDO definition</li><li>PDO theory</li><li>Team PDO over the 2018–2019 season</li></ol><h3>Data</h3><p>2018–2019 advanced stat data was scraped from <a href="http://www.nhl.com/stats/skaters?aggregate=0&amp;report=percentages&amp;reportType=game&amp;dateFrom=2019-10-02&amp;dateTo=2020-03-11&amp;gameType=2&amp;filter=gamesPlayed,gte,1&amp;sort=satPercentage&amp;page=0&amp;pageSize=50">NHL.com/stats</a>. In this case, I had to use a CSS selector as opposed to the xpath method used in <a href="https://medium.com/hockey-stats/how-to-scrape-nhl-com-dynamic-data-in-r-using-rvest-and-rselenium-ba3b5d87c728">this</a> tutorial.</p><pre>df = read_html(url) %&gt;%<br>  xml_nodes(css=&quot;div[role=&#39;gridcell&#39;]&quot;) %&gt;%<br>  xml_text()</pre><p>We also scrape the table column names instead of manually typing them.</p><pre>header = read_html(src) %&gt;% <br>  xml_nodes(css=&quot;div[role=&#39;columnheader&#39;]&quot;) %&gt;%<br>  xml_text()</pre><h3>PDO definition</h3><p>PDO (SPSV% aka On-ice S%+Sv%) is the sum of shooting percent (S%) and save percent (Sv%) during even strength play. Often times, but not in our dataset, it is multiplied by 10 for the sake of using whole numbers.</p><blockquote>PDO = S% + Sv%, where</blockquote><blockquote>S% = goal / shots on goal and Sv% = saves / shots on goal</blockquote><p>For an individual player, PDO measures what happens when a given player is on the ice. For a team, PDO measures the total game counts.</p><h3>What does PDO really measure?</h3><p>A high PDO for team means a high proportion of shots for are going in, and/or a small fraction of shots against are going in. Therefore, the higher the PDO the better.</p><p>However, when talking about PDO, we often talk about <em>regression to mean</em>, meaning over time, a high PDO will fall to the mean (100), and a low PDO will rise to the mean. The reason the mean is 100 is because a shot on goal is either a goal or a save. Therefore, a total game’s S% and Sv% will always add up to 100. Likewise, summing over the entire season will always add up to 100.</p><p>For example, during game 6 of the 2020 Stanley Cup Finals, the Lightning had 24 shots on goal and 16 saves, while the Stars had 16 shots and 22 saves. The final score was 2–0 for the Lightning.</p><p><strong>SP total</strong></p><blockquote>24 shots + 16 shots = 40 shots</blockquote><blockquote>S% total = 2 goals / 40 shots = 5% (of shots resulted in goals)</blockquote><p><strong>SV total</strong></p><blockquote>16 saves + 22 saves = 38 saves</blockquote><blockquote>SV total = 38 saves / 40 shots = 95% (of shots were saved)</blockquote><p><strong>S% total + Sv% total = 100%</strong></p><h4>PDO and regression to the mean</h4><p>Regression to the mean ultimately says the difference between players and teams shrinks. While it might seem that some teams and/or players are going strong and will maintain their dominant performances, statistically, they tend to normalize over time.</p><p>This does not mean that every player and every team ends the season with a PDO of 100, only that the variation is reduced. For a NHL player to sustain a very high PDO, he and his linemates would need to remain extremely efficient in goal scoring and be consistently supported by lights-out goaltending. To have one dominant line over the course of a season is already a challenge, but to also have dominant goaltending is an anomaly.</p><h4>A special note for fans and fantasy owners</h4><p>PDO and regression to the mean is something to remember when your players have a slow start or even a slow month. Generally, their numbers will improve as pucks might start bouncing their way or for their teammates. Let this also be a warning to unsuspecting owners to avoid buying (or a tip to ruthless owners to sell) players high because their performance, more likely than not, will come back to earth.</p><p>As a result, PDO is normally distributed, as seen below. There will always be players at the tail ends but the bulk of skaters fall close to the mean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*qkmONaP5DgtMOKFnkBfYBg.jpeg" /></figure><h3>Team PDO over the 2018–2019 season</h3><p>Here, to visualize PDO over the course of a season, we are only going to consider team moving averages since the player game data is rather sparse.</p><p>Below, I colored the top and bottom three teams based on PDO after 10 games played. Additionally, the Lightning are shown in pink as they dominated the regular season with a final record of 62–16–4. Vasilevskiy won the Vezina and Kucherov was the points (128) and assists (87) leader, earning him the Hart Trophy. They ended the season with a PDO of 101.9, third highest in the league. Number one was claimed by the Islanders with a PDO of 102.2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*EXrp5GKF1IOu4kJUfV287g.jpeg" /></figure><p>Overall, the trend is exactly as we described. There is a lot of variation in the beginning, but over time, team PDO’s regress towards the mean. For example, the Ducks started out well but quickly fell to ~100, and the Golden Knights did the opposite. The Lightning show a different pattern and actually show what appears to be a steady or even slight incline over 100 as the season went on.</p><h3>Conclusion</h3><p>PDO tells us that teams and players may have ups and downs, but over time, variation shrinks as their numbers regress towards the mean. NHL skaters and goalies are the best in the game. The differences in skill, and its distribution across teams, makes puck luck a non-negligible factor and keeps hockey exciting. A few right or wrong bounces can drastically change the direction of a game. With that said, there are a few players who defy the odds. Hopefully they are on your team.</p><p>What we haven’t explored here is how game PDO relates to wins or points. Intuitively, we would expect the team with the higher PDO to win the game, however, the stats could be inflated by a very high Sv% bolstered by a high number of shots against, or a low number of goals over by a small number of shots for. Consider an extreme scenario where team A scores 1 goal on 10 shots and team B scores 2 goals on 50 shots:</p><blockquote>PDO team A: 1/10 + 48/50 = 106%</blockquote><blockquote>PDO team B: 2/50 + 9/10 = 94%</blockquote><p>Based on these numbers, team B dominated the game and won, but their PDO was 12% lower than team A. Therefore, PDO is heavily influenced by the number of shots, goaltending and luck.</p><p>While PDO is supposed to be a measure of how well a player or team is performing, if it doesn’t correlate well with other metrics, like points, the regression to the mean pattern might not be that important or informative.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3f319f2e1f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/advanced-hockey-stats-101-pdo-part-3-of-4-d3f319f2e1f1">Advanced Hockey Stats 101: PDO (Part 3 of 4)</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Hockey Stats 101: Fenwick (Part 2 of 4)]]></title>
            <link>https://medium.com/hockey-stats/advanced-hockey-stats-101-fenwick-part-2-of-4-a8796b8188d?source=rss----fa79b6b46d84---4</link>
            <guid isPermaLink="false">https://medium.com/p/a8796b8188d</guid>
            <category><![CDATA[hockey-statistics]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[hockey-stats]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[toronto-maple-leafs]]></category>
            <dc:creator><![CDATA[Christian Lee]]></dc:creator>
            <pubDate>Thu, 31 Dec 2020 01:51:46 GMT</pubDate>
            <atom:updated>2020-12-31T01:51:46.688Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QOJXORTRIxQtERNM" /><figcaption>Photo by <a href="https://unsplash.com/@jamesplewis?utm_source=medium&amp;utm_medium=referral">James Lewis</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Here we take a closer look at Fenwick and compare it to Corsi while making some visualizations along the way. This also serves as a primer for future articles delving into the validity and usefulness of hockey stats to make machine learning-based predictions.</h4><h3>Agenda</h3><ol><li>Fenwick definition and theory</li><li>Correlation between Fenwick and Corsi</li><li>Which is better for predicting points over the course of a season?</li></ol><h3>Data</h3><p>2019–2020 advanced stat data was downloaded from <a href="https://www.hockey-reference.com/analytics/">hockey-reference.com</a>. 2018–2019 team data was downloaded from <a href="https://www.icydata.hockey/">IcyData</a>.</p><h3>Fenwick definition</h3><p>Fenwick is another measure of shot attempts, a proxy of offensive pressure. More specifically, it counts any shot that is on goal, hits the post or misses the net during 5-on-5 play. That should sound awfully similar to Corsi, discussed <a href="https://medium.com/hockey-stats/advanced-hockey-stats-101-corsi-part-1-of-4-29d0a9fb1f95">here</a>, as the only difference in the calculation is that <strong>Fenwick does not include blocked shots</strong>.</p><h4>Team Fenwick</h4><p>Like Corsi, a team’s Fenwick is often measured as a percentage of the game total Fenwick. Therefore, a Fenwick For % (FF%) above 50% indicates that team had more unblocked shot attempts than their opponent.</p><h4>Player Fenwick</h4><p>Fenwick, and most other advanced stats, also apply to individual players. It simply compares FF% while a player is on the ice to FF% while the player is off the ice. For example, if Nathan MacKinnon has a good game and generates a lot of offense and is responsible in his own end, then his FF% <em>on</em> would be high, say 65%. If his team was dominated when he was off the ice, his FF% <em>off</em> would be low, say 40%. This would leave Mackinnon with a large FF% <em>rel</em> of 25%. These numbers would indicate he was a difference maker on the ice.</p><h3>Correlation between Fenwick and Corsi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*ZLIfWY-koi71RmgL09wYag.jpeg" /><figcaption>Pearson correlation between Fenwick and Corsi</figcaption></figure><p>As expected, FF% and CF% are strongly and positively correlated. In fact, the median values from the 2019–2020 shortened season were 49.8 and 49.9 for FF% and CF%, respectively. Interestingly, Nicolas Roy of the Golden Knights had the highest value of 61.4% in both categories. The biggest difference between metrics was 4.5%, observed in Nathan Gerbe of the Blue Jackets, who had a FF% of 50.2 and a CF% of 45.7%. Ultimately, these results suggest that Corsi and Fenwick are capturing the same information at the individual player level.</p><h4>Are blocked shots really that common/important?</h4><p>A quick look at the 2018–2019 season shows there was an average of ~100 shot attempts and ~15 shot blocks a game during the regular season. If shot blocks are evenly distributed between opposing teams, then there would not be a major difference between Corsi For % (CF%) and FF%. However, some players block far more than others, for example, defensemen like Mark Giordano and Chris Tanev. As a result, there are some instances where CF% and FF% tell two different stories.</p><h4>Why bother differentiating blocked shots?</h4><p>For some players, blocking shots is part of their defensive game, therefore it can be argued that blocked shots shouldn’t be rewarded as shot attempts, as they are in Corsi, since they are (sometimes) deliberately thwarted. A major criticism of Corsi is that it doesn’t discriminate between high and low quality shots and that the volume of shots doesn’t actually reflect offense and possession.</p><p>Since Fenwick considers shots that actually make it through the defense, it is sometimes thought as more stringent than Corsi but more lenient than shots on goal (SOG), in which hitting posts don’t count. However, a blocked shot doesn’t necessarily mean it was a poor scoring opportunity to begin with, so like Corsi, Fenwick also has its limitations.</p><h3>Does Fenwick or Corsi better predict team wins?</h3><p>We have discussed the theory behind Fenwick and Corsi, but the real test is which one provides more predictive value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*_r1p3o58AudsRytjkC-6hQ.jpeg" /><figcaption>2018–2019 data from IcyData</figcaption></figure><p>A simple linear regression of each variable reveals that both metrics are statistically significant, however, FF% is slightly more informative. This is also captured by the correlations in the scatter plot above that show FF% is more strongly correlated with points than CF%. It is also worth noting that the range for CF% is much narrower than FF% over the course of a full season. Over time, blocked shots begin to add up. Teams like the Senators, Kings and Devils likely had a higher fraction of their shots blocked while teams like the Lightning, Bruins and Flames blocked more shots.</p><h3>Conclusion</h3><p>Fenwick is measure of unblocked shot attempts. As expected, it is highly correlated with Corsi at the player level.</p><p>We’ve <a href="https://medium.com/hockey-stats/are-shot-attempts-and-shots-on-goal-meaningful-predictors-of-nhl-game-outcomes-not-really-f8f8d16811bf">previously</a> seen that on a game-by-game basis, Corsi is not particularly useful for predicting wins. In fact, a higher CF% for the home team actually predicts a loss. Here, we’ve shown that a higher Corsi over a full season does in fact correlate with more points, and that this relationship is actually stronger for Fenwick.</p><p>These results may sound contradictory, however, in this analysis, we considered all 82 games for each individual team. Previously, the game-by-game analysis was performed across all 31 teams together. As a result, we could make general statements about the <em>average</em> team. However, averages can be easily skewed by a subset of teams; recall, the medians were still close to 50% and there were still hundreds of games in which the team with CF% &lt; 50 lost and the team with CF% &gt; 50 won.</p><p>With that aside, if I had to pick one between Corsi and Fenwick, I would go with Fenwick. Let me know if you agree!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8796b8188d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hockey-stats/advanced-hockey-stats-101-fenwick-part-2-of-4-a8796b8188d">Advanced Hockey Stats 101: Fenwick (Part 2 of 4)</a> was originally published in <a href="https://medium.com/hockey-stats">Hockey Stats</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>