<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eric Schmidt on Medium]]></title>
        <description><![CDATA[Stories by Eric Schmidt on Medium]]></description>
        <link>https://medium.com/@easchmidt?source=rss-d4825e516474------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mSGuIScifij7ive_.jpg</url>
            <title>Stories by Eric Schmidt on Medium</title>
            <link>https://medium.com/@easchmidt?source=rss-d4825e516474------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:36:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@easchmidt/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[That Got Weird, Fast. And Yet, So Slow…]]></title>
            <link>https://medium.com/analyzing-ncaa-college-basketball-with-gcp/that-got-weird-fast-and-yet-so-slow-d6f46ab88b46?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6f46ab88b46</guid>
            <category><![CDATA[ncaa-tournament]]></category>
            <category><![CDATA[outliers]]></category>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[sports]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Sun, 07 Apr 2019 06:34:05 GMT</pubDate>
            <atom:updated>2019-04-07T06:34:55.340Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://cloud.google.com/blog/products/data-analytics/let-the-queries-begin-how-we-built-our-analytics-pipeline-for-ncaa-march-madness">Building projections is fun</a>, especially when the numbers hit. But when things go wrong? Let’s just call it a different kind of fun — the kind where you take your hands off the keyboard and throw them up in the air because none of the numbers land as expected. Texas Tech vs. Michigan State was that kind of fun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/0*QyOnTAfgaBHQtIlj.jpg" /></figure><p>March Madness occasionally turns out an outlier game of epic proportions (just ask Virginia last year), and the Spartans vs. the Red Raiders offered a leading candidate for this year’s wacky anomaly. There are a lot of ways to slice how exceptional this game was for these two teams and in the men’s tournament in general, but we’re going to dig in using one of our pre-game predictions as a wedge.</p><p>Knowing that both Texas Tech and Michigan State play relatively slow games (ranked 249th and 189th slowest in the NCAA), and neither team relies much on their three-point game (ranked 284th and 211th, respectively, on three-point shot attempts), we focused on two-point attempts instead. We estimated a combined 69 attempts, with a probability of 71.1% that we’d see at least 64. We saw <em>51</em>.</p><p>The absurdly low numbers get even lower and more absurd from there.</p><p>If you managed to stay awake during this slogfest, congratulations. There were <em>only 117 possessions</em> — we had estimated 130. You don’t need a fancy SQL query to figure out that that means there were fewer than 60 possessions per team — an astoundingly low number. To put it in perspective, Virginia is the slowest paced team in the NCAA and even <em>they</em> average 60 possessions per game. This semifinal was slower than Virginia playing itself.</p><p>Few possessions plus potent defenses yields pretty low scores. The first half ended with a nadir of 23–21 — the lowest scoring Final Four first half in 19 years (Wisconsin vs. Michigan State in 2000 holds that record: 19 to 17). For more perspective on how unexpected this was, Vegas odds listed the first half total at 62. It came in at 44. And while the game picked up a bit in the second half, the numbers were still way off the mark for everyone predicting on this sort of thing: Vegas had the game total at 133 with Michigan State favored by 2.5; we had the game total at 137 with Michigan State favored by 3; the final combined score was 111 and Texas Tech won 61–51. Vegas almost never misses this big. (FiveThirtyEight had Michigan State at 54% win probability, and ESPN’s BPI had Michigan State at 61.1% win probability.)</p><p>The potential for slow pace and low score were there, of course — both <a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp/a-final-four-cast-5be814ca1ebd">teams are strong on defense</a>. But the perfect storm (or calm) of Saturday night had more to do with Michigan State’s offensive meltdown than anything else. Coming into the game Michigan State was ranked fourth in the NCAA in offensive efficiency. They also had the second highest effective FG percentage (58.8%), and were shooting 48.8% from the field. But they finished the game shooting 31.9%.</p><p>One problem was turning the ball over (which becomes a much bigger issue in a game with fewer possessions), but the more noteworthy source of their troubles might have been their lack of assists. The Spartans are third in the NCAA in assists, with 18.6 per game. On Saturday, they had six.</p><p>You might imagine that a team that isn’t able to connect from the field (nor with their teammates) might start taking more three-point shots. And that’s what Michigan State did — going 7 for 24 behind the arc. It may not seem like much — 24 attempts on the night instead of their season average of 21.5 doesn’t sound too outlandish — but it was enough to put them close to the 75th percentile.</p><p>Meanwhile, Texas Tech found itself in a somewhat similar situation when faced with Michigan State’s defense. They <em>also</em> attempted near the 75th percentile of their three-point average compared to the season. But where the Spartans only made 29% of their three-point shots, the Red Raiders made 39% and went 9 for 23 on the night (incidentally, the same three-point numbers they put up against Gonzaga).</p><p>These aren’t remarkable three-point numbers in and of themselves. But they are interesting for two reasons: first, because there were so few possessions, field goals were held to a minimum, and both teams started to go long more than usual. And second, because Michigan State is nominally the more frequent three-point shooting team, the combination of Texas Tech stepping up their three-point production while Michigan State’s offense collapsed in the face of those scarce and stifling possessions of this game, we might just glimpse a slightly clearer picture of this strange and slow game through our bleary eyes.</p><p>So what can we learn from all this? Sometimes things just don’t go according to plan, especially when humans are involved (like, say, in a basketball game played by student athletes). But it’s also helpful to learn <em>what we learned</em> — which is everything we dissected during and after the game and discussed above. We couldn’t have done this without quality data, and by having it, we were able to put some of the pieces of this game together after watching it crash down over 40 agonizingly slow minutes. (And for what it’s worth, it wasn’t just Michigan State and Texas Tech that had an unusually low-scoring game: Saturday was the first Final Four semifinal day in which all four teams failed to surpass 65 points in the shot clock era. Just another fun fact brought to you by fast data analysis.)</p><p>Now that we know what Texas Tech can do with a slow-paced game, Virginia might just need to watch its back. So brace yourselves and caffeinate well: we’ll see you for Monday’s ice-cold glacier match. (We’re pretty darn sure.)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6f46ab88b46" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp/that-got-weird-fast-and-yet-so-slow-d6f46ab88b46">That Got Weird, Fast. And Yet, So Slow…</a> was originally published in <a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp">Analyzing NCAA Basketball with GCP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Slippery Slider Slope]]></title>
            <link>https://medium.com/baseballongcp/a-slippery-slider-slope-afb1d59e0a15?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/afb1d59e0a15</guid>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[world-series]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Mon, 29 Oct 2018 00:10:38 GMT</pubDate>
            <atom:updated>2018-10-29T00:21:16.777Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Note: special thanks to co-author </em><a href="https://twitter.com/SteveSandmeyer"><em>Steve Sandmeyer</em></a><em> aka Sandy</em></p><p>Welcome to game 5 as we as we continue our analysis of the <a href="https://medium.com/baseballongcp">World Series using Google Cloud</a>. After an epic comeback in game 4, the Boston Red Sox have taken a commanding 3–1 series lead and are one win away from their fourth World Series Championship the last 14 years.</p><p>Boston will give the ball to left-hander David Price, who earned the victory in game two by going 6 innings, allowing just 3 hits, 2 earned runs and striking out 5. Price also appeared in relief in the 18-inning marathon in game three, throwing 13 pitches in ⅔ of an inning in which he allowed a hit and a walk but no runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/0*Ew1G-nSmQArSjW8Y" /><figcaption>Kershaw doing his thing</figcaption></figure><p>Los Angeles is hoping their own left-hander Clayton Kershaw will fare better than he did in game one, a start in which he didn’t make it out of the fifth inning and was ultimately charged with 5 earned runs in 4-plus innings. Many analysts feel it was because his slider was flat and too closely resembled his fastball for Boston’s hitters.</p><p><a href="https://www.usatoday.com/story/sports/mlb/2018/10/28/clayton-kershaw-dodgers-world-series-game-5/1795760002/"><em>It (slider) was flat again against the Red Sox, and their disciplined hitters wisely laid off his curveball and noshed on his fastball in peppering him for seven hits over four-plus innings.</em></a></p><p>Even Kershaw himself acknowledged the issue:</p><p><a href="https://www.usatoday.com/story/sports/mlb/2018/10/28/clayton-kershaw-dodgers-world-series-game-5/1795760002/"><em>“Definitely working on it,” he said of his slider. “Definitely trying to make it better. I focused on it. My bullpen focused on it, playing catch. I hope it’s better tomorrow.”</em></a></p><pre>sl_stats  = pitches[pitches[&quot;pitch_type&quot;]== &quot;SL&quot;]<br>            .groupby(&quot;game_date&quot;)<br>            .agg({ &#39;launch_speed&#39;:[&#39;mean&#39;, &#39;std&#39;]<br>                    , &#39;start_speed&#39;:[&#39;mean&#39;, &#39;std&#39;]<br>                    , &#39;break_angle&#39;:[&#39;mean&#39;, &#39;std&#39;]<br>                    , &#39;break_length&#39;:[&#39;mean&#39;, &#39;std&#39;]}).reset_index()</pre><p>Simply put, if Kershaw can’t rediscover the movement and location of his slider, it could be a short outing for him, which could make for a long night for Dodger fans at Chavez Ravine. So what can the data tell about how the Red Sox fare against the slider in particular — and in which specific counts?</p><p>Let’s look at some data. For starters (no pun) — how flat was flat?</p><p>Note: <a href="https://medium.com/baseballongcp/mad-max-b1a9666c7124">If you want to get more into how we got here using Google Cloud — check out this post</a>.</p><p>When looking at Kershaw’s appearances for 2018 you can see that velo, break angle and speed were down in WS game 1 AND he got hammered relative to launch speed (and also outcome).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/0*tbzfbG6yBvbvaWSX" /></figure><p>The numbers are hard parse, but if we do a quick correlation test you see that there is moderate relationship between launch speed and break angle — so yes Kershaw was bit flat — his slider too closely resembled a fastball — and the Red Sox were able to take advantage of the situation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/0*wZMnAbeWUIeLpSxq" /></figure><p>How good are the Red Sox at hitting the slider? The second highest batting average and third highest slugging percentage — albeit on sliders not as fast and/or nasty as Kershaw’s on average IF (a big if) he’s back to his normal form. Safe to say if Kershaw regresses, the Red Sox will be ready to pounce</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/0*rsRV6c30rFX0EBMa" /></figure><p>It seems just about everyone is feeling a bit flat after the grueling weekend of baseball and the rest of the real world happenings… let’s have a great game tonight and we hope to see the return of the Kershaw we all know and love — if for any reason to extend the series between two great teams.</p><p>NOTE: <a href="https://pantheon.corp.google.com/marketplace/details/sportradar-public-data/mlb-pitch-by-pitch">You can hack on similar data in BiqQuery by heading over to our public datasets</a> hosted on Google Cloud. After the World Series we will post new data from 2018.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afb1d59e0a15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/baseballongcp/a-slippery-slider-slope-afb1d59e0a15">A Slippery Slider Slope</a> was originally published in <a href="https://medium.com/baseballongcp">baseballongcp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mad Max]]></title>
            <link>https://medium.com/baseballongcp/mad-max-b1a9666c7124?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1a9666c7124</guid>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[baseball]]></category>
            <category><![CDATA[google-cloud]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Sat, 27 Oct 2018 23:27:50 GMT</pubDate>
            <atom:updated>2018-10-27T23:36:23.831Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Note: special thanks to co-author </em><a href="https://twitter.com/SteveSandmeyer"><em>Steve Sandmeyer</em></a><em> aka Sandy</em></p><p>We’ve reached game four of the Fall Classic as we continue our analysis of the <a href="https://medium.com/baseballongcp">World Series using Google Cloud</a>. The Dodgers are within a game in a 2–1 series after an epic game 3 win in a tidy 7 hours, 20 minutes and 18 innings of play. If it seems like the game just ended a half hour ago, it’s probably because it did. Boston is still in the driver’s seat — and by winning the next two games in L.A. — can claim another crown to join the 1903, 1912, 1915, 1916, 1918, 2004, 2007 and 2013 championship teams. Los Angeles has momentum — and if they can tie the series at two games apiece — game 5 in Dodger Stadium will become a super-charged atmosphere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/0*cIFJgjsMvn8V_mBU" /><figcaption>Muncy dog pile</figcaption></figure><p>Now that the jail sentence of game 3 has been served, what will each team do in terms of starting pitching? Nathan Eovaldi (BOS) — the scheduled game 4 starter — was pressed into action last night (earlier this morning?). Eovaldi threw 97 pitches in 6-plus innings of work and is not an option to start game 4. Instead, it will be Eduardo Rodriguez (BOS) vs Rich Hill (LAD) in a battle of southpaws.</p><p>For this post we reuse our existing <a href="https://medium.com/baseballongcp/magic-count-with-a-bigquery-d0cd478ef774">BigQuery views for pitcher analysis</a> to look at individual batter metrics and build a hot zone visualization, specifically for Max Muncy — as such we depart SQL land and jump into iPython for some deeper wrangling.</p><pre>%load google.cloud.bigquery</pre><pre>&#39;&#39;&#39;<br>- I now have access to BigQuery via magic cell syntax.<br>- This enables me to push down my aggregations across all pitches.<br>- In this case I want to extract slash line stats, but also <br>create a density plot of strike zone hit locations.<br>- BiqQuery pipes response rows directly to a pandas dataframe. From there we are off to the races...<br>&#39;&#39;&#39;</pre><pre>%%bigquery pitches<br>SELECT <br>  sched.year,<br>  season,<br>  in_play,<br>  sz_top,<br>  sz_bottom,<br>  loc_x,<br>  is_pa,<br>  total_bases, <br>  ...<br> FROM<br>      `**.tensorpitch.mlb_pbp` AS pitch<br>    LEFT JOIN (<br>      ... ) AS features<br>    ON<br>      game_id = pitch.game_id<br>WHERE <br>  year in (2018)<br>  AND type = &quot;P&quot;<br>  AND in_play = 1<br>  AND is_pa_over = 1<br>  AND hitter = &quot;Mad Max&quot;</pre><pre>hr = pitches[&quot;total_bases&quot; == 4]<br>hr.groupby(&quot;pitch_type).agg(...)<br>... <br># build awesome hot zone graphic</pre><p>Let’s look at some data.</p><p>Baseball has a way of highlighting previously unknown players on a big stage. Last night’s game winning home run was hit by Max Muncy. <a href="https://www.washingtonpost.com/sports/2018/10/14/max-muncy-once-nearly-out-baseball-helps-lift-dodgers-with-his-super-quick-hands/?utm_term=.1c8e23df9781">Muncy is a remarkable story</a> — and pretty much came out of nowhere to hit a whopping 35 home runs in only 395 at bats during the regular season. He is a 28-year old who was cut by the Oakland A’s last year during spring training. He was unemployed for a month — with no team bothering to give him a look. Then the Dodgers signed him to a minor league deal and put him in triple-A for the entire 2017 season — and that’s where he started the 2018 season as well — before the Dodgers called him up in mid-April.</p><p>Now that Muncy can add winning a World Series game to his list of amazing accomplishments this season, let’s take a closer look at the data to see when, where, and how he has been successful at the plate. For starters, Muncy hit a cutter out of the park to win it in the 18th. He referenced his previous at bat against Boston’s Nathan Eovaldi to ground himself in the idea he might see the same pitch.</p><p><a href="https://www.usatoday.com/story/sports/mlb/dodgers/2018/10/27/world-series-los-angeles-dodgers-max-muncy-hero/1788226002/"><em>“The at-bat before, he had got me on a really good backdoor cutter. He had really good stuff all night long and he wasn’t missing a spot. Next at-bat he tried to go backdoor cutter again, but he left this one a little over the plate, and thankfully for me he did that, because I was able to get my bat to it.’’</em></a></p><p>A closer look at the data gives us a good idea about what Muncy prefers to see. Although small population size, he likes the hard stuff including cutters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/0*ZB7va_euDR8ikPxe" /><figcaption>(2018 REG ONLY — ranks are ordinal, lower is better, compared to all players)</figcaption></figure><p>Count wise he thrives on 0–0, 0–1, 1–1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/0*jgXWKVdmQ7keS97L" /><figcaption>(2018 REG ONLY — minimum of 20 counts faced, ranks are ordinal, lower is better, compared to all players)</figcaption></figure><p>Location wise his sweet is spot just off center inside; however, he trends towards outer slightly up. Baseball is a funny game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/0*cIxb5kFlqg1yRO_4" /><figcaption>Pitch location (normalized to batter’s strike zone) for all triples and home runs for Max Muncy (2018 REG)</figcaption></figure><p>Muncy homered on pitch number 7 facing a 3–2 count. His third pitch was a cutter, a ball middle away. He went on to foul two pitches #5 (cutter) and #6. Eovaldi made very few mistakes in his 97 last night pitches. Pitch #7 was outer middle — enough for him to get solid contact — a 90.1MPH cutter (FC).</p><p>The Dodgers are desperately seeking offense, even as they only need one more win tonight to even the series at two games apiece. Can Muncy come to the rescue again? Perhaps only if Boston makes a mistake against him one more time…</p><p>NOTE: <a href="https://pantheon.corp.google.com/marketplace/details/sportradar-public-data/mlb-pitch-by-pitch">You can hack on similar data in BiqQuery by heading over to our public datasets</a> hosted on Google Cloud. After the World Series we will post new data from 2018.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1a9666c7124" width="1" height="1" alt=""><hr><p><a href="https://medium.com/baseballongcp/mad-max-b1a9666c7124">Mad Max</a> was originally published in <a href="https://medium.com/baseballongcp">baseballongcp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Buehler Can’t Have a ‘Day Off’]]></title>
            <link>https://medium.com/baseballongcp/buehler-cant-have-a-day-off-c3e1c1776fac?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3e1c1776fac</guid>
            <category><![CDATA[world-series]]></category>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Fri, 26 Oct 2018 23:30:15 GMT</pubDate>
            <atom:updated>2018-10-26T23:42:24.693Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Note: special thanks to co-author </em><a href="https://twitter.com/SteveSandmeyer"><em>Steve Sandmeyer</em></a><em> aka Sandy</em></p><p>Game 3 is upon us as we continue our analysis of the <a href="https://medium.com/baseballongcp">World Series using Google Cloud</a>. Can the Dodgers make a series out of it? Or will the Red Sox win at least 2 of 3 in L.A. this weekend to clinch their fourth World Series title in the last 14 years? Pitching matchups are always a good place to start.</p><p>NOTE: <a href="https://pantheon.corp.google.com/marketplace/details/sportradar-public-data/mlb-pitch-by-pitch">You can hack on similar data in BiqQuery by heading over to our public datasets</a> hosted on Google Cloud. After the World Series we will post new data from 2018.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*yNFJ9SJvghCakY-O" /><figcaption>We’d be remiss to not reuse a played out Walker meme….</figcaption></figure><p>Tonight, veteran Rick Porcello (BOS) takes on youngster Walker Buehler (LAD) in Dodger Stadium. In terms of experience, Porcello is a decorated Major League starter. He’s a 10-year veteran, a former Cy Young Award winner (with BOS in 2016), and has pitched in six different postseasons (3 with DET and 3 with BOS). Buehler, meanwhile, is a Major League rookie, who made his big league debut by logging 9.1 innings as a 22-year old last season. This year, he started 23 games and logged 137.1 IP in his first full season as a 23-year old.</p><p>For this post we decided to stay in pure SQL land, reusing some over views we built in our last post on just how much the <a href="https://medium.com/baseballongcp/magic-count-with-a-bigquery-d0cd478ef774">Red Sox dominate 2–2 counts</a>. Skill #1 in software and data engineering is copy and paste! And it turns out we were able to easily convert our count analysis into pitch type analysis by changing a few lines of code in BigQuery.</p><pre>SELECT</pre><pre>*,</pre><pre>RANK() OVER(PARTITION BY pitch_type ORDER BY BA ASC) as opp_BA_rank,</pre><pre>RANK() OVER(PARTITION BY pitch_type ORDER BY OBP ASC) as opp_OBP_rank,</pre><pre>RANK() OVER(PARTITION BY pitch_type ORDER BY SLG ASC) as opp_SLG_rank</pre><pre>FROM</pre><pre>(… AWESOME UNDERLYING VIEW THAT CALCULATES STATS FOR EVERY PITCH …)</pre><p>We also had to tweak some columns to account for perspective, specifically opponent’s metrics vs. hitting team’s metrics. A bit of coffee and some SQL wrangling and we have some fun data to look at for game 3 between Buehler and Porcello.</p><p>While Porcello has been a known commodity for years, what can we learn from Buehler’s first full season and how might his stuff play against the dangerous Red Sox lineup? For starters, Buehler is essentially a four pitch (fastball variant) guy — fastball (4-seam, 2-seam), knuckle-curveball, slider, cutter — with an occasional change</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_e9gEZkxuyRHkCwh" /><figcaption>(2018 REG — MIN 20 PA)</figcaption></figure><p>He is a power pitcher with good ancillary stuff. Buehler struck out 151 hitters in just 137.1 innings pitched during the regular season. He started game 7 of the NLCS against Milwaukee and struck out 7 in just 4.2 IP as the Dodgers went on to win the pennant with a 5–1 victory.</p><p>How does this stack up against the Red Sox in term of pitch type?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/0*hJa2js-lSlvUByiH" /><figcaption>(2018 REG)</figcaption></figure><p>The Red Sox hold twelve top 5 ranks across BA, OBP and SLG with their only main “weakness” on two seam fastballs, which is Buehler’s second best weapon (weighing frequency).</p><p>Now let’s turn to count analysis. How does Buehler fare relative to count?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1XDsou0eVU7d4Efr" /><figcaption>(2018 REG — MIN 20 PA)</figcaption></figure><p>Buehler’s best rank (weighting frequency) is when the batter puts it in play on the first pitch of the at bat (opp BA on 0–0). He is middle of the road at 0–2 and is slightly more vulnerable at 1–1. Keep in mind the delta in these ranks are razor thin, in the top 50 they are separated by .001 percent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o9YhiW2KUo_ptoBm" /><figcaption>(2018 REG)</figcaption></figure><p>Nerd wise, the next step is to cross these views, specifically looking at count and pitch type pairing and of course you can add more dimensions like time and score situation. At the end of day you could build one huge matrix for every pitch or you could just sit back and watch the game ;-)</p><p>The game of baseball is played in much more compressed style in the postseason and during the World Series. Every pitch and every pitch sequence matters. A pivotal weekend in Los Angeles begins tonight, as the host Dodgers are desperate to make a series out of this. Boston has been murderous at the plate in almost any situation. It would help if the Dodgers would hit a little bit too. Maybe we should write a post on that subject — if the series isn’t over before we have the chance…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3e1c1776fac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/baseballongcp/buehler-cant-have-a-day-off-c3e1c1776fac">Buehler Can’t Have a ‘Day Off’</a> was originally published in <a href="https://medium.com/baseballongcp">baseballongcp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Magic Count with a BigQuery]]></title>
            <link>https://medium.com/baseballongcp/magic-count-with-a-bigquery-d0cd478ef774?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0cd478ef774</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[world-series]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Wed, 24 Oct 2018 23:02:27 GMT</pubDate>
            <atom:updated>2019-07-08T15:10:28.162Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Note: special thanks to co-author </em><a href="https://twitter.com/SteveSandmeyer"><em>Steve Sandmeyer</em></a><em> aka Sandy</em></p><p>Welcome to Game Two of the Fall Classic. Baseball can be a funny game. Prior to the series starting, everyone got into a lather <a href="https://medium.com/baseballongcp/kershaw-curve-vs-sale-slider-f50097de17c2">(including us)</a> over the “epic” game one pitching matchup between Clayton Kershaw (LAD) and Chris Sale (BOS). The result? Neither ace got out of the fifth inning and a total of 12 runs were scored as Boston opened the series with an 8–4 victory.</p><p>In this post we continue our analysis of the <a href="https://medium.com/baseballongcp">World Series using Google Cloud</a> with a focus on hitting and a little tool called BigQuery and our lingua franca SQL.</p><p>The Red Sox cruised to a 108-win regular season and a Major League best 5.4 runs per game. They’ve been plating runs even more frequently during the postseason (10 games), outscoring opponents 64 to 39 so far — with a whopping 32 of those runs scoring with 2 outs. Try to sneak a fastball by them? Good luck. Mookie Betts hit .384 vs the fastball this season, ranking second in all of Major League Baseball. JD Martinez hit .366 vs the fastball, ranking third. (Interesting note: the other dugout has the baseball’s<em> best</em> hitter against the fastball: Matt Kemp of the Dodgers, who hit .388 vs the fastball, and homered in the second inning of last night’s game on — you guessed it — a fastball).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*J_LnV6dEIkRR0Sck" /><figcaption>The Count loves numbers especially the number 1</figcaption></figure><p>With runners in scoring position, the Red Sox slashed .289/.379/.493 during the regular season. The .289 BA and .379 OBP were tops in baseball. But they are making a mockery of that in the playoffs, slashing an absurd .365/.461/.647 with RISP thus far. Boston’s offensive romp through the playoffs thus far has been nothing short of majestic.</p><p>There are many ways to define “best”: runs scored, batting average, etc. However, for our analysis, instead of looking at traditional top line stats, we have been looking at more specific situational metrics — count specific for example. We already know Boston has the best offense in baseball — but <em>where</em> do they inflict the most damage? In which situation?</p><p><strong>Is there a “magic count?” and where might the players and team rank against others based on count?</strong></p><p>For this analysis, we needed actionable pitch level data to create traditional stats like batting, slugging and on-base percentages, but specifically at the count level where the action occurs. Baseball is not a big data problem, but it is also not a small data problem. Wrangling 2.5 GB of data on a laptop, say in pandas, is not very efficient. So for this use case, we are using BigQuery to help execute transformations and push down all of the needed aggregations.</p><p>NOTE: <a href="https://console.cloud.google.com/marketplace/details/sportradar-public-data/mlb-pitch-by-pitch">You can hack on similar data in BiqQuery by heading over to our public datasets hosted on Google Cloud</a>. After the World Series we will post new data from 2018.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/0*lgL6jnyLCAyBYUK_" /></figure><p>The rows in this table (this is my project) contain the thumbprint for every pitch in the regular and postseason since 2015. With this data we can create stats relative to game context. Building these game state stats typically require ordering and for that we can employ standard SQL techniques like partitioning to create ordinal sequences like current count.</p><pre>SELECT</pre><pre>*,</pre><pre>MAX(CONCAT(CAST(balls AS STRING), “-”, CAST(strikes AS STRING))) OVER(PARTITION BY sched.game_id, inning, half_inning, hitter_id ORDER BY pitch_number ASC ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS starting_count_raw,</pre><pre>ROUND(IF(ab&gt;0, hits/ab, 0), 3) as BA,</pre><pre>ROUND((hits + bb + hbp)/(ab + bb+ hbp + sac),3) as OBP,</pre><pre>ROUND(IF(ab&gt;0, total_bases/ab, 0), 3) as SLG</pre><pre>FROM</pre><pre>(…)</pre><p>We use these queries as base views or our targeted analysis. In this case, we wanted to calculate stats at the count level and for that we relied on RANK() specifically:</p><pre>SELECT</pre><pre>*,</pre><pre>RANK() OVER(PARTITION BY starting_count ORDER BY BA DESC) as BA_rank,</pre><pre>RANK() OVER(PARTITION BY starting_count ORDER BY OBP DESC) as OBP_rank,</pre><pre>RANK() OVER(PARTITION BY starting_count ORDER BY SLG DESC) as SLG_rank</pre><pre>FROM</pre><pre>(..)</pre><p>With a bit of SQL magic we can create player level ranks for stats by count. Here, Andrew Benintendi is ranked ninth putting the ball in play on an 0–2 count with a .259 batting average</p><p><em>(count when AB or PA ended and pa_count &gt; 40)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z7wv-Bh2_jYoOZBF" /></figure><p>So what does this look like when we group by team? Below are the Red Sox rankings for the 2018 regular season. Can you find the number 1 — like the Count?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CAZ4gzh0nOGoMZ4q" /></figure><p>A sign of a good offense is one that doesn’t let opportunities slip away. Every baseball team has an advantage when hitting ahead in the count. The Red Sox just happen to be better than most, ranking in the top 4 slash lines throughout MLB on 2–0 and 2–1 counts.</p><p>Interestingly, while the numbers might not look aesthetically pleasing, Boston owns the 2–2 count compared to the rest of MLB, ranking number one across the board with a slash line of .225/.227/.366. As for the playoffs? Other worldly. Jumping on first pitches (.333/.350/.667) 0–0 and demolishing the 2–1 count (.435/.435/.783)</p><p><em>Postseason (not including last night’s game)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*JTn6Dfnu7u_aKxQ5" /></figure><p>By comparison, here were the Dodgers during the regular season. Los Angeles is an aggressive fastball hitting team that excels by hunting early in the count — evidenced by the success on 0–0 and 0–1 counts. They remain aggressive even behind in the count (1–2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5Prew7MU7LHQos3G" /></figure><p>The awesome part of the workflow here is that we don’t have to extract data elsewhere for transformation and analysis AND the majority of these queries run in a few seconds thanks to the power of BigQuery. It’s great for big and small data, for good counts and bad counts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/0*CVsSu9U3GExbWhjq" /></figure><p>Lately, I have been pushing my team to migrate more and more aggregations out of pandas and into SQL. This way we can share the value of the aggregations more easily AND we are saving a ton of time not having these run as one off pieces of code. Find something interesting — create a view! This post is glimpse into a bit our hacking. If you are new to SQL hopefully you can see some of the magic when using a serverless data warehouse like BigQuery. If nothing else — hopefully you can see just how good the Red Sox inside the count.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0cd478ef774" width="1" height="1" alt=""><hr><p><a href="https://medium.com/baseballongcp/magic-count-with-a-bigquery-d0cd478ef774">Magic Count with a BigQuery</a> was originally published in <a href="https://medium.com/baseballongcp">baseballongcp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kershaw Curve vs Sale Slider]]></title>
            <link>https://medium.com/baseballongcp/kershaw-curve-vs-sale-slider-f50097de17c2?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/f50097de17c2</guid>
            <category><![CDATA[world-series]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Tue, 23 Oct 2018 23:52:20 GMT</pubDate>
            <atom:updated>2018-10-23T23:52:20.089Z</atom:updated>
            <content:encoded><![CDATA[<p>We’re back! After months of slogging through <a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp">basketball</a> and the <a href="https://medium.com/analyzing-the-world-cup-using-google-cloud">World Cup</a> we are finally able to hack on some baseball. This year we are focusing more on pitch selection, sequencing and effectiveness. For our analysis, we are using data primarily from <a href="https://sportradar.us/">Sportradar</a> as well as various public sources to drive our <a href="https://medium.com/baseballongcp/analyzing-the-game-of-baseball-on-gcp-52cd0fb3abb2">overall data science pipeline</a> using Google Cloud.</p><p>Some of the tooling has changed since we started in 2016, but the pipeline fundamentals remain the same — leaning heavily on <a href="https://beam.apache.org/">Apache Beam</a> and <a href="https://cloud.google.com/dataflow/">Cloud Dataflow</a> for ETL, <a href="https://cloud.google.com/bigquery/">BigQuery</a> for interactive analysis and feature development, and then <a href="https://blog.kovalevskyi.com/deep-learning-images-for-google-cloud-engine-the-definitive-guide-bc74f5fb02bc">iPython via Deep Learning images on Google Compute.</a> No long running servers were harmed for this analysis — serverless+ephemeral infrastrastructure is the name of the game! Speaking of games… on to World Series Game One.</p><p>Red Sox vs Dodgers. East Coast vs West Coast. Beantown vs Hollywood. Two teams and towns that couldn’t possibly contrast one another more. Apropos the distance of 2,588 miles between Boston and Los Angeles marks the greatest length between World Series combatants in baseball history.</p><p>It’s hard to imagine a better opening World Series matchup than Clayton Kershaw (LAD) against Chris Sale (BOS) — the two best left-handed starters in baseball who will square off in game one of the Fall Classic. Today’s post focuses on what many consider to be two of the nastiest breaking pitches in the game: the Kershaw curve and the Sale slider. With the naked eye, both seem to defy laws of physics.</p><p>In Kershaw’s case, whether it’s his unconventional delivery, release point, ability to hide the ball, fastball setting up the pitch, and a number of other factors — his curveball always has opposing batters on their toes. This GIF is one of thousands available online. Spoiler alert: they’re all mesmerizing as this one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*5gn4YVg8QmUoeCc6" /><figcaption>Kershaw CU</figcaption></figure><p>The break on his curve seems unreal at times. So…exactly how much does it break…and how much in comparison to other breaking balls thrown throughout MLB? Among starting pitchers (min 200 batters faced), he has the most break of any left-handed pitcher. When factoring in all starting pitchers, Kershaw’s curveball sits in second position only to Mike Fiers (DET/OAK) who had more break.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/0*nQcUHadBaG8hh0FC" /></figure><p>Let’s dig into more here — Kershaw is 3 pitch machine: fastball, slider, curveball. Coming off his 2017 injury shortened season, Kershaw threw his curveball 16.5% of the time in 2018 (also injury shortened) but his average break length is back in shape.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/0*f1f3ak4VV8ceP8no" /></figure><p>Although Kershaw’s injury history the past two seasons are noted — an interesting look at all of his curves time aligned — there is a clear moment where his break changes. This passes the eye test when grouping by year</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/0*M98MbU0eEpU1ICwT" /></figure><p>Another interesting note: 2018 is the most consistent with his curveball in terms of deviation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/0*OYaI8syClmPN9w4o" /></figure><p>Now that we’ve quantified the nasty break on Kershaw’s curve, what can we learn about the pitch in terms of result thrown both in and out of the strike zone? For this we binned each pitch into in zone and out of zone — relative to each batter’s strike zone and then calculated three bins outside of the strike zone.</p><ul><li>out_zone_2_swing_pct is percentage of balls swing on outside the strike zone within 3 to 6 inches.</li><li>out_zone_2+_swing_pct is percentage of balls swing on outside the strike zone greater than 6 inches.</li></ul><p>Batters swung on 42% of curves outside the strike zone and of those 35% were 6+ inches outside of the zone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ogbW9yQgQ_8lIfmL" /></figure><p>Net-net tonight keep an eye out of Kershaw’s frequency and execution of his curveball — and if/when it makes opposing hitter look silly.</p><p>Speaking of looking silly, Chris Sale has a slider that can break machine learning vision systems while buckling the knees of just about any professional hitter. Sale displays many of the same characteristics as Kershaw when it comes to his devastating slider (unconventional delivery, release point, ability to hide the ball, fastball setting up the pitch, and a number of other factors)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/0*5YgobqPyJf5WZ25Y" /><figcaption>Sale SL</figcaption></figure><p>Sale is magical at getting hitters to chase out of the zone. When compared to Kershaw, he is evenly distributed in terms of getting batters to swing at bad pitches. Sale’s repertoire is different than Kershaw’s, but includes the devastating fastball/slider combo.</p><p>We’ll ask the same question about Sale’s slider. Exactly how much does it break…and how much in comparison to other sliders thrown throughout MLB? Among starting pitchers (min 200 batters faced), he has the most break of any left-handed pitcher. When factoring in all starting pitchers? Yep, still number one, regardless right or left-handed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/0*SipD13jS46vT19r6" /></figure><p>Now that we’ve quantified the nasty break on Sale’s slider, what can we learn about the pitch in terms of result thrown both in and out of the strike zone? Possessing the best breaking slider enables Sale to induce 44% of swings outside of the zone with 26% of those are 6+ inches outside of the strike zone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n0z5H-qI78kuePL5" /></figure><p>We can only hope for an extended World Series and rematch opportunities between these two incredible southpaws. Enjoy the Fall Classic and look for more posts before each game!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f50097de17c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/baseballongcp/kershaw-curve-vs-sale-slider-f50097de17c2">Kershaw Curve vs Sale Slider</a> was originally published in <a href="https://medium.com/baseballongcp">baseballongcp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nerdy McJumpyface — analyzing the jump shot]]></title>
            <link>https://medium.com/analyzing-ncaa-college-basketball-with-gcp/nerdy-mcjumpyface-analyzing-the-jump-shot-20b561f98470?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/20b561f98470</guid>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[basketball]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Tue, 04 Sep 2018 21:18:04 GMT</pubDate>
            <atom:updated>2018-09-04T21:18:06.494Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Authored by: </em><a href="http://twitter.com/rsbensaid"><em>Ramzi BenSaid</em></a></h4><p>In <a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp/there-is-no-off-season-in-the-cloud-70f4ac4f8889">our previous post</a>, we covered the data we collected and the architecture we built for our smart basketball court at Google Cloud NEXT ’18. This post explores the flow of that raw data from Google Cloud Storage into a more manageable one-entry-per-shot state in BigQuery, and some ensuing analysis. Our goal was to gain better insight into human shooting mechanics in order to better understand how they influence shots — specifically, what goes into a good jump shot. While it turns out we didn’t have all that many of them in our dataset, we were still able to uncover some interesting patterns and findings that support some common pieces of basketball shooting advice.</p><p>A quick recap: the raw data from our 3D IR system was stored as CSVs in GCS upon collection, which covered the location (x, y, z) and rotation (pitch, yaw, roll) for seven rigid markers on the shooter, the ball and the hoop, as well as timestamp information (each of the 180 frames per second captured) and some user information.</p><p>Given how much data we were sitting on (roughly 4,600 shots from 350 shooting sessions), we wanted to plan out some of the metrics we were interested in collecting before starting ingest (after all, <a href="https://youtu.be/rd3KFJx7ubI?t=1062">ingestion is a function of data engineering</a>). After brainstorming and testing, we started to get an idea of some metrics we wanted to explore in the shooting motion.</p><p>We built a few that we knew would be important into the installation before NEXT — things like shot distance and launch angle, which informed our ‘Naismith Score’ game during the event. But our post-event brainstorming added concepts and calculations such as:</p><ul><li><strong>Vertical jump</strong>: the average height off the ground of a shooter’s left foot and right foot at the frame of ball release.</li><li><strong>Foot spread</strong>: the distance between the shooter’s feet at the frame when they begin the shooting motion.</li><li><strong>Gather midpoint angle</strong>: the angle generated by the shooter measured by the ball’s location as it moves through three frames: 1) when the shooting motion starts 2) when the ball is released and 3) the midpoint frame between those two.</li><li><strong>Form consistency</strong>: a measure of how similar one shot is to the next in a shooter’s session.</li></ul><p>These metrics weren’t chosen at random — they correspond to much of the received wisdom regarding important features of a jump shot. Whether you’re consulting a quick Google or YouTube search or working closely with experienced coaches and players, you’ve probably heard the following:</p><ul><li><strong>Use your legs</strong>: this allows for greater upper body control from all areas of the court. (vertical jump)</li><li><strong>Keep a balanced base</strong>: without it, it’s difficult to get the right lift. (foot spread)</li><li><strong>Watch your arm motion</strong>: without the proper mechanics, you’ll release the ball on a trajectory that has no chance of ending in the hoop. (gather midpoint angle)</li><li><strong>Be consistent</strong>: at the end of the day, the ball needs to go in the basket. If you consistently get the right release angle and direction <a href="https://www.youtube.com/watch?v=mmHocuMT6Ks">it doesn’t matter what your shot looks like</a>. (form consistency)</li></ul><p>It’s one thing to have intuition — or even experience — around these concepts. But it’s another to have real data that can reinforce each premise.</p><p>With the above metrics (and others) in hand, the next step was the actual ingest. While a simple Dataflow read/write job would have allowed us to move the raw data from GCS to BigQuery, some of our desired metrics were going to require work outside of BigQuery. So we decided it would be better to write these calculations into the Dataflow job to begin with, and for that, we’d need to use Java. Or Python.</p><p>(Tip: Try to codify as much transformation and metric formulation within your ETL flow rather than in ad hoc downstream queries or within feature development.)</p><h3>Ingest: making a guinea pig out of Python</h3><p>Today, most Dataflow jobs are written in Java since it was the first SDK for Cloud Dataflow. However, since the rest of our processing and downstream predictive modeling was written in Python, we decided to write our Dataflow jobs using the Python SDK for Apache Beam. The main benefit here is that we were able to reuse existing Python code within our new pipelines. (Copy — &gt; paste!)</p><p>Like any Dataflow job, the first step is reading the data into a PCollection, which in this case was about 1.5 million entries. The metrics we decided to create relied largely on six important frames of the shooting motion:</p><ul><li><strong>Catch</strong>: the first frame</li><li><strong>Form start</strong>: the frame in which the ball is at its lowest point while still in hand</li><li><strong>In-hand midpoint</strong>: the frame between form start and release</li><li><strong>Release frame</strong>: the frame in which the ball leaves the shooter’s hands</li><li><strong>Tenth frame after release</strong>: roughly 0.055 seconds after release (a frame which later helps gauge the launch angle and release speed)</li><li><strong>Frame at first return to rim height</strong>: assuming shot trajectory follows a parabolic shape and gets above rim height</li></ul><p>Before actually isolating any of these frames there was some housekeeping to be done in our opening PTransform; creation of some very important IDs and some simple calculations to each frame:</p><ul><li>Shot_id</li><li>Frame_id</li><li>Frame_id with ball height</li><li>Rim centroid location (middle of the circle of the rim)</li><li>Distance from ball to hoop centroid</li></ul><p>Next, we started the isolation process by separating frames where the ball was in the shooter’s hand from in-flight frames using a simple ParDo, and joined the frame_ids back using a GroupByKey:</p><pre>in_hand_frames = first_processed | beam.ParDo(GetInHandFrames()) | ‘In hand frame grouping’ &gt;&gt; beam.GroupByKey()</pre><pre>released_frames = first_processed | beam.ParDo(GetReleasedFrames()) | ‘Released frame grouping’ &gt;&gt; beam.GroupByKey()</pre><p>Then we actually isolated the important frames. We mostly used inline beam.FlatMap lambda functions like this one:</p><pre>release_iframe = in_hand_frames | beam.FlatMap(lambda element: [(max(element[1]), element[0])])</pre><p>With each of the important frame_ids isolated, we used a CoGroupByKey to join the frame information back in a new PCollection and finally used a CoGroupByKey on each shot_id to join all of the important frames before running all the shot information through a large ParDo where the various metrics were calculated.</p><pre>down_to_rim_info = (</pre><pre>{&#39;frame&#39;: down_to_rim_frame, &#39;processed_frame&#39;: fp_bpy} |</pre><pre>&#39;Join rim height frame info&#39; &gt;&gt; beam.CoGroupByKey()</pre><pre>) | &#39;Getting rim height stats&#39; &gt;&gt; beam.ParDo(FilterRelevantFrame())</pre><pre>all_shot_info = (</pre><pre>{</pre><pre>&#39;first_iframe&#39;: first_iframe_info</pre><pre>, &#39;gather_midpoint_iframe&#39;: gather_midpoint_iframe_info</pre><pre>, &#39;release_iframe&#39;: release_iframe_info</pre><pre>, &#39;tenth_released_iframe&#39;: tenth_released_iframe_info</pre><pre>, &#39;down_to_rim_info&#39;: down_to_rim_info</pre><pre>, &#39;rim_bounces&#39;: rim_bounces</pre><pre>} | &#39;Joining main shot frames&#39; &gt;&gt; beam.CoGroupByKey()</pre><pre>)</pre><pre>all_shot_stats = all_shot_info | beam.ParDo(GetShotMetrics(), get_dist, get_3D_dist, get_angle, get_angle2, format_date)</pre><h3>Job performance and architecture</h3><p>By the numbers, this Dataflow job is composed of: ten FlatMap lambda transforms, 11 ParDo functions using up to five side input functions (for calculations), four GroupByKey transforms and eight CoGroupByKey transforms.</p><p>In the end, this job turns ~1.5 million rows of raw data from 350 shooting sessions into 4,589 shot entries in BigQuery with 50 data points for each shot. Configured with a fixed worker pool of 10 nodes, this job took about eight minutes of wall clock time.</p><p>Here is what the architecture of the job looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cp4-7XHOpQYVwe35" /><figcaption>Ingesting all shot frame and producing one record per shot</figcaption></figure><p>(Note: 1.5M rows is by no means a Big Data challenge. However, the complex reshaping of this data lends itself to using a framework like Apache Beam, which provides abstractions for pruning, grouping, joining, etc. as a means to create repeatable ETL processes. Should our data size grow to 10M, 100M, or 1B rows, we’ll have a graph in place that can automatically be scaled — no refactoring needed.)</p><h3>Analysis: what makes a good jump shot?</h3><p>We knew we wanted to see if analyzing human movement measurements could help us determine what makes a good shooter good, but where to begin?</p><p>With all of our metrics loaded into BigQuery (except one — more on that later) we began our analysis in R. We used R because we needed to build a plethora of visualizations, and because it fits well over our standard iPython environment for this use case. Fortunately, BigQuery has seamless support for R. (More on <a href="https://cloud.google.com/blog/products/gcp/google-cloud-platform-for-data-scientists-using-r-with-google-bigquery">BigQuery support for R over here</a>.)</p><p>The first step was grouping the various metrics we created (upwards of 27), and understand their distributions. We looked at the middle 90% of values for each and then rounded values to an appropriate measure. For example, 90% of release heights were between 5.5 and 9.3 feet, so we rounded values up to the nearest whole number. Other metrics were a bit less familiar. For example, 90% of values for our verticality metric (a calculation measuring the angle of the shooter’s body to the floor) were between 23.8° and 64.3°, so we grouped by 10-degree increments. With our metrics now clustered into manageable groups, we started to investigate whether there were any significant relationships between them and field goal percentage.</p><h4>Foot spread to release</h4><p>One metric that showed above average performance across the board was a particular range of a calculated ratio. That ratio was the distance between the shooter’s feet at the outset of the shot divided by the height at which the ball was released. We wanted to see if shot distance (a common exploratory metric for basketball analysis) had any major effect on the significance of this ratio, but it turned out to be a strong indicator of FG% at all of our shot distance clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2XCeXVwePY3gLVc2" /></figure><p>We intentionally ignored shots taken within 0–5 feet of the hoop as they are most often layups (which have a vastly different shooting motion, and we were only interested in jump shots). At each cluster beyond five feet, shooters whose feet were separated by between 30% and 40% of their eventual release height shot the best.</p><p>This makes sense. If you refer to any jump shot instructions online, or just think back to your last basketball practice, you’ll know it’s often recommended that a shooter’s feet be about shoulder-width apart. Since we didn’t have rigid body markers for the shoulders, we decided to use this ratio as a proxy (consider: taller shooters likely have broader shoulders as well as a higher release point; shorter players likely have narrower shoulders as well as lower release point, but the ratio stays the same). It held up.</p><p>Bolstered by finding one metric that worked across a variety of shot distances, we looked for other significant trends by plotting and grouping various combinations of metrics but we didn’t find much. Since we couldn’t go back and just add more shots to the dataset, we wondered if we might be looking at too much noise. No disrespect to any of our attendees, but NEXT is a tech conference, not sports, and we saw some ugly jump shots (some sessions included zero makes in 60 seconds of uncontested shooting). While sessions like that might be able to tell us what a bad jump shot looks like, we were still hunting for good jump shots. So, we pivoted to see if we could find the shooters who were making them.</p><h4>Wheat vs. chaff: the distance beyond 20.75’</h4><p>Of our 4,589 shots, over 4,000 were taken between five and 20 feet from the basket, which is a mid-range shot in college basketball. If the modern analytics movement in basketball has done one thing for the game, it’s that it’s replaced mid-range shots with the three-point shot. In Michael Jordan’s final year with the Chicago Bulls (1997–98) there was an average of 12.7 three-point shots attempted per game. That number has been on a steady rise and hit an all-time high of 29.0 last year. The explanation is simple: if Player A attempts 20 two-point shots and makes 45% (an average value) they score 18 points. If Player B attempts 20 three-point shots and makes 35% (an average value), they score 21 points. 21 &gt; 18. If any basketball team today were shooting 87% of their shots from mid-range, they’d a) lose a lot of games and b) see their whole staff get fired.</p><p>Analytics aside, we had the NCAA three-point line (20’9”) marked on the court and participants in a(n albeit not very intense) shooting competition. Those who know the game of basketball and have played a little bit are more likely to know a three-pointer is more valuable, and might attempt more of them. But since we were trying to isolate good shooters and not just people who attempt to shoot threes, we decided to look at shooters who made at least one good three-point shot in a session.</p><p>There were 123 made NCAA-distance three-pointers spread out among 45 shooters. And upon closer examination, those 45 shooters were better than the rest of our participants <em>from every distance</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l2zetLh_vZhxtPwrLp4cMg.png" /></figure><p>Now that we’d found one way to segment a group of good shooters (Group A), we thought that perhaps they’d been doing something differently from the rest (Group B). Once again, we tried grouping our various metrics to see if they were related to whether or not the shooter had made a three-pointer, but there were only minor differences across the board. It was tempting to just chalk it up to ‘shooter’s touch,’ until we started to look at what factors might be influencing touch in the first place.</p><h4>Demystifying ‘shooter’s touch’ (a little)</h4><p>‘Shooter’s touch’ is a nebulous term that suggests a fair amount of skill mixed with a “<a href="https://www.urbandictionary.com/define.php?term=shooters%20touch">hint of luckiness</a>.” But since we could actually look at the entire shot trajectory, we could look at the literal beginning of a touch (hand placement) and see if or how it affected the rest of the shot.</p><p><strong>Hand placement…</strong></p><p>Group A shooters, on average, placed their hands about one inch further apart at the beginning of their shooting motion than Group B. This may not seem like much, but on a ball with a circumference of 29.5 inches, that difference meant the angle generated by the centroid of the ball and each hand was about 2° wider, which meant that the ball sat more in the shooting hand.</p><p><strong>Affects launch angle…</strong></p><p>With the ball sitting more in the shooting hand (as opposed to a more two-handed, push-style shot) Group A shooters had a higher shot trajectory — 2° higher. Again, that may not sound like much, but that launch angle difference meant that the average peak of the shot paths from Group A was almost 9 inches higher than the average paths from Group B.</p><p><strong>And yields more bounce opportunities</strong></p><p>With all that extra height, Group A’s shots were likely seeing better entrance angles and better downward trajectories. And satisfying though swishes may be, shots that get a lot of touches as they dance around the rim and eventually drop seem like pure luck. But perhaps not entirely. For all shots that hit the rim and bounced up, Group A’s shots were 6% more likely to be good than their counterparts from Group B. Put together, Group A’s hand placement led to higher shot angles, which led to bounced shots that had a better chance of making it in the basket. Broken down this way, you can see how ‘shooter’s touch’ actually adds up to buckets.</p><h4>Consistency, consistency, consistency</h4><p>The one metric we created outside of our ingestion job in Dataflow was around consistency. Unlike the metrics created around particular parts of the shooting motion, this is an aggregated metric and is relative to the rest of the shooters in our dataset. So what we did was compare consistency across each of our metrics and score accordingly, and we used a combination of SQL in BigQuery and pandas to do it.</p><p>First, in SQL, we started by eliminating layups in order to look only at jump shots. Though we had previously filtered out layups using shot distance clusters, we wanted to try another, more specific method of removing layups this time. We filtered using a release point to rim distance of less than 8 feet, which would capture any layups made from further than 5 feet away. (After all, a good player might start a layup motion from the middle of the key but release the ball only a few feet from the rim.) Since we couldn’t go back and review the tape, we wanted a more expansive definition of a layup to ensure we were truly looking at jump shots, and if we had to sacrifice a handful of very short jump shots for this round, so be it.</p><p>Next, we grouped each of our metrics by user_handle and collected the standard deviation of each user with regards to each metric.</p><pre>SELECT user_handle</pre><pre>, COUNT(*) AS entries</pre><pre>, round(avg(release_height), 3) AS avg_release_height</pre><pre>, round(stddev(release_height), 3) AS stddev_release_height</pre><pre>, round(avg(gather_midpoint_angle), 3) AS avg_gather_midpoint_angle</pre><pre>, round(stddev(gather_midpoint_angle), 3) AS stddev_gather_midpoint_angle</pre><pre>, round(avg(foot_split_to_height), 3) AS avg_foot_split_to_height</pre><pre>, round(stddev(foot_split_to_height), 3) AS stddev_foot_split_to_height</pre><pre>, round(avg(foot_split_to_release), 3) AS avg_foot_split_to_release</pre><pre>, round(stddev(foot_split_to_release), 3) AS stddev_foot_split_to_release</pre><pre>, round(avg(release_speed), 3) AS avg_release_speed</pre><pre>, round(stddev(release_speed), 3) AS stddev_release_speed</pre><pre>, round(avg(form_verticality), 3) AS avg_form_verticality</pre><pre>, round(stddev(form_verticality), 3) AS stddev_form_verticality</pre><pre>, round(avg(shot_max_height), 3) AS avg_shot_max_height</pre><pre>, round(stddev(shot_max_height), 3) AS stddev_shot_max_height</pre><pre>, round(avg(max_height_over_dist), 3) AS avg_max_height_over_dist</pre><pre>, round(stddev(max_height_over_dist), 3) AS stddev_max_height_over_dist</pre><pre>, round(avg(first_ten_frames_dist), 3) AS avg_first_ten_frames_dist</pre><pre>, round(stddev(first_ten_frames_dist), 3) AS stddev_first_ten_frames_dist</pre><pre>, round(avg(form_to_release_time), 3) AS avg_form_to_release_time</pre><pre>, round(stddev(form_to_release_time), 3) AS stddev_form_to_release_time</pre><pre>, round(avg(vertical_jump), 3) AS avg_vertical_jump</pre><pre>, round(stddev(vertical_jump), 3) AS stddev_vertical_jump</pre><pre>, round(avg(spin_rpm), 3) AS avg_spin_rpm</pre><pre>, round(stddev(spin_rpm), 3) AS stddev_spin_rpm</pre><pre>, round(avg(foot_spread), 3) AS avg_foot_spread</pre><pre>, round(stddev(foot_spread), 3) AS stddev_foot_spread</pre><pre>, round(avg(jump_angle), 3) AS avg_jump_angle</pre><pre>, round(stddev(jump_angle), 3) AS stddev_jump_angle</pre><pre>, round(avg(jump_distance), 3) AS avg_jump_distance</pre><pre>, round(stddev(jump_distance), 3) AS stddev_jump_distance</pre><pre>, round(avg(ball_in_hand_angle), 3) AS avg_ball_in_hand_angle</pre><pre>, round(stddev(ball_in_hand_angle), 3) AS stddev_ball_in_hand_angle</pre><pre>, round(avg(launch_angle), 3) AS avg_launch_angle</pre><pre>, round(stddev(launch_angle), 3) AS stddev_launch_angle</pre><pre>, round(avg(hand_spread), 3) AS avg_hand_spread</pre><pre>, round(stddev(hand_spread), 3) AS stddev_hand_spread</pre><pre>, round(avg(hand_dist_apart), 3) AS avg_hand_dist_apart</pre><pre>, round(stddev(hand_dist_apart), 3) AS stddev_hand_dist_apart</pre><pre>FROM</pre><pre>shots.test2</pre><pre>WHERE release_to_rim_dist &gt; 8</pre><pre>-- AND user_handle = &#39;tensorflowsaysno&#39;</pre><pre>GROUP BY user_handle</pre><p>Then, we took these results to Python and compared each shooter-metric’s standard deviation with the rest of the shooters. For each shooter-metric, we pulled the percentile of the standard deviation in relation to the rest of the shooters. We then averaged each percentile for a given user, and that became our consistency score. This method allowed us to look at form consistency across a multitude of different metrics to finally determine how consistent someone’s jump shot was.</p><p>The lower a score, the more consistent a shooter was across the metrics we collected. We clustered these results and found that only 12 shooters had a consistency score below 0.2. As we’d hoped, they had the highest field goal percentage of any cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hInkSO3QTDRTm3R6" /></figure><p>Meanwhile, the cluster with the lowest field goal percentage by consistency score was the one between 0.2 and 0.3, which is a bit anomalous. But upon further investigation, it turns out that cluster was dragged down significantly by a few especially poor shooters. That cluster of 18 shooters included two shooters who failed to make a single shot, two who only made one shot, and two who only made two shots, going a dismal combined six-for-57 from the field.</p><p>Awfully consistent, you might say.</p><h3>Post production</h3><p>Truthfully, we don’t think this 4,589 shot dataset is enough to conclusively determine what makes a good jump shot, let alone teach someone how to shoot one properly. We saw a lot of inconsistency across basketball ability, and too few shots to determine someone’s skill level. In <a href="https://www.youtube.com/watch?v=Er6wBGYfw50">her talk about analyzing over 22 million shots using Noah basketball at the 2018 MIT Sloan Sports Analytics Conference</a>, data scientist Rachel Marty says you need around 1,000 shots from someone before you can really understand them as a shooter; we had no more than 131 shots from a single person in our dataset. Granted, those numbers are relative to the signal quality of the data — there is a bit of apples and oranges being mixed here — but the gist is the same.</p><p>Nevertheless, our data led to a few key outcomes: first, we were able to find a few interesting trends and put some numbers behind conventional wisdom when it comes to shooting — we learned a bit about what contributes to a good jump shot, even if not what defines a good jump <em>shooter</em>. Second, we learned that we need not only more data, but also more balanced data. (Perhaps we should set this court up in a non-tech conference environment!) Finally, by leveraging Google Cloud services, we created a repeatable and scalable workflow that can continue to be implemented as we gather more data to test new hypotheses, abandon dead ends, and improve our analysis.</p><p>We’ll be continuing to refine our insights as well as exploring new metrics and adjusting the overall smart court experience. Next up, to see if 4,589 shots are enough to move the needle on our predictive model. See you out there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20b561f98470" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp/nerdy-mcjumpyface-analyzing-the-jump-shot-20b561f98470">Nerdy McJumpyface — analyzing the jump shot</a> was originally published in <a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp">Analyzing NCAA Basketball with GCP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[There is no off-season in the cloud]]></title>
            <link>https://medium.com/analyzing-ncaa-college-basketball-with-gcp/there-is-no-off-season-in-the-cloud-70f4ac4f8889?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/70f4ac4f8889</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Tue, 28 Aug 2018 21:24:22 GMT</pubDate>
            <atom:updated>2018-08-28T21:24:22.643Z</atom:updated>
            <content:encoded><![CDATA[<p>With <a href="https://medium.com/analyzing-the-world-cup-using-google-cloud">the World Cup behind us</a> and baseball meandering its way through late summer, you’d be forgiven for thinking that we had reached a lull in the Google Cloud sports data analysis universe. If you did, you’ll be pleased to know that our recent Google Cloud NEXT conference proved quite the opposite. Our showcase highlighting Google Cloud’s NCAA partnership demonstrated a new way to make the cloud more tangible than ever: by designing a basketball competition using elements of data science and predictive analytics implemented on a half-court in the middle of San Francisco’s Moscone Center. Naturally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xfD9iRp_tn-AufLpweziPw.png" /></figure><h3>Some context: applied data science</h3><p>This past year, the <a href="https://www.youtube.com/user/googlecloudplatform">Google Cloud Developer Relations</a> data analytics team worked on projects with entities from MLB, NBA, and the <a href="https://www.blog.google/products/google-cloud/ncaa-teams-google-cloud/">NCAA</a> with the intention to gain new insights through applied data science. These projects ranged from looking at player performance metrics to predicting game flow to modeling the impact of potential rule changes. In addition to being fun, these projects provided unique lessons about data science and ideas for how we might convey them to a larger audience.</p><p>So as Google prepared to welcome tens of thousands of developers to NEXT’18 in San Francisco, we wanted to create an opportunity for attendees to have fun while learning how to tackle projects similar to what we’d been working on. Instead of just throwing a bunch of data at attendees, we thought it might be neat to build a smart court at which attendees would not only be part of the data creation process, but also receive that data for their own analysis.</p><p>We decided to focus on a deeper understanding of the mechanics of shooting a basketball. While there’s no shortage of information published around optimum release angle, spin rate, hoop entry angle, and so on, most of this information focuses on the attributes of a shot; we wanted to focus on the mechanics of a <em>human</em>. With better insight into shooting mechanics (like release height, arm motion, shoulder squareness to basket, head position, etc.), we could better understand how they influence shots.</p><p>Unsurprisingly, we’d need a lot of data. Turns out, it didn’t quite exist:</p><ul><li>The NCAA has a wealth of team and player game data that enables one to analyze metrics like shooting percentage and offensive efficiency. This is helpful, but too coarse for our purposes — it doesn’t tell you where or how shots were made, for example.</li><li>The NBA as a league and several NCAA D1 teams use <a href="https://www.secondspectrum.com/">SecondSpectrum</a> to analyze tracking data of on-court action. This is useful for conducting formation and game flow analysis, but doesn’t provide fidelity into player motion mechanics.</li><li>These are several high-quality shooting analysis systems like <a href="http://www.noahbasketball.com/">NoahBasketball</a> that give players insight into the metrics of their shots (e.g. launch angle, launch speed, etc.). These systems help players improve their mechanics, but don’t provide fine-grained information on the components of their mechanics.</li><li>Various video analysis systems exist; however, these applications require building custom models that analyze human motion in the specific context of shooting a basketball, and/or require painstaking manual frame-by-frame annotation.</li><li>Custom tracking devices (e.g., accelerometer, gyroscope, gps) similar to what was used in the World Cup and have been used in the NFL for the past few years are very helpful for game flow tracking, but not so much when it comes to human mechanics.</li></ul><p>Net-net (no pun intended), we didn’t see a system that would provide us with the data we’d need for our desired analysis. To get it, we would build a system using Google Cloud and a collection of other technologies, as well as a predictive model that would estimate the make probability of a participant’s shots in real-time. We would develop a diverse set of shooting mechanics data, and NEXT attendees would receive immediate insights around their jumpshot in an educational and interactive experience.</p><p>The smart court definitely wasn’t built in a day, and its foundational bricks rest pretty deep. Let’s dig.</p><h3>Scoping and data generation</h3><p>Given the challenges above, we decided to implement a 3D infrared (IR)-based system. These are typically used for virtual reality, robotics, animation, and constrained movement science applications, and have proliferated along with them. With a little bit of sweat, you can use them to perform real-time motion analysis: 3D IR tracking systems can track specific objects within a few millimeters of precision, and can produce highly accurate, high-fidelity data at high frame rates.</p><p>We considered <a href="https://optitrack.com/hardware/">buying the raw components</a> and building the system ourselves, but we applied that golden rule of data science and business: “Am I an expert in this domain? If not, find someone who is and leverage their skills.” Our goal wasn’t to become elite 3D motion capture experts, so we went and found some.</p><p>We teamed up with Seattle-based <a href="http://mocapnow.com/">Mocap Now</a> to help us design, implement, test, and run the data capture system. Here are the basic steps of building out the motion capture workflow:</p><p><strong>1.</strong> <strong>Define our final analysis goal(s)</strong>, which included being able to track a basketball through an entire shooting motion: player movement, player catch, player release, and shot finalization. Here is one of our first “high-tech” diagrams used to brainstorm our workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E4q320_C6e_IVyCE" /></figure><p><strong>2. Map out the volume of space we wanted to analyze</strong>. Due to size limitations at the Moscone Center, we ended up building out an analysis volume that was 26’ deep by 34’ wide by 35’ high, which is roughly two-thirds of a half court of an NCAA basketball floor. This volume was split down the center of the rim through the free throw line.</p><p><strong>3. Finalize the number of markers we’d capture on the player and the court</strong>. We chose left foot, right foot, left hand, right hand, left elbow, right elbow, head, ball, and basket. This gave us nine points to track using rigid bodies as markers: lightweight, reflective devices attachable with velcro. Below left is one of our test shooting participants demonstrating how the rigid body markers light up from the camera flash. (Below right is me wearing my UW Huskies jersey, because they’re awesome.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y9mWpldTYFlDif0Y" /></figure><p><strong>4. Calibrate 34 high-speed IR cameras</strong>, in which camera count is a function of the desired volume area. These cameras shoot at 180 frames per second, scanning the analysis volume for, and then resolving, the location of each rigid body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZH6NUzVkV_Z7g3P1" /></figure><p><strong>5. Test, test, test.</strong> We took approximately 4,000 shots in our Seattle-based performance stage, across 12 different player types (short, tall, beginner, novice, expert, etc.) all shooting a mixture of short- and long-range jumpers. Below is another member of our test group, <a href="https://twitter.com/lak_gcp">Lak Lakshamanan</a>, a wicked data scientist with a decent jumper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cyYtXT33K-NE2gHP" /></figure><p><strong>6.</strong> With the basic capture workflow in place and a diverse group of test shooters, we began <strong>building out the workflow</strong> we’d implement onsite in San Francisco.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*MVAnVfuc-LbmSDHcCMmW_w.gif" /></figure><h3>Data ingestion</h3><p>Creating data is one thing, ingesting it and making actionable is a whole other ball of wax. Each of the nine rigid bodies emitted six data points at 180 frames per second, or 9,720 data points per second. We tracked the following location and rotation data (in addition to frame timestamp and other meta-data).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fjQNhJrvCaCpYrQZFDW6iw.png" /></figure><p>To capture this data in real-time, we implemented a socket listener using a .NET-based SDK optimized to process the marker data from the cameras. Using this SDK drove us to use Windows to host our initial ingestion processes, which had downstream impact on the rest of the architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/0*YuDKqaxL955MeiGg" /></figure><p>This data was captured locally, and after applying a bit of pre-processing, we immediately published it to the cloud to Firebase, Cloud Spanner, Cloud Pub/Sub, and Google Cloud Storage. In our architecture (more below), we published all raw data to Cloud Pub/Sub which emitted a real-time stream read by Cloud Dataflow (Apache Beam). This stream was processed and written to BigQuery as well as Google Cloud Storage. Cloud Spanner and Firebase were used for our real-time scoreboard and shot ranking. For all this work we relied on the <a href="https://cloud.google.com/dotnet/">.NET SDK for the Google Cloud</a> to communicate with each service. (With former Microsofties and heavy Python and Java users on the team, the reviews of the .NET SDK factoring and overall user experience were strong — in some ways it was easier than the Python SDK , and most importantly, it got the job done.)</p><h3>Data processing</h3><p>After ingesting hundreds of two-minute shooting sessions, there were more than 500 million data points (9*6*180)*(120)*(500) loaded into Google Cloud Storage. In order to become actionable, the data needed to get into BigQuery, and for that, we needed Apache Beam and Cloud Dataflow.</p><p>Here is the top-level Apache Beam pipeline that reads off the raw data files, parses and analyzes the data, and then writes each shooting session to BigQuery:</p><pre>public static void main(String[] args){</pre><pre>Pipeline p = Pipeline.create(useCloudDataflow());<br></pre><pre>p.apply(FileIO.match()</pre><pre>.filepattern(&quot;gs://naismith-dev/sessions/*/*.txt&quot;))</pre><pre>.apply(new ForceShuffle&lt;&gt;(25))</pre><pre>.apply(FileIO.readMatches())</pre><pre>.apply(ParDo.of(new ExtractFileFn()))</pre><pre>.apply(new SessionWriter());<br></pre><pre>p.run();</pre><pre>}</pre><p>There are several powerful aspects to this simple-looking graph:</p><ul><li>It allows for easy switching between running the pipeline locally or on Google Cloud.</li><li>It’s mode-agnostic: for testing, data collection and processing could run in batch mode; for the eventual live feed in San Francisco, it could easily rely on Cloud Pub/Sub as the data source and process in streaming mode.</li><li>In batch mode, it shows a subset of files or just one file.</li><li>It allows for iteration. We adjusted how much processing was wanted or needed in the extraction function, and also ended up adding more logic to remove downstream burden on SQL processing and data shaping in pandas.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/0*waR7C2or01b7mq_N" /></figure><p>Armed with this Apache Beam graph, we executed a Cloud Dataflow job to ingest all the shot data. No need to worry about how to parallelize the graph — Cloud Dataflow optimizes the parallelization of each graph step and work items for you. For this graph, the pipeline only takes about four minutes of wall clock time to run.</p><h3>Data exploration</h3><p>With our test shooting data loaded into BigQuery, we moved on to data analysis and exploration. But in order to make sense of what was happening in each shot, we still needed some data. Specifically, we needed to determine when a shot was released, and then look backward and forward in the frames so that we could understand the shooting mechanics as well as calculate the shot metrics.</p><p>Fortunately, performing this enrichment and exploration was straightforward due to Python and R’s seamless access to BigQuery. We piped the raw frame data from BigQuery into a pandas DataFrame and built a collection of functions to calculate vector information about the ball and the shooter. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*btcrH8JPhNJfVYJG" /></figure><p>(Note: The code above eventually went back into the Apache Beam graph in order to save post-processing time when performing data exploration. Using pandas to shape data inside an Apache Beam graph — very copacetic.)</p><p>For exploration, we started looking at basic descriptive metrics over a subset of shots:</p><pre>Shot count: 1077</pre><pre>Overall make percentage: 0.420</pre><pre>Average shot distance: 13.148</pre><pre>Average shot angle (offset cft): 91.976</pre><pre>Average shot release angle: 47.833</pre><pre>Average shot release speed: 14.478</pre><pre>Average shot release height: 2490.105</pre><p>And here is a scatter plot for make v. miss these shots:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/0*1-V6-o4a29st03xh" /></figure><h3>Predictive modeling</h3><p>We were ready to build a predictive model for the NEXT installation. Since we’d be receiving shooting data from a more diverse group than our test group, we wanted to build a model that was fairly straightforward, yet skillful enough to be meaningful.</p><p>Using the few thousand shots from our test data, we started to look at various features:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*StgvCm_WSGkQIu04" /></figure><p>After additional feature analysis, we settled on the following features for what we called ‘the simple model’:</p><pre>[‘distance’,’angle_to_rim’, ‘prior_1_distance’,’prior_1_angle_to_rim’,’prior_1_launch_speed’, ‘prior_1_launch_angle’,’prior_1_release_height’,’prior_1_release_dist_to_rim’,</pre><pre>‘Prior_1_outcome’, ‘prior_2_distance’,’prior_2_angle_to_rim’,’prior_2_launch_speed’, ‘prior_2_launch_angle’,’prior_2_release_height’,’prior_2_release_dist_to_rim’,’prior_2_outcome’,</pre><pre>‘priors_distance_avg’,’priors_angle_to_rim_avg’,’priors_launch_speed_avg’, ‘priors_launch_angle_avg’,’priors_release_height_avg’,</pre><pre>‘priors_deviation_avg’,’priors_release_dist_to_rim_avg’]</pre><p>Using distance and the angle-to-rim on current shot, we used the shooter’s prior two shot results plus the average data from all other priors to estimate a make probability for that <em>particular</em> shooter making a given shot. These features were used to train a TensorFlow DNNClassifier.</p><h3>The game</h3><p>Using this predictive model, we built a game to drive some competition while folks were shooting. The game is based on something we called the Naismith Score, which used the distance each shot was from the basket, the distance the active player moved since their previous shot, and the predictive model. Every .05 seconds we would re-score the make probability for the shooter and update the shot location data with the score potential for the shot. Score was specifically: (distance+deviation)*(1 + make probability)*(0|1). We realize that equation may look a bit harsh, but the fact is, you need to make buckets in basketball.</p><p>For example, below is Mingge Deng, one of our software engineers for BigQuery ML. Somehow he put up one session that locked him into 4th place, but then came back and went 0 for 13. You can see the sea of red misses on the three-point line, with a final shot that would have yielded a point bounty of 2947.</p><p>(Note: We utilized <a href="https://www.tensorflow.org/serving/docker">TensorFlow Serving via Docker</a> to host our trained model on the same machine that was analyzing the real-time frame data. Latency from on-court movement to prediction was &lt;40ms. TensorFlow Serving saved us a ton of time as we were able to rely on a pre-built container, a pre-built HTTP server, and the extensibility layers for serving in a production environment.)</p><p>So what happened?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y1i7CRDLz3xiOWeE" /></figure><p>Mingge got caught up in trying to make all three balls, ignoring the reward function of the Naismith Score. Over time, we had numerous savvy data scientists and sharpshooters starting to “game” the system, which incentivized them to shoot from far, then come in close, then move out far, since the scoring system was biased towards distance and movement. Moreover, if the model determined you were a good shooter (read: you made a few shots in a row relative to location and the broader shooting population), future good shots wouldn’t be rewarded as highly until you missed one and the model recalibrated. One could thus game the system by missing a long one, and still pick up a big score by running back in and making a short jumper.</p><p>That said, the reality was that in order to score you still needed to make shots. So even as we explained to participants how the model worked, thereby opening up the possibility of the model being gamed (or as we think of it, basketball engine optimization) the human element took hold and their mechanics became the next challenge. On the court, we were able to give real-time feedback on jump elevation, release point, and release trajectory, as well as provide the as-yet-unquantified data point of positive reinforcement to help them make a few more shots.</p><p>Moral of the story? Don’t change the game, change the player — specifically by helping them get better at shooting the rock.</p><h3>The architecture</h3><p>While our team of basketball nerds handled all the rebounds bouncing around the court, our team of Google Cloud products handled all the data bouncing around the court. All in, we used Firebase for session scoring, Spanner for leaderboard tracking, Google Cloud Storage for raw session data, TensorFlow to serve up the model locally, and a pipeline from Pub/Sub to Dataflow to BigQuery for data analysis (and future model retraining!).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2kEK6mX9sWcpsVSB" /></figure><p>We had wanted to demonstrate how Google Cloud might let you easily build scalable application workflows with turnkey serverless services, while also casually slipping in some data science fundamentals through a fun, applied experience. To be fair, while some might have been more interested in their shooting fundamentals instead, all participants still walked off the court and received an email with their user handle and <a href="https://colab.sandbox.google.com/drive/1shuA6m-FVjHy1WcM_9driI8N37eCH65e">unique link to a Colab notebook</a> to access their raw data from their 60-second shooting session. Once broken out into a DataFrame, all that shooting data might translate into something looking like this — the motion (y-axis) of the ball during a shot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rQ2lzuii9VpDQ8AR" /></figure><p>A pre-built Colab notebook and some tips on how to start hacking on the dataset? Not a bad upgrade to your standard tech conference swag.</p><h3>The score</h3><p>With over 350 participants producing ~4,600 shots over two and a half days and countless audience members cheering (or heckling) their colleagues from the sidelines, the smart court was a highlight for many at NEXT. But it also gave us an opportunity to revisit some of the work from our March Madness efforts, including <a href="https://cloud.google.com/blog/products/gcp/bridging-the-gap-between-data-and-insights">a long-awaited reveal of BQML</a> and <a href="https://cloud.google.com/bigquery/docs/bigqueryml-ncaa">how it played into our predictive analysis</a> — particularly around three-pointers.</p><p>While hanging out at the court, attendees were also able to immerse themselves into our previous work on <a href="https://www.youtube.com/watch?v=rd3KFJx7ubI">Architecting Live NCAA Predictions: From Archives to Insights</a>, diving deep into the process behind the <a href="https://www.youtube.com/watch?v=M7nU-12Auu0">live ads</a> from this year’s Final Four.</p><p>In our next post, we’ll explore some of our findings around the mechanics of shooting a basketball (properly or otherwise). Meanwhile, you can get even more of a flavor of the smart court in action by checking out <a href="https://www.youtube.com/watch?v=m_gLD1YBC1Q&amp;index=1&amp;list=PLBgogxgQVM9srRp-G6RkSXwDQGr71hhSf">the showcase video here</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLBgogxgQVM9srRp-G6RkSXwDQGr71hhSf&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dm_gLD1YBC1Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fm_gLD1YBC1Q%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ad341badbce98379a6a325dfcf44ba4/href">https://medium.com/media/1ad341badbce98379a6a325dfcf44ba4/href</a></iframe><p>Until NEXT time — your Google Cloud sports nerds,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F8OQBM2TH94DKh7EfmhRSQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70f4ac4f8889" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp/there-is-no-off-season-in-the-cloud-70f4ac4f8889">There is no off-season in the cloud</a> was originally published in <a href="https://medium.com/analyzing-ncaa-college-basketball-with-gcp">Analyzing NCAA Basketball with GCP</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Worth More Than its Weight in Gold]]></title>
            <link>https://medium.com/analyzing-the-world-cup-using-google-cloud/worth-more-than-its-weight-in-gold-36baadf17886?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/36baadf17886</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[world-cup]]></category>
            <category><![CDATA[soccer]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Sun, 15 Jul 2018 01:04:55 GMT</pubDate>
            <atom:updated>2018-07-15T01:05:40.829Z</atom:updated>
            <content:encoded><![CDATA[<p>Authored by: <a href="http://Worth More Than its Weight in Gold   After a 40-year run by the Jules Rimet Trophy from 1930 to 1970, the current World Cup Trophy was created in 1971 and was first awarded in 1974 to West Germany. It was formed from 18 carat gold and is worth more than $10m USD in today’s market. It currently sits under tight security at the World Football Museum in Zurich. It will be handed to the winning team only after their name is engraved on it -- then after the official presentation -- will be returned to FIFA who will keep it locked up until the next World Cup. Heady stuff for the folks who make a new replica trophy every four years (out of brass, not gold) to be presented to and awarded permanently for the winner. Simply put, it is the most coveted, prestigious and glorified trophy in all of sport.  For the third time in the last four World Cup tournaments, an all-European Final has occurred, as France meets Croatia for the Championship.  It also marks our final post as we provide our analysis of World Cup using Google Cloud  How did they get  here?  France went 7-1-2 in qualifying, won Group C (2-0-1), ousted Argentina (4-3) in the round of 16, beat Uruguay (2-0) in the quarters and eliminated Belgium 1-0 in the semis.  Croatia went 6-2-2 in qualifying, won Group D (3-0-0), edged Denmark 1-1 (3-2 PK) in the round of 16, edged host country Russia 2-2 (4-3 PK) in the quarters and came from behind to beat England 2-1 (ET) in the semis.   Differing paths for certain, as France has systematically advanced to their third ever World Cup Final appearance (Champion in 1998, runner-up in 2006), while Croatia not only advanced to their first World Cup Final ever, but became the first to do so having all three knockout matches go into extra time.  Croatia has played 90 more minutes than France -- essentially an extra match. Additionally, France has an extra day of rest, having dispatched of Belgium a day before Croatia advanced past England.   There is very little history between France and Croatia in an international setting.  The most infamous meeting was France’s 2-1 victory in the semi-final back in 1998 on their home soil as France went on to win their one and only World Cup Trophy.  Outside of that, a 2011 friendly produced a draw and the two nations have met a total of only 5 times overall.   France has been on a mission every since losing the 2016 Euro Final on their home soil to Portugal.  Don’t take our word for it -- as French manager Didier Deschamps puts it very succinctly: &quot;Two years ago, I remember what happened two years ago. We will go into this final to win it as we have still not gotten over the [2016] final.&quot;  Croatia, meanwhile, is led by perhaps the most dynamic player in the tournament in Luka Modrić Modric is one of soccer’s rarities – a player with the ability to single-handedly change a game. If he does it again in the final, then he would be a worthy winner of the World Footballer of the Year award that Messi and Cristiano Ronaldo have had a decade-long stranglehold upon.  From a lineup and player availability perspective, neither France nor Croatia is expected to make any changes and should likely roll out the identical XI they utilized in their respective semi-final victories. From a player familiarity perspective, there will be decent crossover, as both squads boast talent out La Liga (Spain) from the likes of Real Madrid, Atlético Madrid and Barcelona.   All four of our models are leaning towards France in this one -- not dissimilar to how they were all favoring Croatia’s opponent in the semi-final, but I digress. Our player model has things the closest, because nearly all of our midfield features give Croatia the edge thanks to the stellar Modric and strong play across their midfield. All features built around the backline point towards France though, as do the majority of striker related features, but the difference is not as great as it is with the midfield features.   Player based  Croatia: 53.1% (1.18 xG) France: 46.9% (1.22 xG)  Team based  Croatia: 40.2% (1.68 xG) France: 59.8% (1.92 xG)  Both  Croatia: 41.3% (1.71 xG) France: 58.7% (1.95 xG)  ELO  Croatia: 32.6% France: 67.4%  Our ELO model is significantly further apart than any of the rest of our models and this is mostly a product of how these teams reached the final. At the start of the knockout round, France had roughly 40 ELO points on Croatia. However, since that time Croatia’s ELO has only gone up 14 points, while France has climbed nearly 100 points towards the summit of Mount ELO. This is because a win in regulation reflects much more favorably upon a team’s ELO than a win in extra time or penalties -- France have only needed 90 minutes in each of their knockout games, while Croatia have not had that level of comfort in any of their wins.   Google Search calls the match in France’s favor, with a chance for extra time    538 gives France the nod    Bing likes France even more and gives little chance to Croatia">Steve Sandmeyer</a></p><p>After a 40-year run by the Jules Rimet Trophy from 1930 to 1970, the current World Cup Trophy was created in 1971 and was first awarded in 1974 to West Germany. It was formed from 18 carat gold and is worth more than $10m USD in today’s market. It currently sits under tight security at the World Football Museum in Zurich. It will be handed to the winning team only after their name is engraved on it — then after the official presentation — will be returned to FIFA who will keep it locked up until the next World Cup. Heady stuff for the folks who <a href="https://www.thesun.co.uk/world-cup-2018/6724906/how-world-cup-trophy-is-made/">make a new replica trophy</a> every four years (out of brass, not gold) to be presented to and awarded permanently for the winner. Simply put, it is the most coveted, prestigious and glorified trophy in all of sport.</p><p><strong>For the third time in the last four World Cup tournaments, an all-European Final has occurred, as France meets Croatia for the Championship. It also marks our final match post as we provide our </strong><a href="https://medium.com/analyzing-the-world-cup-using-google-cloud"><strong>analysis of World Cup using Google Cloud</strong></a><strong>.</strong></p><p>How did they get here? France went 7–1–2 in qualifying, won Group C (2–0–1), ousted Argentina (4–3) in the round of 16, beat Uruguay (2–0) in the quarters and eliminated Belgium 1–0 in the semis. Croatia went 6–2–2 in qualifying, won Group D (3–0–0), edged Denmark 1–1 (3–2 PK) in the round of 16, edged host country Russia 2–2 (4–3 PK) in the quarters and came from behind to beat England 2–1 (ET) in the semis.</p><p>Differing paths for certain, as France has systematically advanced to their third ever World Cup Final appearance (Champion in 1998, runner-up in 2006), while Croatia not only advanced to their first World Cup Final ever, but became the first to do so having all three knockout matches go into extra time. Croatia has played 90 more minutes than France — essentially an extra match. Additionally, France has an extra day of rest, having dispatched of Belgium a day before Croatia advanced past England.</p><p>There is very little history between France and Croatia in an international setting. The most infamous meeting was France’s 2–1 victory in the semi-final back in 1998 on their home soil as France went on to win their one and only World Cup Trophy. Outside of that, a 2011 friendly produced a draw and the two nations have met a total of only 5 times overall.</p><p>France has been on a mission every since losing the 2016 Euro Final on their home soil to Portugal. Don’t take our word for it — as French manager Didier Deschamps puts it very succinctly: <a href="http://www.newsweek.com/france-vs-tk-betting-odds-preview-world-cup-final-1019387"><em>“Two years ago, I remember what happened two years ago. We will go into this final to win it as we have still not gotten over the [2016] final.”</em></a><em> </em>Croatia, meanwhile, is led by perhaps the most dynamic player in the tournament in Luka Modrić <a href="https://www.usatoday.com/story/sports/columnist/martin-rogers/2018/07/13/world-cup-2018-france-croatia-final-keys/782333002/"><em>Modric is one of soccer’s rarities — a player with the ability to single-handedly change a game. If he does it again in the final, then he would be a worthy winner of the World Footballer of the Year award that Messi and Cristiano Ronaldo have had a decade-long stranglehold upon.</em></a></p><p>From a lineup and player availability perspective, neither France nor Croatia is expected to make any changes and should likely roll out the identical XI they utilized in their respective semi-final victories. From a player familiarity perspective, there will be decent crossover, as both squads boast talent out La Liga (Spain) from the likes of Real Madrid, Atlético Madrid and Barcelona.</p><h3>Win Probabilities</h3><p>All four of our models are leaning towards France in this one — not dissimilar to how they were all favoring Croatia’s opponent in the semi-final, but I digress. Our player model has things the closest, because nearly all of our midfield features give Croatia the edge thanks to the stellar Modric and strong play across their midfield. All features built around the backline point towards France though, as do the majority of striker related features, but the difference is not as great as it is with the midfield features.</p><p>Player based</p><ul><li>Croatia: 53.1% (1.18 xG)</li><li>France: 46.9% (1.22 xG)</li></ul><p>Team based</p><ul><li>Croatia: 40.2% (1.68 xG)</li><li>France: 59.8% (1.92 xG)</li></ul><p>Both</p><ul><li>Croatia: 41.3% (1.71 xG)</li><li>France: 58.7% (1.95 xG)</li></ul><p>ELO</p><ul><li>Croatia: 32.6%</li><li>France: 67.4%</li></ul><p>Our ELO model is significantly further apart than any of the rest of our models and this is mostly a product of how these teams reached the final. At the start of the knockout round, France had roughly 40 ELO points on Croatia. However, since that time Croatia’s ELO has only gone up 14 points, while France has climbed nearly 100 points towards the summit of Mount ELO. This is because a win in regulation reflects much more favorably upon a team’s ELO than a win in extra time or penalties — France have only needed 90 minutes in each of their knockout games, while Croatia have not had that level of comfort in any of their wins.</p><p>Google Search calls the match in France’s favor, with a chance for extra time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*1GO8-NbUCBRBVGZm" /></figure><p>538 gives France the nod</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/0*yJoseDNmqu0BB6-5" /></figure><p>Bing likes France even more and gives little chance to Croatia</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*ZNZeaU7-3lHZsMf8" /></figure><p>Enjoy the match!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36baadf17886" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analyzing-the-world-cup-using-google-cloud/worth-more-than-its-weight-in-gold-36baadf17886">Worth More Than its Weight in Gold</a> was originally published in <a href="https://medium.com/analyzing-the-world-cup-using-google-cloud">Analyzing the World Cup using Google Cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tale of the Tape]]></title>
            <link>https://medium.com/analyzing-the-world-cup-using-google-cloud/tale-of-the-tape-db5e31ebc72b?source=rss-d4825e516474------2</link>
            <guid isPermaLink="false">https://medium.com/p/db5e31ebc72b</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[world-cup]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Eric Schmidt]]></dc:creator>
            <pubDate>Sun, 15 Jul 2018 00:49:01 GMT</pubDate>
            <atom:updated>2018-07-15T00:49:01.810Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/analyzing-the-world-cup-using-google-cloud/making-world-cup-sausage-with-cloud-dataflow-and-bigquery-830ee44740d7">One more match to go in our analysis of the World Cup using Google Cloud</a>. Prior to and throughout the World Cup, we’ve talked through a lot of analysis workflows. We talked about data coverage, how we use GCP to to manage all data, turn it into predictive features and finally model it. In the end, our models fall into one of four categories.</p><ol><li>Team based features</li><li>Player based features</li><li>A blend of 1 &amp; 2</li><li>ELO</li></ol><p>The blended version combining team and player based features performed the best on our test cases, but we thought it’d be interesting to run our models and compare results from on a more interesting test set than a randomized sample of historical games. We are of course referring to the 2018 World Cup.</p><p>For each group stage game we consider three possible outcomes — win, loss or draw and only consider the pick correct if the highest projected outcome occurred. This hurt our performance some — as teams needed to be very evenly matched for a draw to be the highest probability outcome. Then when it came to the knockout rounds, a different model was used that did not include the possibility of a draw — in which case a pick was deemed correct if the team advanced regardless of extra time or penalties.</p><p>Through the Group stage, our four models all performed relatively evenly. Both the player based model and the ELO based model correctly picked 56.3% of games (though it was a very different set of correctly picked games), while the blended model and the ELO based model did slightly better correctly picking 58.3% and 60.4%, respectively.</p><p>The analysis below represents the accuracy of picking the favored team. This is a harsh mechanism to judge model performance as this form of scoring does not take into account the probability weight. For example, an incorrect pick on a high win probability is less precise and therefore should be scored “worse”.</p><p>During the tournament we received some negative feedback when a favored team did not win. For example, <a href="https://medium.com/analyzing-the-world-cup-using-google-cloud/mama-said-knock-you-out-75c070c1bb7d">we had Portugal at only a 6.5% margin in their match v Uruguay</a>. When Uruguay won, the internet was poo-poo on the estimate citing it was “WRONG!!!”, “TOTAL FAIL”. The England v Croatia match was a similar scenario that also yielded some tasty internet trolling when Croatia an 8% underdog knocked off England. Unfortunately, not everyone understands probabilities.</p><p>In the knock stage (modulo the final match yet to be played) our blended model correctly picked the favorite 66.7% in a World Cup with several cataclysmic upsets. Post the final match we will update this post with a log-loss numbers to shed light on the precision of the models. For now here is the simple accuracy view for each model broken out by group stage and knockout stage.</p><p>Detailed results from group play are below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*7xJ2cEQyW1hnITHSsofg1A.png" /></figure><p>The glaring weakness from Group A was a serious overestimation of Egypt. Our models picked them to beat both Russia and Saudi Arabia, advancing to the knockout round — the hosts made sure that wasn’t going to happen and by the time the Pharaohs faced Saudi Arabia the group was decided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*vuW1Sa0OIFWj0qsQ052dQw.png" /></figure><p>In Group B we were mostly let down by a large number of draws and some poor finishing from Morocco. Iran failed to put a shot on target in the 2nd half against the Moroccans, but won on an own goal and even though the draw came in as high as 28% in Spain vs. Portugal, each model predicted a winning goal that never came. In the end, this was our worst group in terms of accurate projections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*NVEb6WAg96Hhmr5j2cudGQ.png" /></figure><p>Our player based model went 3–3 on France games (including our only correctly picked draw) but was only 1–3 on games that didn’t involve the eventual finalists. All of our non-ELO models picked an upset in the final group game — Australia versus Peru, which ended up missing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*74J5xyrkYkITLJW6NKqkdg.png" /></figure><p>Unsurprisingly, all four models missed Croatia’s upset of Argentina and Iceland’s draw against Messi &amp; co. Both our team and blended models went 4–6 in Group D, outside of those two game. our player based model went against the grain picking against Croatia in the final group game — the start of Croatia outperforming our expectations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*r8q7n9YEOF1l_tzWsD2N9Q.png" /></figure><p>Again in Group E we picked winners eventually leading to our models being 0–8 on the two Swiss ties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*6Ntyedf6byU22v3pesm9rw.png" /></figure><p>Like the rest of the world, we were surprised by Germany’s early exit and as a result our models were 0–8 in their two losses. Our models were split on Sweden versus Mexico and in the end our player based and blended models got it right.</p><p>Group G</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*uJpXff6BOJ5pqZc4YePxYg.png" /></figure><p>Group G was our most accurate group only missing one game with one model. Now this makes sense as there were no real upsets and no draws to trip things up. The one miss was our ELO model picking Panama over Tunisia in what was the final game for third place in the group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*NEFeKpYeaSuoqy9QJ1mSTQ.png" /></figure><p>Group H — which was viewed by many as the most even group before the tournament, had the most variation in model picks. No single game had the same result chosen from all four models, and as a result at least one model correctly picked each game outside of the Senegal versus Japan draw.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*wBIQeeDENbaBloEIwrmNeQ.png" /></figure><p>We have struck out on four of the 15 knockout games; Russia’s all time upset against Spain, Sweden’s win over Switzerland, Belgium’s quarter-final win over Brazil and Croatia’s semi-final win over England. Outside of those games, at least two models have correctly picked each knockout game, including today’s third place game.</p><p>In the knockout rounds our player based model has correctly picked 60% of games, while our other three models have correctly picked 66.7%.</p><p>With one game remaining — our model performances aggregated over both group play and the knockout rounds are summarized below:</p><ol><li>Blended model: 61.9%</li><li>Team based model: 60.3%</li><li>ELO based model: 58.7%</li><li>Player based model: 57.1%</li></ol><p>For what it’s worth — all four models have picked France as the favorite tomorrow, the same way all four models picked England in the semis…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db5e31ebc72b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analyzing-the-world-cup-using-google-cloud/tale-of-the-tape-db5e31ebc72b">Tale of the Tape</a> was originally published in <a href="https://medium.com/analyzing-the-world-cup-using-google-cloud">Analyzing the World Cup using Google Cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>