<?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[re-HOOP*PER-rate - Medium]]></title>
        <description><![CDATA[Random digressions in machine learning and basketball - Medium]]></description>
        <link>https://medium.com/re-hoop-per-rate?source=rss----6f5fff135e62---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>re-HOOP*PER-rate - Medium</title>
            <link>https://medium.com/re-hoop-per-rate?source=rss----6f5fff135e62---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:40:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/re-hoop-per-rate" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[NBA Neural Networks: Quantifying Playoff Performance by Number of Games Won and Seeding]]></title>
            <link>https://medium.com/re-hoop-per-rate/nba-neural-networks-quantifying-playoff-performance-by-number-of-games-won-and-seeding-9b8e9d2f6a55?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/9b8e9d2f6a55</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[nba]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Fri, 21 Aug 2020 00:47:42 GMT</pubDate>
            <atom:updated>2020-08-21T18:59:59.171Z</atom:updated>
            <content:encoded><![CDATA[<p>In my <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">NCAA postseason March Madness neural networks</a>, I use a metric known as “Wins Above Seeding” to determine how well a team will perform relative to its position within the playoff bracket. At its core, the “Wins Above Seeding” is a valuation metric that determine whether a team is over-valued or under-valued relative to their position within the bracket. It was inspired by the Warren Buffet / Benjamin Graham value investing approach that is constantly on the lookout for undervalued equities to invest in and overvalued equities to avoid. In this case, the neural network is trained using previous seasons’ team statistics and “Wins Above Seeding” value data. Based on the patterns found by the neural network, the teams for the current season’s NCAA postseason are evaluated.</p><p>I’ve always wanted to adapt this approach to the NBA postseason, but there’s an extra complication there: unlike the single elimination NCAA March Madness, the NBA playoffs consist of 4 rounds of best of 7 series. In other words, an effective NBA playoff prediction tool must tell us not only which teams will win and advance, but also how many games the team will play before advancing. This is information that isn’t captured by a simple “Wins Above Seeding” metric. In fact, compared to the wild upsets in March Madness, the 7 game series format insures that upsets rarely occur in the NBA playoffs. Instead, participants in bracket challenges like the <a href="https://picks.nba.com/bracket-challenge">NBA Pick ’Em Bracket Challenge</a> gain points on the competition by predicting the exact number of games in a series (i.e. how many games are played before one of the teams reaches 4 wins). Instead of “Wins Above Seeding”, my neural network approach would require a new metric that captures both which teams advance, and how many games that team takes to advance — all while accounting for the team’s 1-through-8 playoff seeding.</p><p>After playing around with the numbers, I found a relatively good way to quantify this seeding adjusted NBA playoff performance using the number of games a team wins in the postseason. After all, the number of games a team wins is a direct reflection of how far a team advances — a team that advances past the first round wins at least 4 games, a team that advances past the second round into the conference finals wins at least 8 games, and so on until a champion is crowned after winning 16 games. As legendary Phildaelphia 76er Moses Malone once put it, winning an NBA championship comes down to <a href="https://www.youtube.com/watch?v=YCtyxtGYWVA">“Fo’, Fo’, Fo’, Fo’”</a>. My new metric, which I call LOgarithmic Victories-Scaled-Seed (LOVSS), is defined by:</p><p>LOVSS=floor(log-base 2 (number_of_wins * (seed+1)))</p><p>where number_of_wins is the number of games the team wins in the postseason, seed is the team’s seeding within its conference between 1 and 8 (where 1 is the best regular season team and 8 is the worst), and the floor operation returns the highest integer value less than or equal to the result of the log base 2 operation. One interesting wrinkle here is adding 1 to a team’s seed before multiplying by the number of wins to calculate the LOVSS. I did this to achieve a nice symmetry: an 8 seed that upsets a 1 seed in the first round but doesn’t win any more games will have a LOVSS of:</p><p>LOVSS=floor(log(4*(8+1)))=floor(5.17)=5</p><p>while a 1 seed that wins the championship will have a LOVSS of:</p><p>LOVSS=floor(log(16*(1+1)))=floor(5)=5.</p><p>I used a Python scraping script to get historical data on LOVSS for every NBA playoff team from the 2013 to 2019 seasons (ignoring the lockout shortened 2012 season and all the seasons before it). I also leveraged the data from my previous <a href="http://scraped%20data%20related%20to%20each%20team%E2%80%99s%20season%20average%20Three%20Point%20Percentage,%20Two%20Point%20Percentage,%20and%20Rebounds%20/Assists%20/Steals%20/%20Blocks%20/Turnovers%20/%20Points%20per%20100%20minutes%20of%20play">NBA restart training dataset</a> (which includes each team’s season average ranking relative to the rest of the league in Three Point Percentage, Two Point Percentage, and Rebounds /Assists /Steals / Blocks /Turnovers / Points per 100 possessions). The result looked something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NVVGRKLiz41FSd4u.png" /><figcaption>historical LOVSS data for playoff teams</figcaption></figure><p>To understand the above data, Miami won the championship in 2013 (a LOVSS of 5 for LeBron and Dwyane Wade’s first seeded Heat team), while being 2nd in the league for three point percentage, 1st in two point percentage, 16th in free throw percentage, and so on and so forth. Meanwhile, their first round opponent, the Milwaukee Bucks, have a LOVSS of 0, having won no games at all that postseason.</p><p>After that, I grabbed data the same per 100 possessions data for the playoff teams this season. I trained a neural network with 3 hidden layers in Keras using the historical playoff data (that’s very similar to my March Madness Neural Network MadNet):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/0*9WxYJEuO2aRPoz-_.png" /><figcaption>Neural Network with 3 hidden layers and Dropout</figcaption></figure><p>using a softmax activation layer (note I had to convert all of the LOVSS data to a onehot representation before I did this) and adding regularization and dropout after each layer to prevent overfitting. I found the “elbow” of the training curve after around 128 epochs of training:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/0*oqxJRX8QTKCuSEpO.png" /><figcaption>Training accuracy of the neural network</figcaption></figure><p>so that’s what I used to obtain my results. I ended up training the neural network over 20 times on this data, and using each of these neural networks to calculate a LOVSS score based on 2020 NBA data. Initially, I used data that didn’t include stats from the bubble restart, since 1) I had that data handy from my <a href="https://medium.com/re-hoop-per-rate/applying-march-madness-neural-networks-to-the-nba-bubble-restart-922aa50cf13">previous NBA neural network</a> and 2) I wanted to see how that compared to the results when NBA restart stats are included, to see which teams gained momentum from playing in the NBA bubble.</p><p>To identify how well a team would do after the restart, I used the average LOVSS value predicted by the neural networks and reversed the equation shown above (i.e. instead of taking a logarithm, I calculated 2^LOVSS and then calculated the number of games won). I also took into account historical data regarding how a NBA playoff series between 2 teams with specific seedings and LOVSS metrics evolved. Here’s the bracket based on the LOVSS predictions based on the pre-bubble NBA stats:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rrWof8Y8t_x-v88u.png" /><figcaption>Neural Network generated NBA Playoff bracket based on pre-bubble data</figcaption></figure><p>As we can see, the neural network is hype on the Bucks — as everyone was before the bubble started. As for the Lakers, even before their restart bubble woes the neural network didn’t particularly like their team profile. The neural network didn’t particularly like the Raptors or Sixers either, and expected Denver to give the Clippers a really competitive second round series out in the West.</p><p>Now let’s see how using data that included stats from the NBA restart bubble would shake things up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QZLNGNicO-d522Ah.png" /><figcaption>Neural Network generated bracket with NBA Bubble data</figcaption></figure><p>Well, that certainly changed things! The Bucks’ bubble troubles have them losing to the surging Heat in the second round, en route to their first Finals appearance since the LeBron era. Meanwhile, the Clippers are now expected to make it out of the West and win the championship with relative ease. The Lakers are now expected to be pushed to the brink by the Blazers in the first round (before eventually defeating them in a close game 7 — a likely scenario given the NBA refs’ noted favoritism towards both LeBron and the Lakers) before again succumbing to the Rockets in the second round. This bracket is really interesting and actually conforms with what I’ve been seeing with the “eye test” watching games during the restart. In particular, it has the Heat making an upset run, a real possibility given <a href="https://www.youtube.com/watch?v=XondELei52Y">Bam Adebayo’s emergence as a cerebral big man who always seems to make the right play</a> and <a href="https://www.youtube.com/watch?v=KgqDyQB-W9w">Duncan Robinson’s emergence as the fastest-trigger 3 point shooter in the league</a> (yes, his release looks like it may be faster than Steph Curry’s, though he obviously doesn’t have Steph’s unstoppable versatility). That’s before we talk about veteran stars like Jimmy Butler, Goran Dragic and Andre Igoudala who round out the Heat roster. Meanwhile, if any team can counter all of the perimeter weapons offensive-minded teams like the Heat or the Rockets can throw out there, it’s a Clippers team stacked on the wings with versatile defenders like Patrick Beverley, Kawhi Leonard, and Paul George (and oh yeah, Kawhi and Paul George are pretty much unstoppable on offense also). In short, I really like how this bracket plays out!</p><p>Out of pure curiosity, I adjusted this bubble restart bracket based on a “momentum factor” in which I took the difference between each team’s post-bubble LOVSS score and their pre-bubble LOVSS score, and added it to their post-bubble LOVSS score. The main difference in that bracket is that it now has the surging Blazers upsetting the Lakers before pushing the Rockets to a game 7, and now has a scorching hot Heat team upsetting the inconsistent Bucks in just 4 games.</p><p>Given the tedium of quarantine, I’m incredibly glad the NBA playoffs are there to keep me sane. Here’s hoping the playoffs evolve exactly like my predictions — after all, there’s a 1 in ~35 trillion chance I’ll get every pick right and win the NBA’s million dollar grand prize!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b8e9d2f6a55" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/nba-neural-networks-quantifying-playoff-performance-by-number-of-games-won-and-seeding-9b8e9d2f6a55">NBA Neural Networks: Quantifying Playoff Performance by Number of Games Won and Seeding</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Applying March Madness Neural Networks to the NBA Bubble Restart]]></title>
            <link>https://medium.com/re-hoop-per-rate/applying-march-madness-neural-networks-to-the-nba-bubble-restart-922aa50cf13?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/922aa50cf13</guid>
            <category><![CDATA[nba]]></category>
            <category><![CDATA[basketball-analytics]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Tue, 28 Jul 2020 10:45:04 GMT</pubDate>
            <atom:updated>2020-07-28T10:45:04.509Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*iRY_rSS99izEJuhA.jpg" /></figure><p>Those of you who have been following this blog for a while know about my <a href="https://medium.com/re-hoop-per-rate/new-and-improved-march-madness-neural-network-for-2020-c154aa1041b7">March Madness neural network MadNet</a> and the <a href="https://medium.com/re-hoop-per-rate/insights-from-metanet-the-march-madness-neural-network-for-bet-sizing-c04bfffb695d">complimentary “bet sizing” neural network MetaNet</a>. Unfortunately, I wasn’t able to put these neural networks to use this year since the college basketball March Madness tournament was cancelled due to the CovId pandemic. But with the NBA restart on the horizon, I decided to try applying these neural networks to the first few games of the NBA season restart in the Orlando “bubble”.</p><p>Unlike the March Madness neural networks, which use a “Wins Above Seeding” metric to determine how well a team would perform, for the NBA season restart I used a Python script to scrape data from <a href="https://www.basketball-reference.com/">Sports Reference</a> on how well a team performs during the first 4 games of the season. This “First Games Won”, or FGW, would serve as a good proxy for how well a given team performs after an extended break (like the one the NBA just experienced). Given the awkward linear way these game results are listed on Sports Reference, it took a tricky bit of hash table magic in Python to scrape this data. Next, I scraped data related to each team’s season average Three Point Percentage, Two Point Percentage, and Rebounds /Assists /Steals / Blocks /Turnovers / Points per 100 minutes of play. The idea here is that teams with certain “profiles” perform better at the start of a season, after an extended break. I trained the neural network on this data to predict the FGW score of each team in the current season based on the stats that make up the team’s “profile”. My dataset included every NBA team from the 2012–2013 season to the 2018–2019 season (ignoring the lockout shortened 2011–2012 season that might have skewed the data, as well as all seasons prior to it).</p><p>I then scraped the same data for the 2020 season, and used both MadNet and MetaNet to predict each team’s performance. Since there were no trades from the time the NBA shut down in March to now, I expect most teams to maintain the same general “profile” at this time (with the exception of injuries and players who have chosen to sit out). Given the smaller dataset, I played with the number of <a href="https://medium.com/fintechexplained/what-are-hidden-layers-4f54f7328263">hidden layers</a> in both models, and was able to use fewer nodes while getting good results.</p><p>I trained 10 MadNet neural networks and 10 MetaNet neural networks each, and averaged the results. MadNet particularly liked the Spurs, giving them a FGW score of 4, followed by the Lakers, Celtics, Pelicans (who now have Zion Williamson joining a team that’s already expected to do well after a long break), and Magic (who may already have some homecourt advantage given how they don’t need to adjust to the humidity in Orlando). MadNet also disliked the Raptors (a top team that may be in for a rough restart), Wizards (who are already depleted without Bradley Beal), Grizzlies, and Bucks (another top team that may be in for a rough restart, especially since their first game back will be against the high FGW Celtics, and their starting point guard and third best player Eric Bledsoe has only recently recovered from Coronavirus).</p><p>Meanwhile, MetaNet also liked the Spurs the most, followed by the Rockets, Mavs, Lakers and Suns. With both MetaNet and MadNet signaling that the Spurs could have a great restart, it’s a real shame that their star player LaMarcus Aldridge is out for the season — otherwise they would have made for a great underrated bet! MetaNet didn’t like the Nets (who have already been decimated to the point of offering minutes to 40 year old Jamal Crawford!), Raptors (there they are in the poor restarting teams list again!), Bucks (also showing up among the poor restart teams again!), and Wizards.</p><p>After using an algorithmic approach to combine the results from MadNet and MetaNet, and adding in an adjustment factor based on which players are missing and the Vegas odds, here are my picks for the first two days of games after the restart (note that I’m not recommending you gamble here, nor am I qualified to give any advice — I’m simply pointing out what the data indicates when taken in conjunction with bookmaker odds):</p><p>Pelicans (-130) over Jazz — Both MadNet and MetaNet really like the Pelicans — and that’s BEFORE accounting for the force of nature that is Zion Williamson. Meanwhile, the Jazz will be missing their best perimeter threat, Bojan Bogdanovic.</p><p>Celtics (+170) over Bucks — Both MadNet and MetaNet felt the Bucks would have a slow start, plus Eric Bledsoe might be feeling the effects of his recent bout with CovId. Meanwhile, Boston has their full roster showing up in Orlando. I would actually go big on both the moneyline and the spread (Boston +5.0) in this one.</p><p>Magic (-230) over Nets — Vegas has a huge hold on this game, but the data favors the Magic in every conceivable dimension, and the Nets are beyond shorthanded at this point. This feels a bit like betting on Floyd Mayweather in his fight with Conor MacGregor — easy but boring.</p><p>Suns (N/A) over Wizards— MetaNet likes the Suns and absolutely hates the Wizards. That being said, the moneyline on the Suns (-290) is so skewed that my algorithm doesn’t recommend this one — even though it’s convinced the Suns will win.</p><p>Spurs (+130) over Kings — MadNet and MetaNet both love the Spurs teams’ profile more than any other, but major caveat, that’s with mid-range maestro LaMarcus Aldridge on the roster. Even with LaMarcus gone though, this is still a Spurs team that: 1) the data REALLY likes (2x more than it likes any other team), 2) is coached by the brilliant and always on top of things Greg Popovich, and 3) is going up against a young Kings team with 4 players who recently tested positive for CovId. Definitely worth taking a chance on the Spurs in this one — and they may even be worth a bet on the spread!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N2j-NWav6E3IdRnV.JPG" /><figcaption>Never a good idea to bet against this man [image source: Wikipedia]</figcaption></figure><p>Heat (+115) over Nuggets — While the data doesn’t absolutely love the Nuggets, MetaNet is especially high on a Heat team that isn’t missing a single player, is playing close to home in Florida, and is led by the mentally tough and borderline insane Jimmy Butler. The Heat definitely won’t make this one easy for the Nuggets. The only reservation I have about this game is Denver’s Michael Porter Jr becoming a potential X-factor with more minutes off the bench — this one seems like a small flyer bet on the Heat to me.</p><p>Lakers (-170) over Raptors — Another game that deserves only a small flyer bet. Both neural networks didn’t particularly like the Raptors’ chances, and both neural networks ranked the Lakers among their top 5 teams. My reservation comes from the Lakers missing both starting point guard Avery Bradley and backup point guard Rajon Rondo — meaning the only “true point guard” who can chase opposing guards on defense is the rather limited Alex Caruso. The Raptors, with their deep roster of speedy guards (Kyle Lowry, Fred vanVleet) seem especially well suited to make life for the Lakers difficult as they adjust to less defense on the perimeter. The absence of Dwight Howard will be more sorely felt than people expect also — the Lakers may be forced to play Markieff Morris at center for some significant minutes, giving the Raptors’ ever-shifting lineups free rein to attack the rim. All of that being said, the data still really hates the Raptors, so they may be worth a small flyer bet out of principle.</p><p>TLDR: My neural networks say Pelicans over the Jazz, Celtics over Bucks and Spurs over Kings are great values, also likes the Magic over the Nets in spite of the awful odds, and thinks Heat over Nuggets and Lakers over Raptors is worth a small flyer.</p><p>Perhaps most importantly, after months and months without basketball, I can’t wait to start watching the NBA restart — even if it’s basketball in a bubble!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*7Ch2kJWJbYrSVpjB" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=922aa50cf13" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/applying-march-madness-neural-networks-to-the-nba-bubble-restart-922aa50cf13">Applying March Madness Neural Networks to the NBA Bubble Restart</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Insights from MetaNet, the March Madness Neural Network for Bet Sizing]]></title>
            <link>https://medium.com/re-hoop-per-rate/insights-from-metanet-the-march-madness-neural-network-for-bet-sizing-c04bfffb695d?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/c04bfffb695d</guid>
            <category><![CDATA[neural-network-algorithm]]></category>
            <category><![CDATA[march-madness]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[march-madness-bracket]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Mon, 02 Mar 2020 05:20:04 GMT</pubDate>
            <atom:updated>2020-03-02T05:20:04.621Z</atom:updated>
            <content:encoded><![CDATA[<p>Like I did for the <a href="https://medium.com/re-hoop-per-rate/using-genetic-algorithms-to-gain-insights-from-madnet-the-multi-class-classification-neural-a4af9d240a49">MadNet</a> and <a href="https://medium.com/re-hoop-per-rate/experimenting-to-gain-insights-from-boxnet-the-convolutional-neural-network-for-march-madness-77d449c08c2c">BoxNet</a> neural networks, I also used <a href="https://medium.com/re-hoop-per-rate/march-madness-neural-network-specifically-for-bet-sizing-fe7bee244682">MetaNet, the March Madness meta-labeling neural network</a> to experiment with randomly generated basketball dasta. In this case, just like for MadNet, I used randomly generated values for the advanced stats data that I’ve been using since my first <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">March Madness Neural Network</a>. Check out that blog post to learn about how I use these neural networks to predict a college basketball team’s “Wins Above Seeding” value (which can also take on negative values when a team underperforms relative to its seed).</p><p>First I took the existing data and changed the output to be 1 for teams with Wins Above Seeding greater than 4(corresponding to a team that goes on a really good run — a team seeded lower than 4 winning it all!).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*xU9gzz8th5X9YlA75FbIJw.png" /></figure><p>Then I trained the same MetaNet neural network:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*aeRmfPRaF66bQ6W7v6FXyg.png" /></figure><p>and used this neural network to predict the results of 500 different randomly generated team profiles:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*xcHUYvA9lBbIpAXdPBQW-g.png" /></figure><p>The resulting array, which I named “winners”, had 6 entries, with the below values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*GLUhwvr3b_oJmYxJ_vsD6w.png" /></figure><p>To figure out what stat category each array field corresponds to, you’ll need to see how I structured the data in my description of my <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">original March Madness neural network</a>. When I cross-referenced this data, one thing that really stood out is how these teams don’t all have a great win-loss record (in fact only one team has a win-loss greater than the 90th percentile), but they all have very good strength of schedules (all above roughly the 80th percentile). In addition, the teams all have a pace below the 50th percentile, a necessity for teams trying to pull off an upset since by limiting the number of possessions they give the other team less chances to run away with the game. In addition, all of these teams have a Free Throw Rate (the ratio of free throws attempted to field goals attempted) greater than the 50th percentile, and a Three Point Attempt rate greater than the 60th percentile. If you want to go on a run, it seems like you need to take threes and get to the line — an approach that’s very familiar for James Harden and the Houston Rockets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/0*8GMMZc9gfZhApyaL.jpg" /><figcaption>James Harden shooting a three pointer <a href="https://commons.wikimedia.org/wiki/File:James_Harden_(30852408515).jpg">https://commons.wikimedia.org/wiki/File:James_Harden_(30852408515).jpg</a></figcaption></figure><p>I also ran 1,000 trials with randomly generated teams on a neural network trained to find underperforming teams with a WAS below -2. The 5 teams with a WAS this low are shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*jxSHZX7C5xcMj0Hg8S1Lqw.png" /></figure><p>We can see that these underperforming teams all tend to have a relatively low block rate and low steal rate, as well as a very low rebounding rate. It’s interesting that so many of these insights gleaned from March Madness machine learning show what kind of teams tend to get upset in March: those with a <a href="https://medium.com/re-hoop-per-rate/march-madness-post-mortem-and-why-sharing-the-ball-isnt-always-good-afcf7e0dd21d">very high assist rate</a>, a very <a href="https://medium.com/re-hoop-per-rate/using-genetic-algorithms-to-gain-insights-from-madnet-the-multi-class-classification-neural-a4af9d240a49">low Free Throw attempt rate</a>, and poor block rate and rebounding rate. Looking through this year’s likely high seed March Madness teams on <a href="https://www.sports-reference.com/cbb/seasons/2020-advanced-school-stats.html">Sports Reference</a>, Creighton and Villanova both have very low block and rebounding rates, top 20 percentile assist rates. Villanova also suffers from the extra whammy of having a very low Free Throw attempt rate, making them a great under the radar upset candidate once the tourney starts!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*Zfkx44Pg_iCFeTo8.jpg" /><figcaption>Blocked shot, something March Madness teams that get upset don’t do very well</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c04bfffb695d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/insights-from-metanet-the-march-madness-neural-network-for-bet-sizing-c04bfffb695d">Insights from MetaNet, the March Madness Neural Network for Bet Sizing</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Experimenting to Gain Insights from BoxNet, the convolutional neural network for March Madness]]></title>
            <link>https://medium.com/re-hoop-per-rate/experimenting-to-gain-insights-from-boxnet-the-convolutional-neural-network-for-march-madness-77d449c08c2c?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/77d449c08c2c</guid>
            <category><![CDATA[march-madness]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[march-madness-bracket]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Sun, 01 Mar 2020 23:45:00 GMT</pubDate>
            <atom:updated>2020-03-01T23:45:00.112Z</atom:updated>
            <content:encoded><![CDATA[<p>Previously, I wrote about using <a href="https://medium.com/re-hoop-per-rate/using-genetic-algorithms-to-gain-insights-from-madnet-the-multi-class-classification-neural-a4af9d240a49">Genetic Algorithms</a> with the multi-class classification neural network <a href="https://medium.com/re-hoop-per-rate/new-and-improved-march-madness-neural-network-for-2020-c154aa1041b7">MadNet</a> to glean insights about what kind of teams perform well in March Madness. Now let’s do the same with <a href="https://medium.com/re-hoop-per-rate/convolutional-neural-network-for-march-madness-197def57f94f">BoxNet, the convolutional neural network </a>that I applied to the average “box scores” showing the average points per game, rebounds per game, steals per game, blocks per game and turnovers per game for each player on the team. Essentially, my BoxNet code treats this data as a “picture” and finds patterns within that picture — some patterns correspond to overperformance relative to a team’s seed and some patterns correspond to underperformance relative to the team’s seed. For more on how I use a “Wins Above Seeding” metric to indicate how well a team will do in March, take a look at my <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">original March Madness neural network blog post</a>.</p><p>Once I had a BoxNet convolutional neural network trained on the historical data, I used a random algorithm to generate “box scores” with randomly generated data on each player’s average stats. Then I normalized those box scores (as I do with the original BoxNet data) and ran the teams through BoxNet, taking either the best performing teams or the worst performing ones. Note that I didn’t bother using a genetic algorithm this time, since basketball box scores are so complex that the new box score “chromosomes” that are bred from existing box scores don’t necessarily correspond to better performance. In addition, note that since the data is randomly generated, certain teams may have deeply unrealistic statistical profiles. I decided it would be too difficult to add “realism constraints” to the randomly generated box score profiles, so I went ahead with full randomization for these experiments.</p><p>Out of 1000 randomly generated team profiles, only 2 had a Wins Above Seeding greater than 2. The first overperforming team had a dominant forward or big man who leads the team in both points and rebounds, maintains a below average turnover rate, and has a fair share of passing duties as well. The team also has a dominant guard who leads in assists and steals while scoring almost as much as the big man, while maintaining a low turnover rate and taking care of some rebounding duties. The team also has 2 more scoring contributors who are above average defensively, similar to the “three-and-D” wings we see in real life. This profile seems to fit a classic dominant basketball team with talent all around, and some of the best examples of this prototype include National Champion Duke in 2015 (with Jahlil Okafor as the dominant big, Tyus Jones as the star point guard, and Grayson Allen, Matt Jones, and Justise Winslow as the wings), or National Champion Kentucky in 2012 (with Anthony Davis as the dominant big man, Marquis Teague at point guard and players like Doron Lamb and Terrence Jones filling out the wings).</p><p>Another prototypical dominant / overperforming team features an all around player who efficiently gets lots of rebounds and assists (a Draymond Green / Denzel Valentine type that seems to be common at Michigan State), a do-it all guard who scores, rebounds and passes well but suffers from being turnover prone, 2 supporting scoring guards who also defend well (those three-and-D wings again). All the players on this type of team pass at greater than 50% relative to the team’s best passer, indicating that there is no dominant ball handler and lots of versatility across the board. Examples of National Championship teams with a profile like this include UConn in 2014 (with Shabazz Napier as the do-it-all guard and Ryan Boatright as the do-it-all forward in the Draymond Green mold), Villanova in 2018 (with Mikal Bridges as the versatile forward and lots of guards who could shoot and pass), and to a lesser extent UVA in 2019 (with DeAndre Hunter playing the versatile forward role, Ty Jerome playing the do-it-all guard role and Kyle Guy single-handedly playing the role of multiple scoring guards with his accurate high-volume shooting).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*mZ8HSbsAnYHCfj-_.jpg" /></figure><p>Source: <a href="https://commons.wikimedia.org/wiki/File:20170213_Villanova-Depaul_Mikal_Bridges_dunk.jpg">https://commons.wikimedia.org/wiki/File:20170213_Villanova-Depaul_Mikal_Bridges_dunk.jpg</a></p><p>I did the same thing with teams that underperform relative to their seed, and out of 1000 randomly generated teams, 3 of them had a Win Above Seeding of less than -2 (corresponding to a first or second seed being upset in the first round). What are these teams that are so easily upsettable like? The first team had a player leading in scoring and rebounding while also having a very low (far below the team’s best passing player) assist rate. This team also had a leading assist player who was very turnover prone. To some extent, this corresponds to college basketball teams with a single traditional “back to the basket” big man. Teams like this have a history of underperforming in March Madness (neither Shaq nor Tim Duncan ever made it past the second round of the tourney). A more recent team that fits this profile is UVA in 2018, a team on which Isaiah Wilkins grabbed many rebounds while doing very little passing, and on which Ty Jerome had a very poor assist to turnover ratio (3.9 assists per game versus 5.5 assists per game the next season, with a 3.9:1.6 assist-to-turnover ratio).</p><p>The next under-performing team profile had a leading scorer who was also a leading rebounder but who rarely passes the ball, a second top scorer who doesn’t rebound much or get many assists, and no other standout players. Again, we see that teams relying too heavily on a traditional low post big man don’t do well in March. The closest prototype for this team may be the second seeded Georgetown team that was upset by Florida Gulf Coast University in 2013. That team featured a big in Otto Porter who wasn’t much of a passer in spite of the team’s high assist rate, and the team’s second leading rebounder Markel Starks barely rebounded.</p><p>The last under-performing team profile had a top scorer and rebounder who was very turnover prone (again indicative of a traditional big man and even sounding like DeAndre Ayton, whose fourth seeded Arizona Wildcats were upset by Buffalo in the first round in 2018). On the rest of the team, no single player doing significantly more than all of his teammates in points, steals, rebounds blocks and assists. Meanwhile, all of the players are very turnover prone. This team looks a lot like the second seeded Duke team that lost to CJ McCollum and Lehigh back in 2012: lots of scorers with no clear cut go-to player and a high turnover rate among every member of the team.</p><p>It seems like if there’s one thing that’s consistent across the five team box score profiles that significantly under or over-performed in March, it’s that versatility is important. The best teams have big men who can pass, and guards who can rebound. On the other hand, teams that get upset have big men who can only score and grab boards, and guards who can only shoot but don’t pass (or are very turnover prone when they do pass). When it comes to March Madness, versatility truly is the key to a deep run through the tourney.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77d449c08c2c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/experimenting-to-gain-insights-from-boxnet-the-convolutional-neural-network-for-march-madness-77d449c08c2c">Experimenting to Gain Insights from BoxNet, the convolutional neural network for March Madness</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convolutional Neural Network for March Madness]]></title>
            <link>https://medium.com/re-hoop-per-rate/convolutional-neural-network-for-march-madness-197def57f94f?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/197def57f94f</guid>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[march-madness]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[march-madness-bracket]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 06:40:07 GMT</pubDate>
            <atom:updated>2020-02-09T06:40:07.699Z</atom:updated>
            <content:encoded><![CDATA[<p>In my recent article on updating my <a href="https://medium.com/re-hoop-per-rate/new-and-improved-march-madness-neural-network-for-2020-c154aa1041b7">March Madness neural network in anticipation for the 2020 college basketball tournament</a>, I mentioned some new approaches that I will be using to fill out my bracket this year. One of these is <a href="https://medium.com/re-hoop-per-rate/march-madness-neural-network-specifically-for-bet-sizing-fe7bee244682">MetaNet</a>, which I’m primarily using to determine bet sizing on specific NCAA tournament games. In this article, I’ll be discussing a convolutional neural network that I’m using for picking March Madness upsets. I’m calling this neural network “BoxNet”.</p><p>Why BoxNet? Because it’s using the much maligned box score. In our current era of advanced analytics, the box score seems like a quant and antiquated call-back to a bygone era. Daryl Morey, Houston Rockets manager and rock star of the analytics revolution, even went so far as to suggest that whoever <a href="https://redef.com/item/54b05f4852d348d925df3386">first invented the box score should be shot</a>. As an obvious fan of sports analytics, I was inclined to agree, until I read something interesting last summer that made me think perhaps the box score could still be of use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/0*5jMIwwubpj6jwljf" /><figcaption>Example of a college basketball box score in the middle column</figcaption></figure><p>In the book <a href="https://www.amazon.com/Deep-Learning-Game-Max-Pumperla/dp/1617295329">Deep Learning and the Game of Go</a>, the creators of <a href="https://deepmind.com/research/case-studies/alphago-the-story-so-far">Google’s AlphaGo computer program</a> mentioned that one of the ways they trained their neural network was by encoding the state of a Go board as an image. They then used the next move made by an expert human Go player to train the computer on what the next move should be. In short, they encoded each state of a Go board over the course of the game as separate images. They then trained a <a href="https://en.wikipedia.org/wiki/Convolutional_neural_network">convolutional neural network</a>, which are ideally suited to machine learning for image applications (such as in applications like text recognition or self driving cars), to predict what the next move should be given the current state of the board.</p><p>Of course, when I read about how AlphaGo was encoding the state of Go boards like they were images, I immediately thought about what other data could be encoded into a regular grid-like image. Being the college basketball fan that I am, my mind naturally gravitated to the basketball box score. In short, I started wondering if certain ratios between box score totals corresponded to teams performing better or worse during March Madness. Is it better for a team to have a single dominant scorer, two (or three) primary scorers, or for the scoring load to be distributed evenly among all the players? Likewise for rebounding: is it better for a team to have a single incredible player down low who specializes in cleaning up the glass, or is it better to have a more balanced ratio of rebounding among different players? And what about the complicated relationships that are possible between these ratios? Add in the ratios of the player who leads in steals per game to the second, third, fourth best players in steals per game, likewise for the ratio of assists, blocked shots, and turnovers, and suddenly there’s a complex relationship that defies mere human consideration.</p><p>That’s where the convolutional neural network can come in! Start by normalizing each box score category (points, rebounds, assists, steals, blocks, and turnovers per game) to the team leader in that category (i.e. divide each player’s points per game by the player with the most points per game, likewise for rebounds, assists, etc.). What you have left is a table of normalized statistics for each statistical category — a table that looks a lot like an image. And since convolutional neural networks (abbreviated with the acronym CNN) are used to find patterns within an image, I could use a CNN to identify patterns in the ratios between different players in a box score. I could train this CNN using these normalized box scores of past March Madness teams, and the over or underperformance relative to seeding of those past teams (as explained in my first ever blog post on <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">March Madness neural networks</a>). Whatever patterns the CNN found in the box score could then be used to identify teams with similar box score patterns in March Madness teams this year, and tell us whether those teams are expected to over or underperform their seed. With box scores featuring so prominently in this neural network, it’s only natural that I decided to name it “BoxNet”.</p><p>After browsing through a few teams’ box scores on <a href="https://www.sports-reference.com/cbb/seasons/">Sports Reference’s college basketball page</a>, I noticed that most teams have a huge drop off in their players’ playing time, scoring, and other statistics after the eighth player or so. It seems like the “core rotation” for most college basketball teams is 8 players, so I limited my box score data sets to the eight highest scoring players. I read in the list of previous teams (both the school name and the year) from my <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">existing college basketball data set</a>, and used the Python code below to scrape this box score data and normalized it within each statistical category:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*7p_ww-cRuapB4hg5" /><figcaption>Scraping the data</figcaption></figure><p>One thing to note is that certain teams on Sports Reference had different names in their URL compared to how they are listed (for example, “Louisiana” becomes “Louisiana-Lafayette” in the URL), and some of the code above is to take care of these contingencies. I parsed through the data stats to get the relevant information and stored it all into a list which I called train_list, which I would later reshape into an array.</p><p>Now it was time to assemble the Convolutional Neural Network using Keras. Since my data was in an 8x6 format, I used a single convolution layer with 2x2 kernal size, followed by a 2x2 max pooling layer, which I thought could reveal relationships between more detailed box score patterns. I then used two dense activation layers, one with ReLu activation and the next with softmax activation, to arrive at the final performance above or below seeding result. Note that as in previous <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">March Madness neural networks</a>, I already shifted the seed over or underperformance from a range of -4 to +6 to a range from 0 to 11.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/0*uARX4rQEZWl6cVH7" /><figcaption>Building the March Madness Convolutional Neural Network</figcaption></figure><p>After 1024 training steps, the resulting model performed with almost 98% accuracy on box scores of March Madness teams from 2010 to 2019:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pp1Dz4CCfm1XbwVF" /><figcaption>Validation accuracy of BoxNet</figcaption></figure><p>with overfitting occuring after around 500 steps, at which time the accuracy was leveling off in the high 90-something percentile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SETwZEHPm8SvK0wW" /><figcaption>BoxNet overfits after ~500 steps</figcaption></figure><p>It seems like there’s some real predictive power behind BoxNet, and there might be some interesting things we can learn about the ideal March Madness team profiles by using genetic algorithms with randomly generated box score data that’s applied to BoxNet. I’ll cover that in a later article!</p><p>In the meantime, I wanted to run one more test: in addition to the six box score fields I’m currently using, I wanted to add shooting percentage data (three point percentage, two point percentage, and free throw percentage). Most likely, teams that had many players shooting a high percentage on all three would probably do better than teams that didn’t, but I still thought training a network with this additional data might give additional insight (or at least, might give more hints on how to fill out a bracket!). I called this neural network “BoxShotNet” (since it uses the same box score as before but now includes data on shooting percentages). Trying this neural network out with our current dataset, we saw similar results with the validation accuracy reaching close to 99%, but the network does start to overfit earlier as we would expect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ji2xTCG3azz_xUZn" /><figcaption>BoxShotNet overfits after ~256 steps</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=197def57f94f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/convolutional-neural-network-for-march-madness-197def57f94f">Convolutional Neural Network for March Madness</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[March Madness Neural Network specifically for Bet Sizing]]></title>
            <link>https://medium.com/re-hoop-per-rate/march-madness-neural-network-specifically-for-bet-sizing-fe7bee244682?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/fe7bee244682</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gambling]]></category>
            <category><![CDATA[march-madness]]></category>
            <category><![CDATA[sports-betting]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 10:56:54 GMT</pubDate>
            <atom:updated>2020-01-27T10:56:54.074Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first created a <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">neural network for March Madness predictions back in 2018</a>, I treated it as a two class classification problem that resulted in a bracket with none of the Final Four picks correct (though it did correctly predict some huge upsets, like Buffalo over Arizona and Nevada over Cincinnati). At the same time, I also created a multiclass classification neural network which at least correctly predicted that third seeded Michigan would make the Final Four and Championship Game (though it missed all of its other Final Four picks). As a result, when it came time to <a href="https://medium.com/re-hoop-per-rate/new-and-improved-march-madness-neural-network-for-2020-c154aa1041b7">re-work my original neural network in Keras with updated and cleaned up data</a>, I decided to use a multiclass classification with ReLU activation.</p><p>However, my binary classification algorithm in TensorFlow was very effective at picking early round upsets, giving me very strong indications of a 13–4 upsets in both 2018 and 2019. In particular, running a binary classification algorithm multiple times can gives me clear statistics on how “strongly” the neural network thinks a given team can pull off an upset, as well as how likely a team is to be upset. Simply look at the teams that consistently show up with a high WAS, and see when they match up with teams that consistently show up with a low WAS. Taking the lower seeded teams average WAS and subtracting the higher seeded team’s average WAS even gives a numerical value corresponding to how much “confidence” to put into the given upset occurring.</p><p>In fact, this binary classification neural network came back to me recently as I was reading <a href="https://www.orie.cornell.edu/faculty-directory/marcos-lopez-de-prado">Dr. Marcos Lopez de Prado’s</a> excellent book, <a href="https://www.amazon.com/Advances-Financial-Machine-Learning-Marcos/dp/1119482089/ref=sr_1_3?keywords=financial+machine+learning&amp;qid=1580121928&amp;sr=8-3">Advances in Financial Machine Learning</a>. Chapter 3, section 6 of the book discusses “meta-labeling” as a way of sizing bets on Wall Street. In short, Dr. Prado refers to a meta-labeling machine learning model as a model specifically used to size bets (as opposed to another ML model that’s used to decide on which side of the bet to take). The idea makes a lot of sense for the March Madness neural network also — one model (the <a href="https://medium.com/re-hoop-per-rate/new-and-improved-march-madness-neural-network-for-2020-c154aa1041b7">MadNet multi-class classification neural net</a>) is used just for determining which upsets to pick, and another model (which, taking after Dr. Prado term meta-labeling, I’ve decided to call “MetaNet”) is used to determine how much I will bet on a given upset in Vegas (where I’ll be headed the first week of this March Madness to try my luck at the sportsbooks). In fact, my current MetaNet implementation trains this binary classification neural network many times, and then predicts the results, storing each prediction into an array:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*tVnm6S49AJaNay3zdlSXSw.png" /><figcaption>Meta-labeling neural network being run multiple times</figcaption></figure><p>Then I examine the results from multiple runs to determine which teams consistently have high Wins Above Seeding, which teams consistently have low Wins Above Seeding, and even the variance of these teams. I’m looking forward to trying MetaNet (in conjunction with MadNet) out in Vegas, and will be updating this blog before my trip with the bets I expect to make, so stay tuned for that!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*NSaAxp_bA6K1aYN9.jpg" /><figcaption>The best place to spend March Madness!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe7bee244682" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/march-madness-neural-network-specifically-for-bet-sizing-fe7bee244682">March Madness Neural Network specifically for Bet Sizing</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Genetic Algorithms to gain insights from MadNet, the multi-class classification neural…]]></title>
            <link>https://medium.com/re-hoop-per-rate/using-genetic-algorithms-to-gain-insights-from-madnet-the-multi-class-classification-neural-a4af9d240a49?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/a4af9d240a49</guid>
            <category><![CDATA[march-madness]]></category>
            <category><![CDATA[neural-network-algorithm]]></category>
            <category><![CDATA[genetic-algorithm]]></category>
            <category><![CDATA[march-madness-bracket]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 10:36:20 GMT</pubDate>
            <atom:updated>2020-01-27T11:02:37.500Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using Genetic Algorithms to gain insights from MadNet, the multi-class classification neural network for March Madness</h3><p><strong>Every College Basketball Team is a Chromosome</strong></p><p>In my last update, I described <a href="https://medium.com/re-hoop-per-rate/new-and-improved-march-madness-neural-network-for-2020-c154aa1041b7">MadNet</a>, an updated neural network for March Madness bracket predictions. For an explanation of the original idea behind MadNet, check out my <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">original March Madness neural network blog post here</a>. Given that MadNet analyzes statistical data to output how many games a team is expected to outperform (or underperform) their seeding by, I thought it would be interesting to see if we could use it to learn about what statistical traits correspond to teams that do better in March than during the regular season (or conversely, to find out which statistical profiles correspond to teams that do worse in March). However, neural networks are notoriously difficult to interpret and understand. We can show that they have great predictive power, but we don’t know why they make the predictions they do. In fact, this <a href="https://towardsdatascience.com/interpretable-neural-networks-45ac8aa91411">“interpreta-bility” of neural networks</a> is one of the most active parts of research in machine learning today, with <a href="https://ieeexplore.ieee.org/document/8579018">important academic papers</a> on the topic being published often. But as of now, a lot of the current research still seems like the blind men and the elephant, with each new learning uncovering some aspect of the problem but no cohesive theory available.</p><p>In this blog post, I decided to experiment with <a href="https://en.wikipedia.org/wiki/Genetic_algorithm">Genetic Algorithms</a> as a way to interpret results from MadNet. I generated a random population of team profiles, and then set aside the profiles that had a Win Above Seeding greater than 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mSstNIkWTRUEb-dSKeHV0w.png" /><figcaption>Using the neural network to find randomly generated teams with Win Above Seeding greater than 1</figcaption></figure><p>and I took the resulting 1,464 teams and bred them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efF8Zb-FrHUxq_6uCqqwaQ.png" /><figcaption>Mixing chromosomes of successful teams</figcaption></figure><p>using a random method where there was a 5/11 chance that the data’s field would be selected from each “chromosome” (really just the randomly generated advanced statistics for the team), and a 1/11 chance that the new data’s field would be randomly generated in order to avoid local minima. I then ran the population generated from this round of breeding on the neural network, retaining the teams that had a Win Above Seeding greater than 2 this time. In this case, 72 out of 732 teams made the cut. I then bred those teams (using an approach the same as described above, with some randomization to avoid local minima), and then took the resulting 36 teams and ran them on the neural network, retaining the teams that had a Win Above Seeding greater than 3. This resulted in a final population of 9 teams, all of which outperformed their seeding by a very large amount, as shown below (note each column corresponds to the percentile rank of the relevant statistical field as described in the original <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">March Madness neural network article</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*Ut6Gj9oDZlSbhlOE0Oaulw.png" /><figcaption>Genetic algorithm generated teams with WAS greater than 3</figcaption></figure><p>I used <a href="https://en.wikipedia.org/wiki/K-means_clustering">k-means clustering</a> to group these 9 teams into two centers. One of these cluster center teams has a lowly 58% win rate (corresponding to a team that is most likely low seeded), but has a top notch 99% strength of schedule, and a three point attempt rate in the 91% percentile and a 82% percentile steal rate. The team is not good (and is even explicitly bad) at everything else — an indication that lower seeded teams that make a big run to the Final Four are guard heavy, get lots of steals, and shoot lots of threes (even though they don’t make many of them during the regular season, they suddenly rely on a stretch of great outside shooting once March Madness kicks off). The other team has a stellar 97% win rate, but a more mediocre strength of schedule, most likely corresponding to a mid-major team that was able to dominate within its own conference. This team had a high rebounding rate and true shooting percentage, meaning that if you play sub-par competition, you better completely dominate scoring and the glass if you want to advance come March. At the same time, this team didn’t have a steal rate that was as high as the team that had a 58% win rate, perhaps meaning that guard oriented teams are only upset favorites if they performed poorly during the regular season?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*DwObq5qRlJXOAPub.jpg" /><figcaption>Chromosomes can also be good models for basketball teams</figcaption></figure><p>I did the same genetic algorithm for teams that underperformed their seed, with 573 out of 100,000 teams performing below a -1 in the first round, 17 out of 288 teams performing below a -2 in the second. In the third round, none of the 9 teams performed below -3, but 2 of the 9 teams still performed below -2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*zWQmghmkGpggpXbjHA-PIQ.png" /><figcaption>Worst performing March Madness teams as determined by the genetic algorithm</figcaption></figure><p>Both of the teams have a solid win percentage and strength of schedule (which makes sense since these are teams that are victims of huge upsets, and only top 1 or 2 seeded teams have upsets with a WAS of -3 or lower). Both teams have a very high assist percentage (see my previous research for more on the <a href="https://medium.com/re-hoop-per-rate/march-madness-post-mortem-and-why-sharing-the-ball-isnt-always-good-afcf7e0dd21d">history of high seeds with high assist percentages performing poorly</a>) and also were among the bottom 1/6 in pace. That being said, UVA played with the lowest pace in the country during the previous season and still won it all — so take that finding (like all the conclusions drawn from these neural networks) with a huge grain of salt!</p><p><strong>More Experiments with other Machine Learning Techniques</strong></p><p>My experiments with genetic algorithms got me wondering: what if I simply took the top performing teams (or worst performing teams) out of a randomly generated set (as determined by the neural network), and performed k-means clustering on them to determine representative “centroid teams” to examine? I first tried this by running 1,000,000 randomly generated neural networks and keeping the 14,023 that had a Win Above Seeding greater than 1. I then performed k-means clustering with 4 clusters on the remaining 14,023, and the resulting 4 cluster centroids had win-loss percentages of 80%, 60%, 77% and 75%, respectively. The centroid team with the highest winning percentage (80%) also had the highest strength of schedule, and played at a pace significantly lower than their offensive rating. They also had a higher effective field goal percentage, and a significantly lower assist rate than the other teams (again, the top seeds with high assist rates tend to get upset). The centroid team with the lowest winning percentage had a high steal rate (steal percentage again! — a necessity for lower seeded teams with poor records to perform well in the tournament), as well as a high assist percentage (lots of assists doesn’t seem to be a problem for lower seeded teams, only the higher seeds). In fact, all 4 of these teams performed well above the mean on steal rate — and interestingly, also had poor turnover rates. It seems like teams with high regular season turnover rates may suddenly find themselves focusing more and tightening up their ballhandling and passing in the postseason? Guess that means it’s important not to shy away from teams just because they’re turnover prone once March comes around.</p><p>When I took a look at randomly generated teams with a Win Above Seeding less than -1 (corresponding to a top 4 seed being upset in the first round), 5,819 out of 1,000,000 teams fit the criteria. These teams had both a high rebounding rate and offensive rebounding rate, seemingly indicating that rebounding rate is not a great predictor of March Madness success — and that high seeded teams that rely only on rebounding are most at risk. Perhaps much of rebounding comes down to effort — and every team starts exerting more effort in March?</p><p>When I examined randomly generated teams with a WAS greater than 3 (corresponding to a team seeded lower than 8 making the Final Four), the resulting centroid teams — like the teams with a WAS greater than 1 — had a very high turnover rate. It looks like regular season turnover rate REALLY doesn’t mean much come tournament time (maybe this even reflects young underrclassmen guards improving their decision making over the course of the season?). When I took a look at teams with a WAS lower than -3 (i.e. 1 seeds that really underperform) was when I noticed something really interesting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*5_mVrMOL5t-mPTWky0JjaA.png" /><figcaption>Cluster centers of teams that really underperform with WAS&lt;-3</figcaption></figure><p>all of these teams have a great win-loss record and strength of schedule (as expected of top seeded teams), but they also had egregiously low free throw rates and egregiously low rebounding percentages. Curious, I took a look at recent history and noticed that UVA ranked a frighteningly low 345th out of 351 teams in Free Throw Rate in 2018, when they had the ignominious distinction of being the only 1 seed to ever lose to a 16 seed. The next year, when they won the championship in 2019, their comparative Free Throw Rate had improved to a less extreme 281 out of 351 teams. I decided to take a look at the recent history of every team with a Free Throw Rates ranking below 305 out of 351, and here’s what I found:</p><p><em>2019</em> —</p><p>Wisconsin, 4 seed that loses in a first round upset, ranks #310 in FTR (I even made hundreds of dollars betting against them in this game!)</p><p>Michigan, 2 seed that is upset in the Sweet 16, ranks #308 in FTR</p><p><em>2018 —</em></p><p>Kansas, 1 seed that performed to expectations and lost in the Final 4, ranks #328 in FTR</p><p>UVA, 1 seed that lost in the 1st round, #345 in FTR</p><p>UNC, 2 seed that was upset in the 2nd round, #317 in FTR</p><p>Creighton, 8 seed that was upset in the 1st round, #337 in FTR</p><p><em>2017 —</em></p><p>UVA, 5 seed that played to expectations and lost in the 2nd round, #349 in FTR</p><p>UCLA, 3 seed that played to expectations and lost in the Sweet 16, #342 in FTR</p><p>Iowa State, 5 seed that played to expectations and lost in the 2nd round, #336 in FTR</p><p>Creighton, 6 seed that was upset in the 1st round, #335 in FTR</p><p>St. Mary’s, 7 seed that played to expectations and lost in the 2nd round, #334 in FTR</p><p>Notre Dame, 5 seed that lost in the second round, #328 in FTR</p><p>Michigan, 7 seed that went one beyond the expected second round, #305 in FTR</p><p><em>2016 —</em></p><p>Michigan State, 2 seed that was upset in the 1st round, #330 in FTR</p><p>Iowa State, 4 seed that performed to expectations and lost in the Sweet 16, #350 in FTR</p><p>Out of 15 teams that were in the very bottom of Free Throw Rates, only 1 outperformed expectations, and 7 were upset. Even some of the teams that won barely eeked out victories. It seems like we’re finding a useful rule of thumb here: don’t pick teams among the absolute bottom in Free Throw Rate (i.e. below 305 out of 351 teams) to advance far in the tourney, and maybe even pick the high seeded teams with abysmal Free Throw Rates to be upset. In fact, it seems like it might be a good idea to bet against the spread on the lower seeded team whenever they’re playing a higher seeded team!</p><p>Somehow, the moment a team raises their FTR above the absolute basement, they start winning, like UVA in 2019 (281st ) or Villanova in 2018 (293rd). Overall, examining these “centroid teams” have shown that teams that have a high three point rate tend to both underperform AND overperform a lot, which confirms the intuition that 3 pointers tend to introduce variance to the game. In addition, teams that did better tended to play at a below average to slightly above average pace, and successful teams tended to have a pace ranking that was lower than their offensive rating (in fact, a cool rule of thumb for seeing how a team measures up come March is to take their offensive rating ranking versus other teams that season, and divide it by their pace ranking versus other teams that season). All that being said, the low FTR tendency just might be the coolest thing I’ve found from experimenting with applying different random data to the MadNet March Madness Neural Network!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4af9d240a49" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/using-genetic-algorithms-to-gain-insights-from-madnet-the-multi-class-classification-neural-a4af9d240a49">Using Genetic Algorithms to gain insights from MadNet, the multi-class classification neural…</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New and Improved March Madness Neural Network for 2020]]></title>
            <link>https://medium.com/re-hoop-per-rate/new-and-improved-march-madness-neural-network-for-2020-c154aa1041b7?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/c154aa1041b7</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[college-basketball]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[march-madness]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Wed, 15 Jan 2020 10:16:24 GMT</pubDate>
            <atom:updated>2020-02-09T23:06:18.106Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been almost 2 years since I first <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">trained a neural network to fill out my March Madness bracket</a>. I used the same neural network implemented with <a href="https://www.tensorflow.org/">Google’s TensorFlow</a> to predict my March Madness bracket last year, but due to my busy schedule (I was actually getting married around March Madness time last year!), I didn’t have time to write a blog post about it. Long story short, the neural network gave strong signs that Oregon would upset Wisconsin in the first round, that Ohio State would upset Iowa State in the first round, and that UVA would win it all. I actually had a friend help me put down some bets on Oregon upsetting Wisconsin and Ohio State upsetting Iowa State, as well as on UVA winning it all. In the process I managed to turn $120 into over $500, not bad for my nifty little neural network.</p><p>To review, my approach to March Madness looks at predicting winners in the tournament as a value problem. Just like how <a href="https://www.investopedia.com/articles/01/071801.asp">Warren Buffett and Benjamin Graham look at investing as finding undervalued stocks and avoiding overvalued stocks</a>, I treat the seed of each NCAA tournament team as a pre-set “value” for that stock. Then I use machine learning to find what combinations of advanced stats correspond to teams that “underperform” (i.e. are overvalued) or “overperform” (i.e. are undervalued) relative to their seed. When an overvalued team plays against an undervalued team, to quote the great Dick Vitale, “<a href="https://www.youtube.com/watch?v=q6_QMII9wJ8&amp;t=40s">Upset city, baby!</a>”. As I wrote in my original neural network for March Madness blog post:</p><blockquote>“I decided to train my machine learning algorithms to use advanced statistics to classify which high seeded teams tend to be “upsettable”, and which low seeded teams have “upset potential”. To do this, I came up with a metric, “Wins Above Seeding”, that measures both how well a team resists being upset and how good a team is at upsetting higher seeds. In short, Wins Above Seeding (WAS) measures how many more games a team wins than it’s seeding would suggest. For example, a 7th seed would be expected to win a game against a 10th seed in the first round, but would be expected to lose a game against a 2nd seed in the second round. If that 7th seed makes it past the 2nd seed and advances to the Sweet Sixteen, it would have a WAS of +1. If it won another game and advanced to the Elite Eight, it would have a WAS of +2, and if it made it to the Final Four (as South Carolina did as a 7th seed last year), it would have a WAS of +3. Conversely, if a 1st seeded team loses in the second round, it would have a WAS of -3 (since a top seed implies the team is expected to make the Final Four, advancing 3 games past the second round). If I could get data on both how past NCAA teams tended to play, and on how many Wins Above Seeding they were able to obtain, a machine learning algorithm would be able to find patterns that correlate with March Madness success.”</blockquote><p>In short, I’m taking advantage of the fact that the “seeds” in the NCAA tournament bracket are all set up by a bunch of old guys in Indianapolis. While overall they gets things right (as evidenced by higher seeded teams winning about three quarters of the time), I believe they have certain biases that cause them to overvalue certain teams (for example, <a href="https://medium.com/@ld7q/march-madness-post-mortem-and-why-sharing-the-ball-isnt-always-good-afcf7e0dd21d">teams that pass the ball a lot might naturally appeal to the old folks running the NCAA who are used to a certain style of play</a>). In addition, I believe there are certain traits that make teams more likely to succeed in March Madness, when their opponents start really clamping down on defense and both teams start fighting for every loose ball. By using machine learning, I believe I can “correct” these biases, and I can also figure out what specific type of advanced stats profile corresponds to an edge (or a disadvantage) in college basketball’s postseason.</p><p>In the last few weeks, I decided to “clean up” and revamp my March Madness neural network. My original dataset took <a href="https://www.sports-reference.com/cbb/seasons/2020-advanced-school-stats.html">advanced stats data directly from The Sports Reference</a>, but this data was all in different formats: strength of schedule is a number roughly between negative 12 and 12, Free Throw Rate and Three Point Attempt Rate are listed as decimals, while PACE and Offensive Rating are numbers greater than 50. I decided to clean up this dataset using feature normalization: for every season that I had available data (from 2010 to 2019), I would take the highest value for each category among all March Madness bound teams, subtract the lowest value among the March Madness teams. I would then take this difference and divide each team’s value by the difference. For example, if I was looking at Free Throw Rate in the <a href="https://www.sports-reference.com/cbb/seasons/2019-advanced-school-stats.html">2018–2019 season</a>, I would take the highest Free Throw Rate among March Madness teams, UCF at 0.453, and subtract the lowest Free Throw Rate among March Madness teams, Liberty at 0.265 (keep in mind that all tournament bound teams are marked with a “NCAA” tag next to them on Sports Reference). In this case, after feature normalization my dataset would end up with UCF having the value 1 for Free Throw Rate, Liberty having the value 0, and a team like Kentucky with a Free Throw Rate of 0.419 having the normalized value:</p><p>(KentuckyFTR-MinimumFTR)/(MaxFTR-MinimumFTR)=<br>(0.419–0.265)/(0.453–0.265) = 0.819</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*fpHkfgGl0ncm-aAz" /><figcaption>Normalized the Free Throw Rate relative to the best and worst free throw rate teams in the tourney</figcaption></figure><p>I performed this feature normalization for each of the 15 advanced stats that made up my dataset. With feature normalization, I’m hoping data fields that The Sports Reference happened to use a large number range for don’t exert disproportionate impact on the neural network’s training, resulting in more accurate results for the 2020 tournament.</p><p>To accomplish this in Python, I first read in my original dataset using Jupyter Notebook:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nreShyFV5ElCK2jPCOCYoA.png" /><figcaption>Original March Madness dataset for teams from 2010 to 2019</figcaption></figure><p>and then looped through the entire dataset, grouping the data for each season together, finding the maximum and minimum in different stat categories for each season, and then normalizing using the equation shown above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ZR3ExxmKlKuVoUEBH4TEg.png" /><figcaption>Part of the loop in the Python script to normalize the existing dataset</figcaption></figure><p>The normalized data looked something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MEqTtMxuC_Xf4z1DSLXTMA.png" /></figure><p>With this new data, I once again tried some simpler machine learning techniques like <a href="https://en.wikipedia.org/wiki/Random_forest">Random Forests</a> and <a href="https://en.wikipedia.org/wiki/Decision_tree">Decision Trees</a>. Just like before, these classifiers gave results that were below the 76% accuracy that simply picking higher seeds would have given (in fact, most of these classifiers were correct less than 50% of the time!). It seems like neural networks are definitely the way to go for this dataset!</p><p>Instead of TensorFlow, my revamped neural network uses <a href="https://keras.io/">Keras</a>, another open source neural network library that works at a higher level than TensorFlow. Essentially, Keras wraps around TensorFlow, making it easier to put together neural networks. Like TensorFlow, Keras was also developed at Google, in this case by engineer François Chollet. One of the big benefits of Keras is that it’s very easy for me to add regularization to prevent <a href="https://en.wikipedia.org/wiki/Overfitting">overfitting</a>, where my neural network corresponds too closely to the existing data and loses its ability to predict results more generally. In this case, I added both <a href="https://machinelearningmastery.com/dropout-for-regularizing-deep-neural-networks/">dropout regularization</a> and <a href="https://towardsdatascience.com/l1-and-l2-regularization-methods-ce25e7fc831c">L2 regularization</a>. In dropout, during training some of the output features of a neural network layer are randomly, well, dropped out (i.e. set to zero) to fight overfitting. In L2 regularization, a cost is added proportional to the square of the weight coefficients in the neural network, in an effort to keep the values of these weights small.</p><p>It was easy to put together my neural network using Keras, as you can see in the code snippet below. After some trial and error, I found that I was seeing solid results for a neural network with 256 nodes in the input layer (chosen because there are 15 data fields in each training instance, and 15²=225=~256), with 128 nodes, 64 nodes and 32 nodes in each of the consecutive hidden layers. Note that we add a bit of L2 regularization to each layer, and add dropout set at a ratio of 0.1 after each layer. Since I approach machine learning for March Madness as fundamentally a categorization problem (the Wins Above Seeding value for a given team corresponds to its category), I’m using a <a href="https://machinelearningmastery.com/rectified-linear-activation-function-for-deep-learning-neural-networks/">Rectified Linear Unit (or ReLU) activation function</a>. Finally, at the last layer, to aid the categorization, I’m using a <a href="https://gombru.github.io/2018/05/23/cross_entropy_loss/">categorical cross entropy loss function</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3sRlTubLQN03qrPoxZPuQ.png" /><figcaption>Neural Network getting assembled in Keras</figcaption></figure><p>This use of categorical cross entropy in the final layer means that we now need our training data to be <a href="https://en.wikipedia.org/wiki/One-hot">one hot encoded</a>, i.e. each Win Above Seeding value must be represented as an 11 bit binary value, with only one bit set to 1 (and the rest set to 0) for each category. In this case, a WAS of -4 (corresponding to a 1 seed ignominiously losing in the first round, *cough* *cough* 2018 UVA) would have a value of binary 00000000001, while a WAS of +2 (corresponding to, for example, a 7 seed making it 2 games beyond expectations to the Elite Eight) would have a value of binary 00001000000. The code to set up the training data now consists of adding 5 to the WAS value to make sure all the values are positive and then converting it to a one hot binary representation. Luckily, Keras provides a one-hot function that really makes this process easier:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t9eF82UaLtU9apFMbm_uQQ.png" /><figcaption>Setting up the WAS data to use Categorical Cross Entropy</figcaption></figure><p>I set aside 94 samples from the dataset to be used as a validation set, and began training with the remaining 550 samples. I initially trained the data for 512 epochs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cfygKa6pSlpSUU6Xzj86Lw.png" /><figcaption>Training the March Madness Neural Network</figcaption></figure><p>which resulted in an accuracy close to 98%:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YNTp2b1UFiDAAYupKQZbZA.png" /><figcaption>Accuracy after training for 512 epochs</figcaption></figure><p>but a plot of the training loss showed that we might be overfitting after around 200–300 epochs or so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pamd7Klazz59wfAKEjb3Lg.png" /><figcaption>Neural network loss levels out after 200–300 epochs, beyond which we are overfitting</figcaption></figure><p>As a result, I decided to retrain the neural network for only 256 epochs, resulting in a still solid accuracy of about 93%:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*_FhftAFAFpbAjWESVkFcvQ.png" /><figcaption>Accuracy after 256 epochs</figcaption></figure><p>This is still a very acceptable accuracy, especially when we consider that picking only high seeds gives us an accuracy of only about 76%.</p><p>And… there you have it! A new and improved neural network for March Madness that I’m calling “MadNet” (creative name, right?). In the coming weeks, I’ll be writing about another neural network I’ve created that leverages the much maligned box score in a new and creative way, so stay tuned for new articles on this “BoxNet”!</p><p><em>If you like what you read here and would like to support re-HOOP-PER-rate, we are accepting donations of the cryptocurrency Ether at address: </em>0xC909ce5d714B3cBD98D498331a45A64E62F786bf</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c154aa1041b7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/new-and-improved-march-madness-neural-network-for-2020-c154aa1041b7">New and Improved March Madness Neural Network for 2020</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[March Madness Post-Mortem, and why Sharing the Ball isn’t always good]]></title>
            <link>https://medium.com/re-hoop-per-rate/march-madness-post-mortem-and-why-sharing-the-ball-isnt-always-good-afcf7e0dd21d?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/afcf7e0dd21d</guid>
            <category><![CDATA[march-madness]]></category>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Wed, 15 Jan 2020 10:15:36 GMT</pubDate>
            <atom:updated>2018-04-12T08:53:26.280Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been a while since March Madness, and what Madness it was! My <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">bracket</a> was torn to shreds pretty quickly, though the neural network I trained did predict Buffalo over Arizona, and really liked Nevada to upset Cincinnati. I said <a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">before</a> that if I were to bet on any game, it would be a potential Nevada over Cincinnati 2nd round upset, and after seeing the Nevada Wolfpack come back from 20 points down to upset Cincinnati… well, to paraphrase the great <a href="https://www.youtube.com/watch?v=p5L_QkUZ-3s">Rasheed Wallace</a>, numbers don’t lie! (At least, not when they repeatedly identified Cincinnati as the team most likely to be upset)</p><p>While the Tourney was going on, I decided to do some <a href="https://en.wikipedia.org/wiki/Principal_component_analysis">Principal Component Analysis</a> to see which of the 14 Advanced Statistics I analyzed were most relevant in predicting a team’s NCAA tournament success. This projects the dataset into a pre-determined number of dimensions, in a way that optimally keeps as much of the original information as possible. The magnitude of each of the original components in the new dimensions gives a clear sense of which statistics are the most “important”, in terms of capturing data that are already captured in other dimensions.</p><p>In Python, I did:</p><pre><strong>from</strong> <strong>sklearn.decomposition</strong> <strong>import</strong> PCA<br>pca=PCA(n_components=3)<br>X3D=pca.fit_transform(XTrain)</pre><p>to convert the original dataset into a new representation with only 3 dimensions. I checked how well this new 3 dimensional dataset captured the original data by calculating the Explained Variance Ratio:</p><pre>print(pca.explained_variance_ratio_)</pre><pre>[0.49246765 0.14785902 0.11346942]</pre><p>adding up these percentages,we get about 75%, not bad for reducing 14 dimensions down to 3!</p><p>To see which of the orignal 14 stats were projected onto these 3 dimensions the most, I printed out the components of each in the new PCA representation:</p><pre>pca.components_</pre><pre>array([[-1.29458010e-01,  6.95485825e-02, -9.83184325e-04,<br>        -8.05737044e-02, -4.33195551e-03, -1.46212499e-01,<br>        -1.01218939e-01, -8.34025780e-04,  1.36409696e-04,<br>         9.10941095e-04, -3.09267288e-01,  1.41108473e-02,<br>        -4.74401428e-01, -4.44151076e-03, -7.86984776e-01],<br>       [-2.80822347e-02,  3.44688827e-02,  1.91145602e-03,<br>        -1.06263980e-01, -1.24243865e-02,  9.26066611e-01,<br>         4.90970113e-02,  1.68262277e-03,  1.79876657e-03,<br>        -1.09215205e-03,  2.28980781e-01, -7.21053163e-02,<br>        -2.39997384e-01,  3.03746720e-03, -1.06380175e-01],<br>       [-1.00796963e-01, -1.74515007e-01,  3.63456693e-03,<br>        -2.20267108e-01, -6.99973454e-02, -3.07469576e-01,<br>         6.89514344e-02,  3.54759919e-03,  2.67396701e-03,<br>         1.88325307e-04,  8.11275093e-01,  1.67915195e-01,<br>        -3.44898208e-01,  7.61347422e-03, -3.55936511e-02]])</pre><p>The most relevant statistic for the first component (with a magnitude of almost 0.8) seems to be the first element in our array, which corresponds to good old fashioned wins and losses. The next 3 most important factors are Offensive Rating, Strength of Schedule, Assist Rate, and Offensive Rebounding Rate. Looking at the next most important component (the second array in the output), Assist Rate is the most important statistic. Looking at the third array, we see that Offensive Rating is the biggest contributor, followed (yet again) by Assist Rate. It seems offensive statistics manage to “capture” much of the information in other Advanced Statistics.</p><p>Curious about seeing Assist Rate appear repeatedly among the most important statistics, I took a look at the performance of the teams that ranked HIGHEST in Assist Rate in the NCAA Tournament over the past 9 seasons. Old sportscasters always like to say teams that “share the ball” and are “unselfish” perform better in the post-season, but is that really true?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*8Gr2i5ZGxiyNQdJM.jpg" /></figure><p>I took a look at teams that were:</p><ol><li>In the Top 15 in Assist Rate</li><li>Had a Top 6 seed (making them the favorites in at least their first game)</li></ol><p>What I found was a bit shocking: the 49 teams that fit this profile had a net record of 25–24 in the NCAA Tournament from 2010 to 2018. A number of those teams were from the Big 10 Conference (Michigan State, in particular, consistently had a high assist rate); if we take out the Big 10 teams, the top passing teams who received high seeds had a record of only 18–18 — they were upset as often as they won. Keep in mind these are top seeded teams! They are generally expected to win — and their opponents have favorable odds. That means if you went to Vegas every single year from 2010 to 2018, and simply bet on teams that were in the Top 15 in assist rate to lose every game, you would be way ahead right now. In fact, you would have predicted notorious, come from nowhere upsets such as 15 seeded Florida Gulf Coast over 2nd seeded Georgetown in 2013 and 15 seed Middle Tennessee State’s upset of Michigan State in 2016.</p><p>Second seeded teams that are in the top 15 in assist rate fare particularly poorly in March: their record from 2010 to now is a measly 6–6, far below their expected result of making it to the Elite Eight. In 2018 alone, second seeds Michigan State and UNC were upset in the second round of the tournament. It seems like that conventional wisdom about “sharing the ball” doesn’t actually apply come March! A few other observations about these teams:</p><ul><li>Top 15 Teams that received Top 6 seeds had an average seeding of 3.5, which means they would be expected to reach the Sweet 16</li><li>Instead, they have an average WAS score of -1.1, corresponding to an expected loss in the second round</li><li>Second seeded teams had an average WAS score of -2.4, somewhere between a second round upset and a first round upset, performing much worse than their expected appearance in the Elite Eight</li><li>Only 2 teams that fit this profile have made it to the Sweet 16 in the last 9 years: Top seeded Syracuse in 2010 and 4th seed Michigan State in 2014. Both teams promptly lost</li><li>Only 2 of the 49 teams that fit this profile have performed above their seeding in the Big Dance: the aforementioned Michigan State team in 2014, and 6th seeded Xavier in 2015. Both teams only won one more game than expected.</li><li>Speaking of Michigan State, they appeared on this list 3 times, more than any other team. Back when Tom Izzo led the Spartans to the National Championship in 2000, they were ranked a lowly 102nd in Assist Rate.</li></ul><p>What is it about teams that share the ball so much that makes them vulnerable to upsets? It may be that teams which have a high assist rate are forced into that position because they don’t have individual star players that can take over in close games. The lack of a clear go-to scoring option may cause teams to pass the ball around the perimeter, without anyone taking the initiative to make a play (a common sight every March). That’s a recipe for disaster in the close games that have come to define the NCAA Tournament.</p><p>It may also be because teams that pass at such a high rate rely on an offense that is built around repeated “gimmicks” like lots of ball hand off screens, or lots of repeated back door cuts. For a top seeded team, there is usually plenty of game film for their opponents to analyze and determine exactly how to counter those gimmicks. Lower seeded teams that have a high assist rate perform much better in the tournament, possibly because there isn’t as much game film of their offensive schemes for opponents to study, allowing their clever plays to be shocking surprises. In short, assist heavy schemes like the <a href="https://www.youtube.com/watch?v=rYd9Tqiy-z8">Princeton offense</a> are only effective for the Princetons, Holy Cross-es, and Richmond’s of the world, and not for the Michigan States, UNCs, and Georgetowns.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afcf7e0dd21d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/march-madness-post-mortem-and-why-sharing-the-ball-isnt-always-good-afcf7e0dd21d">March Madness Post-Mortem, and why Sharing the Ball isn’t always good</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Training a Neural Network to fill out my March Madness Bracket]]></title>
            <link>https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1?source=rss----6f5fff135e62---4</link>
            <guid isPermaLink="false">https://medium.com/p/2e5ee562eab1</guid>
            <category><![CDATA[march-madness]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[college-basketball]]></category>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <dc:creator><![CDATA[reHOOPerate]]></dc:creator>
            <pubDate>Thu, 15 Mar 2018 09:33:00 GMT</pubDate>
            <atom:updated>2018-03-15T11:03:03.578Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Machine Learning Madness!</strong></h3><p>March Madness has always been my favorite sporting event. It manages to perfectly combine my favorite sport with the surreal chaos usually found at 3 am raves and college house parties. Add in the pageantry (from <a href="https://deadspin.com/wichita-states-mascot-has-been-creepy-at-every-stage-o-1544651485">ridiculous mid-major mascots</a> to <a href="https://www.youtube.com/watch?v=yfPBQyQkUKI">One Shining Moment</a>), the inimitable mania of <a href="https://www.youtube.com/watch?v=B08Km6sV3pk">Gus Johnson</a>, and the impossibly <a href="https://www.ncaa.com/news/basketball-men/bracketiq/2018-02-15/march-madness-bracket-challenge-how-hard-it-pick-perfect">unpredictable</a> gambling element, and you get a uniquely insane American sports experience.</p><p>As much as I love March Madness, my bracket always seems to end up torn to shreds by the end of the Elite Eight. There are simply too many upsets that come out of nowhere, and it seems like the Tourney just gets more crazy and random every year. This year, I used data from previous March Madness-es and Google’s <a href="https://www.tensorflow.org/">TensorFlow</a> library to train a neural network to complete my bracket. That way, when my bracket inevitably gets busted, I can blame a computer AI instead of my own poor judgement. Plus, if TensorFlow is good enough to <a href="https://www.theverge.com/circuitbreaker/2016/5/19/11716818/google-alphago-hardware-asic-chip-tensor-processor-unit-machine-learning">defeat the world champion of Go</a>, it must be good enough to predict whether a bunch of 18 to 22 year old kids can win six basketball games in a row… right?</p><p>From past experience, it always seems like winning a March Madness pool comes down to at least one of two things:</p><ol><li>Picking tough and resilient (usually defensive-minded) top seeded teams that don’t get upset to make the later rounds and Final Four (i.e. Duke in 2010, Louisville in 2013, Wisconsin in 2015)</li><li>Picking a great lower-seeded team to go on a run and make a series of upsets (i.e. Butler in 2010 and 2011, UConn in 2011 and 2014, South Carolina in 2017)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5OBK8ZRsJW2MPnti.jpg" /></figure><p>In other words, a good bracket should have a solid mix of top seeded teams that are “un-upsettable”, combined with lower seeded teams that have high “upsetability potential”. I decided to train my machine learning algorithms to use advanced statistics to classify which high seeded teams tend to be “upsettable”, and which low seeded teams have “upset potential”. To do this, I came up with a metric, “Wins Above Seeding”, that measures both how well a team resists being upset and how good a team is at upsetting higher seeds. In short, Wins Above Seeding (WAS) measures how many more games a team wins than it’s seeding would suggest. For example, a 7th seed would be expected to win a game against a 10th seed in the first round, but would be expected to lose a game against a 2nd seed in the second round. If that 7th seed makes it past the 2nd seed and advances to the Sweet Sixteen, it would have a WAS of +1. If it won another game and advanced to the Elite Eight, it would have a WAS of +2, and if it made it to the Final Four (as South Carolina did as a 7th seed last year), it would have a WAS of +3. Conversely, if a 1st seeded team loses in the second round, it would have a WAS of -3 (since a top seed implies the team is expected to make the Final Four, advancing 3 games past the second round). If I could get data on both how past NCAA teams tended to play, and on how many Wins Above Seeding they were able to obtain, a machine learning algorithm would be able to find patterns that correlate with March Madness success.</p><h3><strong>Getting the Data</strong></h3><p>To obtain my training data, I wrote a Perl script to scrape data on advanced statistics from the website <a href="https://www.sports-reference.com/cbb/">Sports-Reference</a> into a simple <a href="https://en.wikipedia.org/wiki/Comma-separated_values">CSV file</a>. Luckily, Sports Reference marks all teams that advance to the March Madness tournament with a “NCAA” note on the side, so the scraping was relatively painless — check out the code snippet at the bottom to see the Perl script I wrote for this. I decided to use advanced statistics since they are often more revealing than traditional points-rebounds-assists-blocks-steals box score stats, and (more importantly) because they are all rate based. This meant my data would not be affected by apples to oranges comparisons between a slower defense oriented team (think UVA) and a faster paced offense oriented team (think Duke). The 14 advanced statistics I used as parameters for the training (and what they mean) are:</p><p><strong>W-L %</strong>: The win-loss percentage, or percentage of games the team won during the regular season</p><p><strong>SRS: </strong>A rating metric that takes into account a team’s average point differential and it’s strength of schedule</p><p><strong>SOS: </strong>Strength of schedule, a measure of how strong the opponents the team faced were</p><p><strong>Pace: </strong>Average possession the team plays per 40 minutes</p><p><strong>Offensive Rating: </strong>An offensive rating that measures how many points the team scores per 100 posessions</p><p><strong>Free Throw Rate: </strong>The ratio of a team’s free throw attempts to it’s field goal attempts, measures how aggressive a team is at attacking the basket and drawing fouls</p><p><strong>3 Point Attempt Rate: </strong>The percentage of a team’s field goal attempts that are three point attempts</p><p><strong>True Shooting Percentage: </strong>A measure of shooting efficiency that takes into account the different values assigned to three pointers, two point field goals, and free throws</p><p><strong>Total Rebound Percentage: </strong>The percentage of available rebounds a team grabbed (also the percentage of rebounds they prevented the other team from grabbing)</p><p><strong>Assist Percentage</strong>: The percentage of the team’s field goals that were assisted</p><p><strong>Steal Percentage: </strong>Percentage of the <em>opposing</em> team’s possessions that ended with a steal</p><p><strong>Block Percentage: </strong>Percentage of the <em>opposing</em> team’s possessions that ended with a block</p><p><strong>Effective Field Goal Percentage: </strong>A measure of field goal percentage that accounts for the higher number of points assigned to 3 point shots</p><p><strong>Turnover Percentage: </strong>Number of turnovers the team commits per 100 plays</p><p><strong>Offensive Rebound Percentage: </strong>The same as Total Rebound Percentage but applied only to offensive rebounds</p><p>There was no straightforward way to scrape the Wins Above Seeding data that will be used to train the machine learning algorithms, so I looked through old brackets and manually picked out the team’s WAS score. It was a fun trip through the ghosts of busted brackets past (sigh, I still can’t believe Kansas got <a href="https://www.youtube.com/watch?v=GiwqEz50ipY">Ali Farokhmanesh-ed</a>). For teams that advanced past the Final Four, I continued adding to their WAS score, resulting in the sum of all WAS scores for a given season being more than 1. I did this so my trained model would reflect the additional good performance of any team that advances past the Final Four and on to the championship.</p><p>I restricted my data to the past 8 March Madness tournaments from 2010 to 2017, mainly because the rate of tourney upsets greatly increased starting in 2010. Back in 2007, the average seed of teams in the Final Four was 1.5, in 2008 it was 1.0, and in 2009 it was1.75. In 2010, that average Final Four seeding jumped to 2.6, followed by 6.5, 2.25(the one year of Anthony Davis induced relative sanity in 2012), 4.5, 4.5, 2.5, 3.75, and 3.0 in 2017. Clearly, there was a large jump in upset teams making big runs starting circa 2010. I’m not sure why this change happened in that particular year, though one promising theory is that it has to do with John Calipari’s <a href="https://www.aseaofblue.com/2015/7/18/8997019/iconic-moments-john-calipari-era-2010">move to Kentucky</a> causing much of the top talent to join the Wildcats or Coach K’s Blue Devils, leading to a dearth of elite talent in the rest of college basketball and top teams that are more easily upset as a result.</p><p>Once I had my data ready, I used my trusty <a href="http://jupyter.org/">Jupyter Notebook</a> to read it into a <a href="https://pandas.pydata.org/pandas-docs/stable/dsintro.html">Pandas dataframe</a>:</p><pre><strong>import</strong> <strong>pandas</strong> <strong>as</strong> <strong>pd</strong></pre><pre>bball_data=pd.read_csv(&quot;/home/liangd/cbb_full.csv&quot;)</pre><p>The scraping script had done its job, and my data was ready for some training:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*A7XG3ePsePKuAkyx4VfuJg.png" /><figcaption>The csv file read in as a Pandas dataframe</figcaption></figure><p>Since the machine learning libraries I’m using prefer working with numpy arrays, I assigned the training parameters to an array called “XTrain” (the columns from team_name to ORB) and the training predictions to an array called “y” (the column labeled OverE). I also used a scaling pipeline to transform the data in these arrays to get them ready for machine learning.</p><h3><strong>A Few First Experiments</strong></h3><p>Before unleashing a neural network, I tried to fit the data using a simpler machine learning technique known as a <a href="https://en.wikipedia.org/wiki/Random_forest">Random Forest</a> classifier. In this approach, the data is repeatedly trained using a series of decisions in a flowchart known as a <a href="https://en.wikipedia.org/wiki/Decision_tree">Decision Tree</a>, and the predictions of these individual decision trees are used to “vote” on a final (ideally correct) prediction. I used the Random Forest classifer provided in the free <a href="https://en.wikipedia.org/wiki/Scikit-learn">SciKit-learn</a> Python library:</p><pre><strong>from</strong> <strong>sklearn.ensemble</strong> <strong>import</strong> RandomForestClassifier<br>forest_clf=RandomForestClassifier(random_state=22)</pre><p>To see how well the Random Forest classifier would do predicting the results of previous March Madness-es, I used <a href="https://en.wikipedia.org/wiki/Cross-validation_(statistics)#k-fold_cross-validation">k-fold cross validation</a>, a techique in which the training data is randomly split into k different samples, one sample which is kept as test data and the other k-1 samples which are used to train the machine learning algorithm. The resulting algorithm is then used to predict the test data, and its accuracy is reported. This process is repeated with each sample being selected as the test data, and the accuracy of the test with each sample data is reported. For testing the Random Forest classifier, I chose k=3:</p><pre>cross_val_score(forest_clf, XTrain, y, cv=3, scoring=&quot;accuracy&quot;)<br>&gt;array([0.46285714, 0.46745562, 0.4702381 ])</pre><p>The Random Forest is able to predict the amount by which past March Madness teams win or lose more than expected with an accuracy of 46%-47%, not particularly great. That being said, to be somewhat useful to us, we just need to know which teams are likely to win more than expected and which teams are likely to win less. To do that, we can train the data to make a simpler prediction: whether a team will win more or less than 0 games. To do that, we create a Boolean array that has “true” elements for each team that has a WAS greater than 0, and “false” elements for each team that has a WAS equal to 0 or less:</p><pre>y_gt0=(y&gt;0)<br>cross_val_score(forest_clf, XTrain, y_gt0, cv=3, scoring=&quot;accuracy&quot;)<br>&gt;array([0.73099415, 0.73099415, 0.75294118])</pre><p>This looks much better — more than 50% accuracy! But keep in mind that about 24% of all March Madness games result in upsets. That means that even if we predict all high seeds (also known as the Completley Boring Way of Picking a Bracket), we would still have 76% accuracy! All of a sudden, our Random Forest Classifier isn’t looking so great — we’d be better off picking all high seeds like some obnoxious Duke fan.</p><p>For what it’s worth, when I use the Random Forest classifier to predict this year’s March Madness teams, it outputs only 2 results: it expects Michigan State to win 2 fewer games than it should (that would means it expects 3rd seeded Michigan State to lose in the first round to 14th seeded Bucknell!) and it expects Duke to win one more game than it should, which would place Duke in the Final Four — maybe it will be a good March for obnoxious Duke fans after all. Then again, the Random Forest is only batting 73% — maybe we can do better. One quick note — I know in a real data science project, right about now the precision/recall tradeoff should be studied in depth and the Confusion Matrix should be examined — but I’m just trying to quickly fill out my bracket here and don’t have time to bother with that, now or in my later experiments.</p><p>Let’s try one more quick experiment before we move to the neural network and TensorFlow. A <a href="http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html">Stochastic Gradient Descent (SGD) Classifier</a> repeatedly takes the derivative of the error function while adjusting coefficients in a linear regression until the error function reaches a local minimum (those of you who somehow managed to remember more calculus than me may recall that going in the direction of a lower derivative moves you toward minimum values of a function). Typing some Python into my Jupyter Notebook gives me:</p><pre>from sklearn.linear_model import SGDClassifier<br>sgd_clf=SGDClassifier(random_state=11)<br>cross_val_score(sgd_clf, XTrain, y_gt0, cv=3, scoring=&quot;accuracy&quot;)<br>&gt;array([0.28571429, 0.0295858 , 0.52380952])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*CRbUU_c15rDPo9F-.jpg" /><figcaption>Stochastic Gradient Descent finding the minimum in the error function</figcaption></figure><p>One of the training sets shows less than 3% accuracy — clearly, the SGD Classifier is practically useless for our purposes. The chances of a team surviving deep into the tourney clearly don’t have a simple linear dependence on any of the advanced statistics we’re looking at. Let’s see if we can do better with a neural network, at least we know we can’t do much worse!</p><h3><strong>Neural Netball</strong></h3><p>To get started, I imported the TensorFlow library into Python and created a Deep Neural Net (DNN) with two hidden layers each with 512 neurons, and a softmax output layer with 10 neurons.</p><pre><strong>import tensorflow as tf<br></strong>feature_columns=tf.contrib.learn.infer_real_valued_columns_from_input(XTrain)<br>dnn_clf=tf.contrib.learn.DNNClassifier(hidden_units=[512,512], n_classes=10, feature_columns=feature_columns)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*o39MZXzofFb1YrwwHN_esw.png" /><figcaption>Example of a Deep Neural Network. The one I use to predict March Madness has 14 neurons in the input layer, 10 in the output layer and only 2 hidden layers (of 512 neurons each).</figcaption></figure><p>I wanted to use a neural network with only 2 hidden layers so that I wouldn’t have to worry too much about selecting different activation functions. Full disclosure, my background is in GPU architecture, and I don’t fully understand the tradeoffs between say, a hyperbolic tangent activation function and a ReLU function — I’m sure the truemachine learning geeks are judging me for this, but what I know is enough for me to let me play with the data. I chose the 512 neurons in the hidden layers after adjusting in powers of 2 from 128 to 256 to 512 and seeing the accuracy of my model consistency go above 98% once I hit 512. I chose 10 neurons in the output layer to correspond to historical team WAS ranging from +6, which would correspond to a lower seeded team winning the entire tourney (this hasn’t happened yet but is conceivable — especially if <a href="http://www.espn.com/mens-college-basketball/player/_/id/4277811/collin-sexton">Collin Sexton</a> of Alabama lights it up from three this March), to -3, corresponding to a 2nd seed losing in the first round or a first seed losing in the second round (not quite conceivable to me that a first seed would lose in the first round, but I may be proven wrong!).</p><p>Now that my neural network was all set up, it was time to start training it. Since TensorFlow’s DNN Classifier can only accept integer outputs, I took my previous y_gt0 array and converted it from a Boolean array to integer, and then let the training algorithm go to work. Since this dataset wasn’t particularly large, I could let it run on my Intel Core i5 CPU without distributing the workload to the GPU and still get results in less than 10 minutes.</p><pre>yi=y_gt0.astype(int)<br>dnn_clf.fit(x=XTrain, y=yi, batch_size=50, steps=40000)<br>dnn_clf.evaluate(XTrain, yi)<br>&gt;{&#39;accuracy&#39;: 0.9941406, &#39;global_step&#39;: 120000, &#39;loss&#39;: 0.042456727}</pre><p>Accuracy greater than 99% — not bad at all! The neural network was clearly better suited to predicting March Madness performance than the Random Forest and Stochastic Gradient Descent classifiers. To determine which teams would make deep runs, I trained the neural to report on which teams would have a WAS greater than 2:</p><pre>y_gt2=(y&gt;2)<br>yi=y_gt2.astype(int)<br>dnn_clf.evaluate(XTrain, yi)<br>&gt;{&#39;accuracy&#39;: 1.0, &#39;global_step&#39;: 200000, &#39;loss&#39;: 0.0007399367}</pre><p>That 100% accuracy isn’t THAT impressive when you consider that fewer than 3% of all teams have a WAS of 3 or more in the past 8 years (the record holder is Philadelphia 76er end of the bench legend <a href="https://en.wikipedia.org/wiki/Kevin_Ollie">Kevin Ollie</a>’s National Championship UConn team in 2014, with a WAS of +5). That being said, let’s find out which underrated teams the model predicts will make a deep run this year by running the data for this year’s March Madness teams through the neural network. Having already read another csv file with this year’s data into a numpy array called XTrain2018, I ran it through the neural network:</p><pre>pred_rslt=list(dnn_clf.predict(XT2018))</pre><p>I then looped through the resulting pred_rslt array to find the index of the teams expected to have a WAS greater than 2:</p><pre>[i <strong>for</strong> i, e <strong>in</strong> enumerate(pred_rslt) <strong>if</strong> e != 0]<br>&gt;[0, 9, 28]</pre><p>The teams the algorithm expected to do well were the ones at index 0, 9 and 28 in my test data. In order to quickly find which teams the neural network was predicting, I created a list to store this year’s March Madness team names in index order:</p><pre>bd2018=pd.read_csv(&quot;/home/liangd/cbb_2018.csv&quot;)<br>Tbd2018=bd2018[&quot;Team&quot;]</pre><p>Now it was time to see these teams:</p><pre>Tbd2018[0]<br>&#39;Virginia&#39;</pre><p>Whoa! Virginia is the first overall seed, and yet the neural network still predicts that it will make a deep run. Clearly, the neural network was trained only using previous seasons’ data, and is unaware of <a href="http://www.espn.com/mens-college-basketball/player/_/id/4065732/deandre-hunter">DeAndre Hunter’s</a> <a href="http://bleacherreport.com/articles/2764254-virginias-deandre-hunter-to-miss-ncaa-tournament-after-suffering-wrist-injury">unfortunate injury</a>. Nonetheless, as a graduate of Mr. Jefferson’s University, this result made me thrilled (and a bit worried that maybe… just maybe… Google may be feeding data about me into it’s TensorFlow libraries).</p><p>Let’s see the other teams:</p><pre>Tbd2018[9]<br>&#39;Tennessee&#39;<br>Tbd2018[28]<br>&#39;Purdue&#39;</pre><p>The neural network also likes Tennessee, which is (uncomfortably for me) in the same bracket as UVA, and Purdue, an underrated second seed that nobody seems to be picking to go far. I continued training the neural network to identify teams that correspond to different conditions (i.e. WAS greater than 0, greater than 1, less than 0, less than -1, less than -2). I also re-trained on the same conditions a few times, since the results would change slightly each time I trained the neural network. Each training run resulted in an accuracy greater than 98%.</p><p>Here are 10 things I noticed in the predictions:</p><ol><li>The neural network REALLY likes UVA. It was always consistently a +1 or +2 team and was among the most highly rated teams. There was no bias on my part here in training the neural net (though, once again, I’m starting to question how much Google really knows about me and whether it has customized the TensorFlow libraries I downloaded…)</li><li>Purdue was repeatedly predicted as a top team. They boast a VERY high effective field goal percentage (58.1%) one of the highest block rates in the tourney (12.8%), and a high assist rate (59.3%). The type of teams that do better than their seed tend to combine stingy defense with efficient offense, all while sharing the ball and having multiple players who can come through in the clutch.</li><li>Everyone’s upset favorite, Arizona, had the widest range of predicted WAS, consistently ranging between a +1 and a -2. That’s the difference between upsetting UVA and making the Elite Eight, and losing in the first round to Buffalo. It seems oddly appropriate that a team so reliant on a single freshman superstar would end up all over the place in predictions. If Arizona basketball were a stock, I’d be trading it with an options spread right about now.</li><li>The neural network really liked two 7 seeds, Nevada and University of Rhode Island. Both teams are among the lowest in turnover percentage, which seems to be a necessity for lower seeded teams that want to make a big run, and like previous March Cinderellas boast a higher than average block rate (see Oregon and South Carolina in last year’s tourney).</li><li>There is one team the neural network consistently dislikes, rating it as lower than -2 in almost every prediction: Cincinnati. Cincinnati is also the 2 seed that could face Nevada in the 2nd round. If you’re the gambling type (as I <a href="https://www.youtube.com/watch?v=aWFRnffCA4A">sometimes am</a>), hmm…</li><li>Other teams the neural network consistently expects to underperform: Auburn, Wichita State and Texas Tech. All 3 teams combine a lower than average effective field goal percentage with a higher than average turnover rate — not a great recipe for postseason success. Auburn, Wichita State and Texas Tech are also 4, 4, and 3 seeds respectively, positions where teams often don’t make the Sweet 16.</li><li>Kansas and Villanova were the neural network’s least favorite 1 seeds, with some predictions having them as low as -3, a loss in the second round. UNC was consistently predicted with a -1, corresponding to a loss in the Sweet 16.</li><li>Missouri consistently ranked as -1 or +1, corresponding to an upset of Xavier in the second round or a first round loss. There was no data to reflect this, but Missouri truly seems like the wild card of the tournament to me: with <a href="http://www.espn.com/mens-college-basketball/player/_/id/4278104/michael-porter-jr">Michael Porter Jr</a> back in action, who knows how far they can go?</li><li>Among the lower seeds, 12th seeded South Dakota State was the only team to consistently have a positive WAS in the predictions.</li><li>West Virginia and Florida would occasionally pop up in the predictions as teams that could make deep runs with WAS of 2 or more — while rarely showing up as teams that could make a run with a WAS of 0 or 1. These seem like high risk high reward teams that are worth a bet on some Sweet 16 or Elite 8 futures.</li></ol><p>In light of all these (and some additional) predictions, my final bracket has Virginia, Gonzaga, Michigan State and Purdue in the Final Four, with Virginia triumphing over Purdue in the National Championship game. Whenever my neural network is unclear on the predictions, I simply choose the higher seeded team (under the proven belief that for the most part, the NCAA Selection Committee does a pretty good job). My full bracket is shown below, but then I decided to do one last experiment… so keep reading to learn more…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*k8I-416qtFL6SCdxBEn99A.png" /></figure><h3><strong>… one last experiment…</strong></h3><p>Since most websites allow you to submit multiple brackets, I decided to try to complete a bracket based on training the neural network to do multiclass classification; that is, a neural network that not only predicts whether a given team can make it past a certain Wins Above Seeding value, but that predicts the exact WAS value a team will have. After multiple rounds of training and a lot of steps, this neural network was also able to reach a accuracy greater than 99% on the previous 8 years’ training data:</p><pre>dnn_clf.fit(x=XTrain, y=(y+3), batch_size=50, steps=2000000)<br>dnn_clf.evaluate(XTrain, (y+3))<br>&gt;{&#39;accuracy&#39;: 0.9921875, &#39;global_step&#39;: 1320000, &#39;loss&#39;: 0.059503354}</pre><p>Note that this time, I’m training the neural network to output data after adding 3 to the original WAS data; this is because the neural network expects to work on data ranging from 0 to 9 (corresponding to the 10 neurons in the softmax output layer I defined earlier), once training was done I shifted the resulting output by -3 to get the data back in the original format.</p><p>These predictions were drastically different! UVA was suddenly given a WAS of -3, a second round loss! Vanderbilt also consistently showed up as a second round upset, and Lipscomb was predicted to advance 2 rounds past it’s seeding — a 15 seed making the Sweet 16! The multiclass neural network continued to expect Nevada to make a deep run, predicts an early upset for Cincinnati, foresees an early out for Arizona, and expects Missouri to pull off a second round upset. It also likes West Virginia and Gonzaga’s chances, and also predicted that both Duke and Michigan State would make deep runs (which doesn’t help us much since those two teams would theoretically meet in the Sweet 16).</p><p>This (rather different) bracket is shown below, with a Final Four of Duke, Purdue (there they are again!), Michigan, and Kentucky, with Duke triumphing over Michigan in the National Championship game. I ended up entering this bracket in a different Tournament Challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*MBXIzfA4GBFgEDSGi7du9A.png" /></figure><h3><strong>Final Thoughts</strong></h3><p>The beauty of March Madness is it’s unpredictability. In the end, we’re watching a bunch of young college kids play basketball while figuring out who they are. I know that when I was their age, I certainly… made some unpredictable immature decisions in the process of figuring myself out (I’m in my thirties and am STILL known to make immature decisions on occasion, like staying up late on a work night to train neural networks to predict the outcomes of games involving throwing an orange ball through a hoop). The unpredictability is all part of the fun, and no amount of TensorFlow and GPU optimization will take that away.</p><p>That’s why no matter what the algorithms say, I will continue to cheer for, defend against haters (no, <a href="https://www.theringer.com/2018/3/13/17112824/virginia-cavaliers-ncaa-tournament-tony-bennett">great defense ISN’T boring</a>!), and bet on the University of Virginia Cavaliers, my alma mater. Seeing UVA and the Charlottesville community bravely <a href="https://www.npr.org/2017/08/17/544081108/glow-from-candlelight-vigil-in-charlottesville-lights-up-uva-campus">stand up to racism</a> last year makes it all the more rewarding to cheer them on. In closing, all I want to say is: <a href="https://www.youtube.com/watch?v=uiS0eauDmHA">Wa-hoo-wa Vir-gin-i-a!</a></p><p>PS. Here’s that stats scraping Perl script I promised earlier.</p><p>#!/usr/bin/perl</p><p>my $IND=2017;</p><p>while($IND&gt;2009) {</p><p>open($IFILE, “&lt;”, “$IND”);</p><p>open($OFILE, “&gt;&gt;”, “result.txt”);</p><p>while(&lt;$IFILE&gt;){</p><p>if($_=~”NCAA”){</p><p>@my_array=split/\s/, $_;</p><p>if(@my_array[2] =~ “NCAA”){</p><p>$offset=2;</p><p>$team_name=”@my_array[1] $IND”;</p><p>}</p><p>if(@my_array[3] =~ “NCAA”){</p><p>$offset=3;</p><p>$team_name=”@my_array[1] @my_array[2] $IND”;</p><p>}</p><p>if(@my_array[4] =~ “NCAA”){</p><p>$offset=4;</p><p>$team_name=”@my_array[1] @my_array[2] @my_array[3] $IND”;</p><p>}</p><p>$WL_offset=$offset+4;</p><p>$WL=@my_array[$WL_offset];</p><p>$SRS_offset=$offset+5;</p><p>$SRS=@my_array[$SRS_offset];</p><p>$SOS_offset=$offset+6;</p><p>$SOS=@my_array[$SOS_offset];</p><p>$PACE_offset=$offset+16;</p><p>$PACE=@my_array[$PACE_offset];</p><p>$ORTG_offset=$offset+17;</p><p>$ORTG=@my_array[$ORTG_offset];</p><p>$TOV_offset=$offset+26;</p><p>$TOV=@my_array[$TOV_offset];</p><p>$ORB_offset=$offset+27;</p><p>$ORB=@my_array[$ORB_offset];</p><p>$TS_offset=$offset+20;</p><p>$TS=@my_array[$TS_offset];</p><p>$SR_offset=$offset+23;</p><p>$SR=@my_array[$SR_offset];</p><p>$BR_offset=$offset+24;</p><p>$BR=@my_array[$BR_offset];</p><p>$RR_offset=$offset+21;</p><p>$RR=@my_array[$RR_offset];</p><p>$FTR_offset=$offset+18;</p><p>$FTR=@my_array[$FTR_offset];</p><p>$TPAR_offset=$offset+19;</p><p>$TPAR=@my_array[$TPAR_offset];</p><p>$AP_offset=$offset+22;</p><p>$AP=@my_array[$AP_offset];</p><p>$EF_offset=$offset+25;</p><p>$EF=@my_array[$EF_offset];</p><p>printf $OFILE “$team_name,$WL,$SRS,$SOS,$PACE,$ORTG,$FTR,$TPAR,$TS,$RR,$AP,$SR,$BR,$EF,$TOV,$ORB”;</p><p>printf $OFILE “\n”;</p><p>}</p><p>}</p><p>$IND=$IND-1;</p><p>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e5ee562eab1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/re-hoop-per-rate/training-a-neural-network-to-fill-out-my-march-madness-bracket-2e5ee562eab1">Training a Neural Network to fill out my March Madness Bracket</a> was originally published in <a href="https://medium.com/re-hoop-per-rate">re-HOOP*PER-rate</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>