image: thumbnail.jpg
Alok Pattani - Google | Sports Analytics Meetup | RStudio
The increasing volume, variety, and velocity of sports data provides both great opportunities and challenges for data scientists working in sports. Using R with Google Cloud data science tools like BigQuery can help practitioners scale their analysis and impact in this "new era" of sports analytics. This presentation will include a demonstration of using R and Google Cloud together with an NCAA basketball data example, as well as a discussion of the application of such metrics and tools in the sports media and technology industries.
Speaker Bio:
Alok is a Data Science Developer Advocate at Google, where he shows how to use Google Cloud tools for data science, in sports and otherwise. He is a sports analytics expert and a long-time user of R and RStudio. Before joining Google, Alok spent 8 years at ESPN, where he was a founding member of their Sports Analytics team and contributed significantly to the use of analytical content across all media platforms. Alok is originally from Cheshire, CT and earned a BA/MA in statistics from Boston University.
Alok's Slides: https://lnkd.in/gxQUf8nV
Packages shared:
✨sportsdataverse: https://lnkd.in/g8UKAJgc
✨ wehoop: https://lnkd.in/grBgmc33
✨ hoopr: https://lnkd.in/gRHNWV4j
✨ glmnet: https://lnkd.in/g4cuxYzs
✨ googleAuthRverse: https://lnkd.in/gf5fRgcC
✨ All of Mark Edmondson's Google packages: https://lnkd.in/gmTpvMsY
Other resources shared:
✨ Sports data: https://www.spotrac.com/
✨ Analyzing NCAA Basketball with GCP: https://lnkd.in/gT-4vWwa
✨ 2020 Google Cloud March Madness Insights: https://lnkd.in/gEWd9xtu
✨ Alok's presentation on Innovating the MLB Fan Experience through Data: https://lnkd.in/g9XmFKsy
✨ NFL Player Tracking Data Meetup recording:
✨ Analyzing Soccer Data with BigQuery: https://lnkd.in/gbbCGKaK
✨ Sports channel on the R for Data Science Online Learning
✨ Community Slack: r4ds.io/join # chat-sports_analytics
Transcript#
This transcript was generated automatically and may contain errors.
All right, thanks, Rachel and Mitch. Really appreciate you having me here to speak today. Been a big fan of R and RStudio for probably a decade now and been involved in sports analytics for longer than that. So excited to come talk about a couple of things related to both sports analytics, R and Google Cloud, where I currently work. So let me share my screen.
Okay, make sure everyone can see it. Looks good. All right. So yeah, we're gonna talk about scaling sports analytics with R and Google Cloud.
Like I said, I'm Alok Pattani. I work as a data science developer advocate at Google Cloud, which means that I talk about how to external people outside of the company, how to use Google Cloud for data science. And often I like to do that using sports as an example, because I come from a sports background and sports is fun and gives us a way to talk about cloud technology and data science in unique ways that appeals to a large section of sports fans.
Background and introduction
So a little bit of background on myself. I went to Boston University, did major in statistics there. That's probably where I first got started with R. Very, very different than now, given that this was probably more than 15 years ago now. I was fortunate to work in ESPN's stats information group and was a founding member of the sports analytics team, where we created metrics like the total quarterback rating for the NFL and college football, as well as power indices for various sports. So I'll talk a little bit about that today, depending on where we go.
Yeah, it was a great experience there. Moved on to Google in 2016. And since about three years ago, I've been in the current position I'm at at Google Cloud, where, as I said, I talk about how to use Google Cloud tools for data science and have worked on our sports partnerships initially with the NCAA, as well recently with Major League Baseball, Golden State Warriors, and a few others, a few other sort of sports related engagements. I also do other, outside of Google, I do some sports and data science consulting, including for an NFL team, but not the one that won on Sunday. So I still have a lot of work to do to catch up to Mitch.
R and BigQuery for data science
Okay, so let's take a step back. So I want to dive into an example here, but first kind of set the background for some of the tools and technologies I'm gonna talk about. We'll dive into the example, look at some code, and then come back and kind of go in some other learning. At the end, hopefully we'll have plenty of time for questions. So look forward to hearing from you all then too.
So R and BigQuery for data science. So here is a chart that my teammate Priyanka put out recently about all the different tools on Google Cloud for data science. And you can see that there's a lot, right, quite frankly. So depending on how wide your definition of data science is, and here we picked a pretty wide one, there are lots of different categories of activities that fall into data science.
So you can see here we have things like data engineering, right, so all the aspects of getting data in, ingestion, pre-processing storage, et cetera. Data analysis, which is fairly common, something that a lot of people using R will do too, is exploratory data, whether you're getting stuff, maybe you go right from there into an activation in a dashboard tool, or you want to go build a model. And depending on how you want to build a model and how large and sophisticated and sort of what the goal of that model is, there's a ton of tools here you may want to use. And then once you sort of have your model and it's up and running, now you're sort of in the software engineering space for you want to manage your model and all the end points.
This is where, certainly from my background statistics, that this is new to me. You end up having to learn a bunch of technology just about what to do once you've kind of done what I would consider the statistical work. And then finally, kind of the most important end goal is these activation points. You're not doing data analysis, data science in a vacuum usually, you're trying to influence some sort of business decision, or it'll go into an application, right? Your model will be part of software that sort of dictates how your business, that will be an integrated one to your business, I should say.
So I could spend the next several hours deep diving into these products. I'm not going to do that. I'm only going to talk about probably one of them and then maybe mention some others as we go. So the big idea is we can turn data into insights, right? Faster and easier with tools like these various ones.
BigQuery overview
The one product I do want to talk about is BigQuery. So Google Cloud BigQuery is a serverless, highly scalable and cost-effective data warehouse. We have many customers using this that you store up to 100 plus petabytes of data, right? So that's well larger than any of the data we're going to talk about today, but is starting to become pretty common in the enterprise space, right? Where companies have more and more data. So it's SQL-based, highly available data warehouse.
Some of the unique things it has is the ability to go multi-cloud. So you can query stuff that's on Google Cloud within BigQuery itself, but also in other clouds with a product called BigQuery Omni. There's also real-time insights. So based on streaming data into Google Cloud with other tools, you can set up dashboards or other sort of interfaces where the data coming into your warehouse is available to you very, very quickly. There's also built-in machine learning. So through a product called BigQuery ML, BigQuery Machine Learning, you can fit a growing number of models, including linear regression, logistic regression, onto neural networks.
Things that Cisco R users might be interested in too, pre-processing. And that's a really nice tool for when you have really huge data already in BigQuery, you can do the machine learning right on that data. You don't have to move it around. And then insights for everyone. Products like BI Engine allow you to kind of scale the way you take BigQuery and build outputs on top of it.
So this is one of my favorite products. This was kind of came out of work that Google was doing. Obviously, Google is a huge data company. The whole concept of Google Cloud is taking the infrastructure that powers things like Google Search, like YouTube, and making that available for other businesses.
Using R and BigQuery together
Okay, so now let's get a little bit into this as far as R and BigQuery. So I like R and I like BigQuery. So this isn't, which one is better for what? You can do a lot of things in both of them. And a lot of that will be based on sort of the use case. When I go through the example, you'll see how I'm kind of weaving between the two. But in general, things I like to do in R include getting data from lots of different packages. We'll see on here, websites, APIs. I think the ecosystem around how to get data into R has been really awesome and getting better over the last several years. General data manipulation. Obviously, the tidyverse is quite amazing for this. I use it all the time extensively.
And yeah, can't recommend that part enough. Exploratory data analysis. You know, whether that's just kind of looking at your data or plotting it with ggplot2, something like that. Statistical analysis and modeling. This is where I think R has a large depth of packages, right, depending on where your background is, what type of specific model you want. You can almost always find an R package or multiple that are doing, that are available to solve your problem. And then what I call ad hoc data visualization. As I'm going, I want to look at something, quickly build a plot, quickly, maybe facet the plot by a couple of different dimensions or look at a few things as I'm doing analysis. R, I think, really stands out for that.
BigQuery, like we said, enterprise data warehouse. So if you want a bunch of data that is now available for R, but maybe lots of other things, that's like the place where we want that data to be stored. And then, and we'll look into this a little bit too, what I call intermediate pieces, some views, stored procedures. Often you'll have a data warehouse with like some very, I guess, basic foundational tables. But then on top of that, you want to create some more interesting outputs that then maybe feed multiple other analyses, right? So we'll talk a little bit about this too. And then we talked a little bit about BigQuery ML. So BigQuery also can do modeling, which is a differentiating feature for a data warehouse. And like I said, I like using that when you have really big data already in BigQuery.
And the storing, we also, like I talked about, you can store the results in BigQuery of an analysis, right? Not just the base sort of data, the results, and then build sort of interactive dashboards or other data products off of them as well. And then the thing at the bottom, maybe one thing that like, if you want to take away, maybe you've already, if you're not using this, but if you are using R and maybe you're interested in BigQuery, the big R query package is really a strong way to integrate the two. So you want to get data from BigQuery into R, you want to take data from R into BigQuery. I use this package all the time to do this sort of stuff. Thanks to Jenny Bryan and Hadley at the RStudio team. I believe they're the developers and maintainers of that package.
NCAA basketball example
Okay, so let's dive into an example analysis here where we're going to use NCAA basketball data, March Madness, not too far around the corner. And I have an interest in college basketball data going back to, I don't know, probably when I was a kid, but also from ESPN where I worked on the original version of our basketball power index, which launched about almost 10 years ago to the day. So I thought it would be a cool way to get into the idea of using R and BigQuery together and see what we can learn about NCAA basketball. So first I'll set the problem and then assuming I know how to switch my screen, I'll share other aspects of, share some R code as well as BigQuery.
So here's what we want to do today, which is to create a rating system for NCAA basketball players. So this is not novel. Some people have done this type of thing, creating rating systems, a player rating system is among one of the top sort of topics in sports analytics. But the difference here is that we want a couple of different things to be true about this system.
So we want to use multiple player box score statistics. So for example, we don't want to just take the player who scored the most points and say that's the best and something like that, right? There's many ways that people can contribute to the game. In the world of NBA, there's actually way more interesting statistics now that take into account sort of play-by-play level, who's on the court, all the way to the newer tracking data to do this. But we're going to assume we have more limited data, but still very good on the player box score level. We want to take all of that into account or as much as we can.
And then the second point is important as well. We want to represent it as a player's contribution to winning. So let's say we had really detailed data, we could say who jumps the highest. That would be a way to rate players, but it doesn't necessarily in and of itself contribute to winning. So we want to take into account statistics, but also have some relationship with winning.
The third point is important as well. So often I've seen a lot of rating system for men's college basketball, not quite as many for women's college basketball, but I think it's growing over time. We want a rating system that can be equally applicable to both. Many statistics are collected on sort of both levels. Let's see, again, we want to talk about scaling. Can we take the same system and adapt it for, I shouldn't say adapt it from one to the other. Can we take the same system and create it for men's and women's basketball? And then we want to apply it to the current system, but again, this is about scale. We want to compare to players in past years as well. So let's apply it to the few past years. And then this last point, which is really important, we want to adjust for schedule. We don't want to just take into account stats as they are. We know that in Division I college basketball, there are over 350 teams each, men's and women's, and teams play varying schedules, all different sorts of quality. We want to adjust for who, not just, you know, we want to account for not just what you did, but who you did it against. And that's really important, so.
Why player ratings matter
So why is this, why would this be important or useful? So there's like some basis, like people say that all-in-one ratings are dangerous and shouldn't be. Sort of consumed. And there definitely are reasons why you don't want them, particularly in certain instances where you want to learn more about a player, especially if you're coaching the players on your team. You want to talk more about what that player's strengths are, how they fit in with the rest of the team. It's not just an overall value thing. But let me take the other side and talk about why they really are useful sometimes.
So for media and fans, right? A lot of people in college basketball otherwise always talking about who's the best player, who should make a certain team, who should be an All-American, who should win the awards. And these all-in-one ratings are really useful for that, right? Because one player may be really good on defense, one's good on offense, one scores more, one rebounds more. How do we know, right? And these metrics give us a really good baseline for some of those discussions, as well as research, right? So you may be watching a game or in your media, you need to call a game. College basketball, again, 350 plus teams on either side. So that's thousands of players each year. The players change out often, right? Because they're moving through, especially some of the best players go right on to the pros. So just having an idea of who are the best players on certain teams can be really useful.
And these metrics give us a really good baseline for some of those discussions, as well as research, right?
So that's one use case. And again, in my time at ESPN, this is a lot of reason why we would develop these player ratings. College teams, right, would find this useful for managing their own roster, as well as looking at their opponents, who are the best players on those teams. Content companies. So I'm thinking more here, like even sort of the companies getting into daily fantasy or more coverage of gambling and sports. To something, even a company like Google, like if you have an all-in-one rating, what could you do with that? You might use it to figure out signals for which players might be interesting, what players are people looking for content for,
above and beyond how good they kind of are at winning. It's just a measure of how interesting they are. It could be a signal in a machine learning model, right? And then finally, we're talking about college ratings. Pro teams may find these ratings interesting because they want to evaluate, again, it could be NBA, it could be WNBA, evaluating the college players as potential draft prospects.
And along with many other things, right, measurables and sort of how they do in interviews and things, you might want to use these all-in-one sort of ratings.
Okay, so this is the one sort of high-level overview about what we're going to do. I'm gonna try to at least walk through this. I won't say fully demo this. I'm gonna try to walk through this as much as we can. But high-level, we're going to use open-source R packages, which exist, thankfully, to pull in NCAA basketball data. And then we're gonna upload it to BigQuery, kind of create our mini data warehouse.
And then instead of sort of reinventing the wheel, we're gonna use existing basketball analytics theory for how to kind of take player stats and create a measure of how much they impact their team's winning. And we're gonna apply that in BigQuery.
We're gonna read that data back into R for our schedule adjustment. And then since it's there, we're gonna calculate some stuff there and get some final player ratings. And it'll push it back into BigQuery. And then once we start looking at them there, we'll do the whole purpose of player ratings, which is for argument, is for debate. So we'll say, well, this player's ranked too high, this player's ranked too low.
And to some degree, that at least, once I got comfortable with that, I took things, I found it more interesting. No one's gonna take your player rating system and say, oh, this is perfect. And they shouldn't, and you shouldn't either. So it's a good baseline for a lot of the reasons we discussed and then you go from there.
Setting up the data pipeline
Okay, so let's go through a setup here.
So normally I don't include code directly on the slide, at least like this, but I really wanna point out how awesome sort of the ecosystem is here. So major thanks is at the bottom to Saim Gilani. So he sort of is the leader of this initiative around the sports dataverse, and has been a developer on many packages to kind of make sports data accessible in R, as well as Python and others, but we're focusing on R today.
So the two you see here, hoopr and wehoop, one of them allows you access to men's basketball data and the other, as you might imagine, women's basketball data. And this is the full code to get a bunch of data for the history of what's available in this package for men's and women's college basketball. So it's about almost 20 years, but not as complete here and 15 for women. And you can get teams, schedule, team box, player box, just by running these very well-named functions, load the schedule, load the box.
And the other good thing, so again, this in times where we were working in environment, this will not be as easy, right? Go getting your data is a day's week's process. This was not the case in this. So again, major thanks to Saim for setting up these packages, others who have contributed as well. You can get all the data here. And the other good thing about this is that the men's and women's data comes in with the same schema.
So now when we talk about scaling, one thing we can do is actually store them together, add an extra field that says this is men's basketball, this is women's. And then every calculation we do, we can group by that sport category and everything else kind of can flow along. And we don't have to create two separate code bases or whatever for rating these players.
Basketball analytics framework
Okay, this might be the most complicated slide, not sure. So the other thing is, like I said, we want to build on foundations that others have built for how to measure basketball players. So the framework I use here is actually fairly old, at least old as much relative to sports analytics goes. So this is based on using box score statistics. Again, if you have play-by-play, you have more detailed tracking data, you can do plenty of other things. But this, we have box score data going back, you know, about a decade or so for both men's and women's, thanks to the hoopr and wehoop packages.
So let's do our best to use that and add some of our own twists to it too. So you have player box score stats, you have team box score stats. There's a whole lot of math developed by Dean Oliver, who I was fortunate enough to work with at ESPN and is a pioneer in the basketball analytics space, currently works as a coach for the Wizards. He wrote this book, Basketball on Paper, and did a bunch of stuff to show how you can get the most usage out of that to create these individual player offensive and defensive ratings, or rating, debrating.
If you're familiar with basketball analytics, there's a concept called offensive and defensive efficiency, points for 100 possessions. These are the individual analogs to those. It's not the same as what the team does when the player's on the court, it's a much more detailed calculation, certainly on the offensive side, using points assists relative to the team and how well the team did overall, but taking into account the player's sort of credit for each of those things. The offensive one is much more detailed and useful than the defensive one, because box score is traditionally very offensive based.
But you can calculate those things, you can calculate how many possessions the offensive player used, as well as how many defensive possessions they were involved in. And then with that and some other stats on league, again, I'm hand-waving a bunch on these big green arrows, but Sports Reference, among others, has a win-shares calculation. So they've detailed it here. I hope to share these slides afterwards so y'all can click the links and everything.
But you can take those metrics and then do a bunch more math and develop these calculations for offensive and defensive win-shares, which then you can do another calculation, just add addition, so I didn't put a green arrow here, to get total win-shares. And then I have this other adjustment here that I have seen and like, which is for college basketball in particular, win-shares is a low baseline. Everyone gets kind of wins relative to the team. But what I'm more interested in, how many wins does the player add above sort of the average Division I player, whether that be men's or women's.
So that's the final sort of piece here. So again, a lot of pieces I'm glossing over, not gonna go over this in detail, but you can get the idea that we take player and team box score stats and end up with some metric about how player contributes to his or her team's winnings.
Live code walkthrough in RStudio
All right, let's go into some code.
So I'm going to switch the sharing if I can to...
All right, so hopefully you can see my RStudio. Yep, looks good. Great, so I have this first script, which is the data gathering script. I won't go into too much detail. Again, just look at the packages. We got HoopR, we got WeHoop. We have BigRQuery, which I talked about, that versatile package interface with R&B query. I'm not gonna run this right now. I'm just gonna show you. It takes not that long to run, maybe a few minutes. Again, it gathers a large history of men's and women's college basketball data.
Authenticating BigQuery, you can use email authentication, which I'm doing here because I'm on the sort of like my own laptop. But if you're doing this on a virtual machine or somewhere, you wanna use a service account. We can go into that another time. BigQuery has kinds of datasets I'll get into in a second. And I wrote this little helper function to upload the table into BigQuery using some of the functionality in the BigRQuery package.
This little section here is the one I had copied. This is how you read in all the data. Like I said, relatively easy. Thankful to the community for developing that. The rest of this is a bunch of just data munging, cleaning stuff up, separating out field goals, these sorts of things. As anyone who's worked with data knows, you do have to still do some work to get it in the form you want to sort in the database, especially. So this is kind of a bunch of that.
And then every set of data at the end, we have this little upload and replace table in BigQuery that little helper function. And that will take, for example, this team's data and push it to a table in BigQuery called, in this case, teams.
Exploring BigQuery
So, yeah, like I said, this gets you into BigQuery, which I will share now.
Okay. You see my screen with Google Cloud Platform? Yeah. All right. Thanks, Rachel. So now we're here in Google Cloud. So I think RStudio should be familiar to a lot of people here, probably why you're in the meetup. Google Cloud may not be. So I'll go over a little bit of stuff here. There's way more than I can cover in a small session. But Google Cloud Platform, this little logo is BigQuery. So you can see we're in a BigQuery SQL workspace.
And here you can see what's called a project, right? So I'm in this data science demo project and then a data set. In this case, I created one called NCAA basketball. And within my data set can be many different things. So most prominently we have tables, which are these ones with the sort of dark calculator-like thing. And then these are views. We can also have models here, functions, which you'll see routines, all sorts of different things, materialized views, stroke procedures.
But, yeah, so this is kind of a way to encapsulate like a group of objects that will relate to the same thing. So this is called basketball data. And then what we'll look at is the tables we created from that R script into BigQuery. So we have a table for the teams. We have a table, and we can look here. So it's about 700 plus teams. That's men's and women's. We have a players table.
So we pop that over. We look at the details. You can see there's quite a number of players in here, almost 90,000, again, men's and women's, going back several years. And then we created tables called team game box. So this, again, we want those box for statistics for teams. You can see this has a schema down here. It's fairly wide, lots of different team statistics, field goal, rebounds, all the way to points, and some information about the team and the opponent in the game. This one has like 250,000 rows, 73 megabytes. So, again, BigQuery is built for data way, way bigger than this. But just to give you an example of what we have in this case, and then player game box, which is our biggest table, you can see here, maybe half a gigabyte, and about 2.5 million rows.
So, yes, you could process all this in R. In fact, we did to get it here. But if you want to use this for multiple things, you probably want to store it in some sort of database. I think BigQuery is one option that's pretty solid for that. And then you can imagine running a script, the same script we have, or some other job daily to update your data warehouse with the freshest data.
As you go about there. And then I want to go on to sort of views and just how much you can actually use SQL to do these calculations. Like I said, it's a bunch of math, but it's a lot of joining different data amongst the teams and the players and things like that.
So, you can take your team box for data and kind of augment it in this type of way. I have this view. So, this is a view, which means sort of you write a SQL query and then it stores that sort of intermediate output. So, then you can call the view as if it's its own table. So, again, if you have something where you want to, there's a way you sort of pre-process data all the time. Maybe you want to use it and your teammates want to use it. You may use it for one thing. Then you can kind of abstract that in a view. This is something coming in a lot of databases and I think is a really useful concept.
So, this view, if we click over to the details, you'll see is really long. Again, I won't go into code, but it takes some team and game statistics and calculates advanced stats, sort of basketball analytics, one-on-one stats, offensive efficiency, defensive efficiency, some of the four factors. So, this is a useful thing that I can see using for multiple things. In this case, we'll use it as a stepping stone to the player ratings.
And then we have another view called player team game stats. This one, again, if you go over to this details tab, you can see the code behind the view. Like I said, it's heavily based here on basketball and paper. This one is really, really, really, really, really long. So, again, not going to go totally in depth, but the last steps are we calculate those individual offensive ratings and defensive ratings.
The one thing I should mention actually is this width statement for what's called common table expressions. This I almost use like R where you're, you know, the pipe or using different data frames and then merging them together. With the width statement, you can essentially chain logic together. So, I have this team game stat calcs and I have player game stat calcs, right? So, I do some calculations on the team level. I do some on the player level. Go down here and finally we merge them together, team and player. And then you can just keep building on your outputs. So, one large script is a little more readable with these common table expressions and allows you to reuse pieces over and over.
So, one large script is a little more readable with these common table expressions and allows you to reuse pieces over and over.
Yeah, and then we can build a view on a view on a view.
So, then the last view here is one called player season advanced stats. And I won't even show you the details, but the point is at the end here, we have this schema where we get these calculations for win shares. And like I said, this wins above average type of metric. So, to some degree, we might've answered the question right here all the way in BigQuery.
Yep. So, you can save your queries here. So, I saved one yesterday that allows me to find the top players. So, let's look at women's basketball and we'll look at just this season and get the top players. So, this again, we'll query this view player season advanced stats and give me the top players in that wins above average stat. So, this will take a couple seconds.
Again, one of the benefits of BigQuery is that when you have really massive data, imagine you have player tracking data or play something really big, it will turn through it pretty fast and you don't have to worry about configuration.
So, the same query I'd run to process 100 rows of data can process 100 million rows of data. It spins up what it needs to in the background and it just computes.
Okay. So, we got our answer here. Again, this is not necessarily the size of the data, but the logic is fairly complex amongst those views. Again, for women's basketball this year, these are the top 10 players and the ones above average. So, Alia Boston is a very well-known player in South Carolina who's a top team. Kaitlyn Clark, really excellent player for Iowa, can shoot from Steph Curry range, amazing.
So, this looks pretty good, honestly, right? So, and Ioko Lee, I think, set the Division I scoring record earlier this year. This looks really good, at least in the top of the list. I'm not a huge expert on women's basketball, but some of the names I recognize. And you can see they contribute about five to six wins above average at the top.
So, let me go back now. We're gonna exit BigQuery for the moment. And go back here to the slides.
Reviewing final results and schedule adjustment
So, this, we have our quote-unquote final results. We have the top players. So, I looked at men's and women's and this season, and what we said, we also wanted it back for the several years.
So, the women's ratings, like I said, look solid. They're going back a few years. Brianna Stewart, Sabrina, Inescu, really awesome players who've gone on to success in the WNBA. Kelsey Plum, I think, is the Division I all-time leading scorer. These names are really familiar to me. This looks solid.
Men's ratings, again, if you're not college basketball fans, this would be meaningless to you, but as those who may be, like some of these players stand out, but I'm not as familiar with the ones from this year. Sheboy from Kentucky is the machine rebounding. So, actually, he stood out. Some of these are a little bit smaller schools like Chattanooga, Colorado State, Utah State. And then if you go back, Frank Kaminski did win player of the year for Wisconsin. So, this looks reasonable. These other guys, I know a little bit, but again, you notice this small school thing.
Now, they may be true. They may be very valuable to their teams, but we didn't finish here, right? We didn't do our schedule adjustment, right? We just talked about the... We only did the framework where we take the metrics and build something that relates players to teams. But we didn't do anything where we account for who they play. And we know that some of these players at the bigger conference schools play harder schedules than the ones at smaller conference schools. So, what do we do, right?
So, we moved to part two, right? This is where we get really in-depth about how to take a thing, which, again, was a bunch of math to get here, and now we take it to the next level with sort of statistical analysis. And again, we'll see how R and BigQuery can help with that.
So, we talked about this. Teams face varying levels of competition. So, there's 350 plus Division I teams that are organized into 32 conferences. They play largely different opponents. Some conferences are traditionally better than others. Also, if you think about what affects performance, home court advantage matters, right? So, if you're playing at home a lot, you may likely do better than if you play on the road more.
And this middle section here, we have a model representation kind of of what happens. So, a player or a team stat is maybe loosely related to the intercept, sort of like a baseline, plus maybe the team effect. Again, plus could be plus or minus, maybe the team's above average or below average. The effect of the opponent, right, who they're playing, as well as maybe some impact from home and being at home or on the road or a neutral site. And then, again, error, right?
So, if we think of fitting a model like this, again, very high-level loose representation, we can kind of directly measure the effects of team versus opponent and, again, home court on every stat. So, we use FlimNet, which is a common package in sort of the regularized regression space to fit a bridge regression. Bridge regression helps with sort of, like I said, regularization, not like accounting for sort of outliers, small samples, as well as still giving us good estimates of these effects.
And the interesting part here is we're not fitting a model for predictions. We're fitting a model to get coefficients that we can use to get estimates for offensive and defensive efficiency, effective offensive and defensive efficiency on teams and home court advantage, as well. So, we're more interested in the coefficients of this model than any prediction, at least initially. And I think, like I said, once I share these slides, you'll see a little bit more details.
So, that we use to adjust offensive and defensive efficiency for teams. But the last thing, we are interested in players. So, once we have an adjusted team rating, what do we do for the player side? Well, you can see, we wanna adjust at the rating level. So, we can adjust player's offensive and defensive ratings by the opponent's ratings on the other side of the ball.
So, if I'm on offense, my rating should be adjusted for home court, as well as the opponent's defense. And then my defense should be adjusted for their offense. So, those are the two sort of formulas you see here. They're pretty actually straightforward. Once you have these ratings, the adjustments are essentially linear combinations of this on the game level. So, a player's adjusted offensive rating in a game might go up or down. If he's at home, it'll go down, usually about two points or so, points for 100 possessions. And then opponent adjustment can vary a lot. You may play a really hard opponent and your offense rating will jump about 20 points or so.
Again, the level, it's on a points for 100 possession level. So, the average is about 100. But it also could go down 20 points or so. And defense rating, you see a little bit like that as well. And then, once you adjust these ratings, you can aggregate those to the season level and then follow that same diagram we had before, where you go boom, boom, boom, to get adjusted win shares, adjusted wins above average, and those sorts of things.
Fitting the model in RStudio
So, let's dive back into our RStudio instance here.
So, this is a different script now that just calculates the team and player ratings. So, we use a couple of the regular sort of packages I used to do in Inflation, Tidyverse, Blue Janitor. We're doing new payload processing. Big R query, which we talked about. Glimnet, which is gonna fit this rich regression. And then, Broom, which is a nice package that allows you to kind of clean up regression outputs.
So, again, I'm not gonna go through. We'll go through a couple sections here. This sets up for BigQuery. Similar thing, we need to authenticate. We'll write some helper functions, this time to download data from BigQuery. We'll specify the seasons we're gonna look at. So, in this case, the completeness of the data is pretty solid, starting about 2013, 14. So, we'll start there. Gives us about nine years of data, which is what we were looking at before.
Here's another thing that I do commonly. Sometimes I'll write my SQL with parameters in R, or Python in some cases. And then, using something like Glue or Format, you can then put in the parameters you want. So, if you change the seasons up top, you'll get different data. And these will sort of write the SQL. So, we have one for getting team data. We have a query for getting player games data. We have another query for getting team and league stats together. That's one of the longer ones. Skip, skip, skip.
And then, we eventually get all that data in. And then, we look at some metadata around the stats we wanna create. Sorry, I know I'm scrolling. Should've looked at this a little bit better.
Okay. One thing I wanted to show. So, we eventually get to this sort of table here, where we're gonna have a table, and I'll actually look at this in the console.
So, we have a long table of team season stats. Let me get one more, actually. This is the table of team game stats. So, we get to this point where this is one row per team, per game, per stat. So, you can see that this has a game ID. This is Jackson State. This is when they played Bethune-Cookman, and we're looking at their offensive efficiency, which was 118 over 60 possessions.
And then, what we're going to do here is, this is a fairly large data set on team game level of about 300,000 rows, but we wanna do this adjustment by season. We're not adjusting this year's Jackson State team versus Bethune-Cookman over the last eight years. We're gonna adjust it versus this year. So, one of the tricks here we'll go into is sort of this nesting concept.
And what I mean by nesting is, if you look here, we then nest this team game data into different levels by sport, by season, and by stat. So, there are 36 rows here, 18 for men, 18 for women, and nine each within those for offensive efficiency and defense efficiency, and one per season. And then, we nest these sort of game level stats in here. And what this kind of does is help organize our data. This is using tidyverse concepts per as well, so that we can fit one row, one regression per row here, which you'll see is in the next step.
So, this function, again, I'm hoping to share this code. There's a lot of details here I'm skipping over, but what it will do is fit that reg regression we talked about using this GlymNet library, and then we'll use, we'll take the model coefficients, kind of pull them out, and do a bunch of manipulations to get them back into the right form, and get team adjusted stats off of this.
What you see here is we run this using multiprocessing with the per package. This future pmap step will basically take each row of this, say, take these games and data and give me back adjusted, you take this data of games for this season, for this stat, and give me back adjusted ratings.
And when you see here, what you'll see is on our next thing, after we fit, again, I ran this before, we get adjusted regression results. So, for each one of these rows, we now have regression results, and if you want to look at one of them, for example, the first one, you can see it gives you two different things. We have home court advantage, with, like I said, an estimate about two points, and then for every team, we get an adjusted rating, a couple different versions of it, and this is the team IDs.
So, we move on from there. We do a bunch of stuff to then take that out, extract it, put it in, and get the team ratings straight. Then we want to adjust for the ratings. I'm going to, again, gloss over some of this. All those calculations we did initially in SQL, I can also do here in R.
Again, I love chaining together sort of the pipe with tidyverse functionality. You can see a bunch of joining, more calculations. Eventually, we get down to player ratings, and I will show you this. So, we have this player season summary thing, and it's pretty long, but you can see it gets season, player, and the last column is that adjusted wins above average. So, now we've calculated the thing we want, and then finally, we will write it back to BigQuery.
So, running a little short on time, so I won't show the results in BigQuery, but I'll jump back over to the slides, and we can at least see the results there, and further discussion.
Schedule-adjusted results
Okay. So, does schedule adjusting matter? This is a question. So, you can see this is actually in that thing, in that last script. I create this plot using ggplot2. So, we take for each dot here represents the players, one player, their raw wins above average versus the adjusted wins above average.
So, there's a very tight correlation, something like 0.9 in a lot of cases here. So, you may think, like, okay, this isn't really doing much, but what you will notice is that for each sort of, like, vertical line, which represents a win above average, there's actually a good amount of spread amongst the adjusted wins above average. If you take a two-win player in women's basketball, the adjusted rating might have them close to an average player, or they could be four-ish wins, which is a really big difference. So, we can see that while there is a strong correlation, this does make a big difference in certain cases, and this is probably something we do want to account for going forward.
So, we can see that while there is a strong correlation, this does make a big difference in certain cases, and this is probably something we do want to account for going forward.
Okay. So, now our more final results, like I said, the top players. So, a couple things to notice. The top three over here for this season's women are exactly the same, but the numbers were higher. Before, they were closer to five wins. Now, they're closer to six or seven. So, all these teams are in hard conferences. So, actually, their schedule was above average, and therefore, you get even more credit, and you get greater differentiation. Some of these top players up here from the last nine years are pushing nine or ten wins on the women's side.
Men's ratings for this year look a little, like, again, Sheboy from Kentucky's there, though. You see Malchi Smith. So, it isn't impossible to be here if you're in a smaller school. You just have your performance get adjusted relative to the competition you face. You see some other bigger school players here. And then, the historic list, as I'm a fan of college basketball, sort of going back, I think it's really interesting. You see Zion, who's a sort of marquee player, was an amazing player for his one year at Duke. He won player of the year. Franklin is the one player of the year. So, you see some more common names here. So, we like this list. It's pretty good.
And I think it does illustrate sort of the value of the opponent adjusting as well.
Loose ends and surfacing outputs
All right. We've got a few more minutes here. Loose ends. So, we went through analysis. We showed R. We showed BigQuery. But we didn't talk about how to sort of surface the outputs. This would be sort of the one endgame of this process. If we had a player rating system we really liked, how would we share it? We could do it in Google Sheets. We could do it in a tool like Data Studio, which is Google's sort of free interactive dashboarding tool. It's one of my favorites. So, I think, yeah, it's certainly a good way to build some stuff. It's more point and click based.
Looker, sort of our enterprise business intelligence platforms. You can build your API over the data. That's much more on the business side, but it's a really amazing tool as well.
And then, of course, you know, we're here, RStudio Shiny. So, Shiny allows you to do a ton, right? You can take the functionality of R and build dashboards that allow you to go deep into that data. Let's say you wanted to even run some of that adjustment code on the fly. You can do that with something like Shiny. And if you build your interactive web application there, you can publish it to something like RStudio Connect to share within your organization or Shinyapps.io to share publicly.
So, again, we didn't go over this, but this is sort of a large endpoint here.
Running R on Google Cloud
And then, this is for sort of the people coming for R on Google Cloud. So, I showed an example of how to use R sort of with Google Cloud, with, because we had BigQuery, we had R, we were moving data maybe between the two. That's not the same as running R or RStudio on Google Cloud. So, here's a few options for how to do that.
So, RStudio Workbench is sort of the professional product, the most high-end version of this, where you can deploy RStudio directly on Google Cloud Platform.
But you can also do, you know, if you're smaller scale, you have access to Google Cloud and you have access to an RStudio server, open source version, you can then install it on Compute Engine. And then, that would be similar to what you're doing right now, just on a virtual machine somewhere.
If you're scheduling R scripts, there's ways to do that with Docker on Google Cloud with a bunch of tools like Container Registry. And another one, this last one, is one that I actually like a lot, because I'm a Jupyter Notebook fan. You can use our sort of Google Cloud product called Vertex AI Workbench to run Jupyter Notebooks back into my R. You can configure up your memory up and down. So, again, you might have some calculations where you run out of memory to do that.
One other plug here, Mark Edmondson, he's a really tremendous Google Developer expert in Denmark, focused on R and Google Cloud. He wrote some of the packages that allow you to interface with Google Cloud Storage with R and a bunch of tutorials, really, really helpful stuff. He is an expert in this space. So, I would recommend following him and looking up his website information if you're interested in particular about different ways to use R on Google Cloud.
Additional resources and wrap-up
This is a bunch of stuff. I will briefly go over NCW Basketball Analysis. I recently did some work with MLB Partnership. Like I said, my intent is to share these slides. You can click through and watch and read at your leisure. We have a series on soccer data recently released where you can use soccer data similar to this, where you'll ingest the data into BigQuery. You'll do some analysis in BigQuery, even build an expected goals model. So, that's one thing to look out for if you're interested in how to use BigQuery. You'll see links to that in my Twitter and LinkedIn as well.
All right. Like I said, I'm a little over, but let's wrap up. So, let's find the tools and methods first.
R and RStudio work well with BigQuery. BigQuery is made for very large storage and analytics. So, we looked at regression. In this case, we did reg regression. So, what's interesting here is when you look at regression, all the hype these days around modeling prediction. Regression is really good as like a summarization tool. This is kind of how we use it here. It's not explicitly building prediction model. And I found this very useful in lots of sports analytics tasks.
There's lots of ways to do things. And like I said, you saw I did one example where I did stuff in BigQuery a little more, then I did some in R a little more. There's always trade-offs. It depends on what you want to do with the data, where it may be at the time, what you're comfortable with, what your colleagues are comfortable with. So, that's kind of a journey you go on as a data scientist.
And yeah, this is pretty hard. I think there's a lot here that we went through, but we got to rate all Division I men's and women's basketball players over nine years with open source data, R, and a version of BigQuery that you could probably use within the free tier in terms of number of storage. So, that's pretty cool, I think.
Sports analytics takeaways
Okay, and finally, my sports analytics takeaways. So, there's large open source data resources. I talked about the Sports Dataverse. Shout out to Sime again. Allows you to do this stuff. Allows anyone to kind of get started if you have R without doing a ton of setup.
We noticed how having sports knowledge and using established work in this field isn't really important, right? So, I didn't have to build a framework from scratch about how to turn box score stats into wins. There are better and more advanced ones than the ones I use, but the ones I use are pretty well respected and established, and we can implement them.
So, again, I heard a quote that said, like, good developers copy, great developers paste. So, I think the same things apply to data scientists sometimes. Of course, we had to modify a bunch, but it gives us a huge head start.
like, good developers copy, great developers paste. So, I think the same things apply to data scientists sometimes. Of course, we had to modify a bunch, but it gives us a huge head start.
Schedule adjustment is important, especially in college, and Alia Boston and Oscar Shiboi are really good at basketball. That's what we learned. All right.
Thanks again for having me. I know I went a little over. I wanted to try to cover a bunch of things for all different audiences here. This is where you can find me on Twitter, and you can find me on LinkedIn. Definitely want to, I think we have some time to open up for questions.
Awesome. Thank you so much, Alec. I always like to say in virtual settings, you can't hear us clapping, but we all are.
Thank you so much. And I think there's so many great resources in those slides, too. So, I know you'll share those with us, but I can also take out all the links and share that with the recording, too, for everyone.
Sure. I see a few great questions coming through on the Slido, and just a reminder if anybody wants to ask questions there, either anonymously or with your name, I'll put the link in the chat again right now.
But Larry, I see you had asked a question in Slido. Would you want to come in live and ask that?
I'd have to go. Thank you. I'd have to go back and look at that again. Oh, no worries. I can read it. Yeah. Let me try. Okay. And if I miss it, because I'm distracted and this isn't my field, I work in nutrition and time series of data. So, I'm interested in how you evaluate the performance of the player year over year, or even within a year as the season progresses, to say that that's statistically significant change in WAA, for instance.
Yeah, that's a good question. Sports is interesting in that it has a season concept. So, it actually ends up being like, in this case, it evaluates each kind of season as its own entity, and then you can look at correlations across. This is common in sports analytics. I think if you wanted to do it as like a time series, and this would be a much like heavier use cases, you could run this rating system every day and see how a player's rating, because it would change not just when they play, but also based on their opponents. And then kind of track that over time.
This is something we have done, or at least my team at ESPN had done in the past with team ratings, is you wanna see how is the team doing day over day. And then if you have some sort of forecasting model, you may wanna rate recent performance more than later performance. Sometimes you don't wanna do that. So, I think there's a lot of interesting research in that area.
And if anyone just wants me to read their question, no worries, I can just read them out as well. But I see some people commenting in the Zoom chat as well if they wanted to ask questions. Walter, would you wanna jump in live?
The question was, did you monetize on this or backtest your regression and prediction in some way?
Did I make money off this directly? No, if I did, I probably wouldn't tell you about it.
So, yeah, I think the question is that did you... So, imagine you wanted to use this to make predictions. That's a good use case. I have not done that here. What we're doing here is more of a summary, more of a backward looking who was the best player type of thing. But imagine that you did want to. It's actually, the answer is similar to the last one. You can set up this whole process to run by day, right? So, then you can have, what was the Zion's player rating on week one after when he started at Duke and then a month into the season and then all towards the end of the season and then have that for the whole, all the players on the teams and then use that to do some game predictions.
We have done that, or again, I've done that in the past with team ratings, run them daily and see how they correspond. And those have done pretty well. ESPN, college football, SPI was built that way. And then eventually BPI, college basketball as well. So, yes, in that sense, we've done that, but not for this player sense, though I think it would be a cool exercise.
I see Danny asked a question on the packages used. So, just a question about why do you use the big R query package instead of big query R?
Yes, it's a solid question. Big query R is solid as well. So, when I talked on one of the last slides about Mark Edmondson, and he had developed a bunch of packages for interfacing with Google Cloud and R, he developed big query R. Big R query, I think, was developed by the RStudio team and maybe in consultation with others. I haven't used big query R too much. I guess I started using big R query and it has kind of met most, if not all of my needs, but there may be some value in using the other one. I'm not saying that I'd necessarily say one is better, but like I said, there's different ways to do things. There always will be.
Thank you. Gier, I see you asked a question, or said you'd like to ask a question in the chat. Do you want to jump in? Yes, yes. First, thanks for the opportunity, Rachel and Alec. Sorry if I mispronounced your name.
Alec, so you created a rating for the players based on specific stats. By doing so, couldn't you, for example, also create a model to predict the players' values and try to sell this information for teams in a form for capitalizing it? Just an idea.
Yeah, and if I release this code, I guess that'll be an idea for everyone. But yeah, no.
So I think that's totally within realm of what is done in sports analytics, right? So Mitch, for example, and myself have worked for teams and you want to have values on players because it's really important for how much you, who you should draft, who you should sign, how much you should pay them, those sorts of things. So there's sort of the internal way. And then there's what you're talking about, which is maybe there's a marketplace for these ratings that people might use for, maybe like college teams can't build these ratings themselves and they do that. So a site like, I should have mentioned this, Ken Pomeroy built the sort of canonical college basketball site, kenpom.com. He has player ratings on his site. You can pay for a subscription to his site. People are monetizing that.
If you want to turn this into a product, right? This is a demo at this point. I think the ratings are really good. I built some of these for Google Cloud when we were doing our SLA partnership a couple years ago. You want to turn this into a product. I could see certainly teams may be paying for it. You can also see the gambling use case where it's like you build the ratings, you don't share them, but they help you make predictions. Like we've talked about a couple other questions. And then you kind of build that, use the player ratings as a way to profit that way. So I think there are pathways. I haven't exactly pursued them for this one.
Thanks for the answer and the honesty.
Thank you so much. Hernan, I see you have your hand raised on Zoom too, if you want to jump in.
Yeah, thank you. So I was just wondering if you have any specific experiences using, well, first using, I guess you would call it soccer data and also doing the analysis. And what have been your, if you've done it, what have been the specific challenges, if you will?
Yeah, so I've used soccer data on and off for almost 10 years now also. So I think one of the major challenges in soccer is that it's low scoring. So unlike basketball here, where we can almost do everything off of points per possession or whatever, soccer, lots of matches end one nil, no nil draws, pretty common, right? Did anyone do anything in this match? So of course they did. They ran around for 90 minutes, they fastballed, tried to do a bunch of stuff. So there's been a lot of work over a while now on sort of like how to measure team and player performance based on the actions that are taken, not just scoring goals.
This expected goals framework has gotten really popular amongst every sort of place in soccer, or you may call it football that I know of. So that is different ways of calculating based on where every shot came from, because you'll have way more shots generally than you'll have goals. Assigning a value for, assigning a value for the probability that the shot would go in, and then sort of aggregating that value. So there's often soccer matches because scoring is so low where the best team doesn't kind of win, right? If you watch one team have more chances, one team had more opportunities, but they just missed them, or the keeper was really amazing. Expected goals helps tell that story. And it turns out it's also very predictive as well from team performance better than goals itself in a lot of cases.
So that's one thing to kind of, to know and to keep in mind. Nowadays, like in every other sport, there's tracking data. So you can get a lot more information about what's going on in the soccer matches than it was, you know, to one. Yeah. And that series I have linked in there on BigQuery does take you through taking soccer event data and building an expected goals model. So if that's of interest, I would recommend taking a look.
One anonymous question on Slido was, how do you decide what to adjust on? For example, like home court advantage,
what are some of the less obvious ones?
Yeah, good question. You can adjust for a lot. So when we, at ESPN, we're building models to predict college football and college basketball games. The main thing to adjust for is like, again, this is going backwards, but then also forwards is who you're playing, right? So the opponent's gonna dictate the most. Home court advantage is usually the second most, second biggest factor if you're talking about things that are sort of quantifiable on the game level. But then there's other things, days rest, distance traveled. Those are things that we started incorporating in the model. The average, if you're thinking about this in terms of gain, you're gonna get your biggest gain from the opponent, then a little more maybe from home court, and then it's sort of marginal.
But days rest is important in some sports, especially if there's a discrepancy, right? So we, you know, sometimes a team has a week off, another team just played recently, so there's an advantage there. Distance traveled, I think some of my colleagues at ESPN have found altitude effects, right? So if you look at which teams have the highest home court advantage in college and pro basketball, it's the teams that play in Utah and Denver almost always. And it's because I think we at least suspect the altitude, the teams that are there are used to playing there, and the road teams have trouble catching their breath.
So those sorts of things are interesting. You can, if you get really into the player modeling aspect, then you open up a whole can of adjustments. You adjust for who's on the court, who's on the pitch, whatever, in sort of these other frameworks like adjusted plus minus, which have become popular over the years as well.
Cool, thank you. See, there was a comment on Slido, not really a question, but Joe said, I'm excited that you've given Diddy Reese as high a ranking as you did.
Yeah, when we do the next one on ice cream analytics, we'll go into that, but I do love Diddy Reese. Diddy Reese is an ice cream place near UCLA, that I really like. Great sandwiches, ice cream sandwiches.
Community resources and salary data
Cool. I see Danny has, you have your hand raised as well, if you want to jump in. Yeah, cheers. Sorry, it's another soccer question. I'm curious about whether or not you've done anything with salaries before, and if you know whether or not the data sets include player salaries. I'm just trying to think of sort of basically looking at like who's the most efficient player, like who provides the best value.
Yep. It's a great area of analysis, cross sports. There are salary data sets available. I don't know as much about soccer. And I know it's a little bit different because you have transfer fees and then also like the actual player salary. So yeah, I don't know, maybe someone else in here who has a little more experience with soccer can point to a research. For other sports, there are sort of websites that keep track of player salaries. So there's like Hoops Hype for NBA. There's Over the Cap for NFL. These are sort of the resources. I wonder if there's one for soccer. I just don't know that.
I'll have a look, thank you. No, Mitch just put one in the chat that is another salary site. But I think the general idea of the analysis is really useful. That's a lot of things that like teams think about as well.
Sounds like we have a lot of soccer fans on as well. So if anyone has any ideas for a talk you'd like to do on soccer, love to have that be the next Sports Meetup too.
I did put two forms into the chat too. One is just meetup feedback if you ever want to give suggestions or let us know about anything. And then the other one was a meetup speaker form if you are interested.
Adjusting metrics and player ratings
Nate, I see you just had a question in the chat as well. Do you want to jump in and ask that? Yeah, sure. Thanks for an awesome presentation. I've been trying to, I'd love to learn a little bit more just about how to make these adjustments in terms of metrics for, just for any kind of metric. I work with volleyball specifically. And just being able to, the difference between playing Kentucky versus playing, I don't know, UC Santa Barbara is like, I'd love to learn a little bit more about how to make those kinds of adjustments. And then at my level, playing one team, we might be playing their A team versus their B team. So is it possible to make that adjustment at an individual level as well?
Yeah, lots of good questions. So like I said, we'll share some of the resources here. I went over the, how to do this schedule adjustment here, what would probably be more useful to use actual code to do that. I have it in like a little bit more description of how to do that. So hopefully that'll answer the first part. The second part about adjusting at the individual level of the same team. Yeah, that's harder because you may not have enough data on the B team, right? You need, in order for this to work, and it works in college basketball because you get eventually enough, every team kind of overlaps with every other team and you can see generally how they transpire.
And then for the player data that we had, we were looking at aggregates. So you have players who accrue a lot of minutes. There's actually a lot of work that you, if you want to do adjustment for how to handle the low minutes players, and usually you don't get them their own rating and all this stuff. It's like, it's actually like more work than the regular part is just to what to do with these like smaller players. So if you're on your own team trying to just, you kind of like, you're a little bit data starved, right? If they don't play in real matches, you won't know. Now you can keep track of practice data or something about how they're doing in scrimmages or something. And maybe that would help. But I think it's harder in those cases where you don't collect as much data.
Thank you, Nate. And just you mentioning that you work with volleyball data as well, just reminded me of the sports analytics channel on the R for data science online learning community. And so I just wanted to make sure I let people know about that too. If someone had recently posted there about working with USA beach volleyball teams. So let me just put the link to join that slack in the chat. And then the channel there is just chat dash sports analytics. And I'll put that here as well. But I also was curious if there's other like sports communities or slack groups or discords or things that people are a part of as well.
Yeah, I'll at least answer with one. So the sports data verse initiative that I discussed, they have a discord group. If you're interested, reach out to Simon Galani, who I mentioned talk S-A-I-E-N. So he's got a bunch of people working on some of those packages we talked about. And there's a group there that chats about different things related to that. It's been, I didn't, a recent sort of recently joined that. It's been some really cool discussions there. And then, you know, we've talked like a lot of the sports analytics has exploded over the last several years back in the day. Like, you know, I knew Mitch and we maybe knew a few other people working in one sport or the other, but it's much bigger than that now.
But in-person conferences, as hopefully as they start to come back are really useful for that. If you can, you know, make the time and effort. MIT Sloan is the big one, super expensive also. So, you know, if you can get someone to pay for it, great. You should go. But there's also many great smaller analytics conferences, some with virtual components too, kind of across the US and abroad too. So look out for that or build your network, see what things people are working on. If you can't attend the conference, maybe watch some of the videos afterwards. Ton, ton of resources, certainly relative to several years ago.
Awesome. If other people have tips or community resources to share, please feel free to put them in the chat too or jump in. I will put a little plug for, we just announced the save the date for the RStudio conference as well. So we're so excited to be able to meet in person again. So that will be July 25th through the 28th in DC. And I know at those we've had like birds of a feather for different industry groups as well. And I'm sure sports analytics will be one of those.
Tracking data availability
Walter, I see you asked one other question too, and I can read it for you. It was, do you know if tracking data is also an option or available for basketball games? And then just said, great talk. Thanks for organizing. Yeah, thanks. So tracking data is hard to come by publicly.
So let's see. The good news, the NFL has released tracking data for the last several years as part of the big data ball, which was the subject of the last sports analytics meetup, I think that we had. We had Tom from the NFL talking about it and they just announced their winners today, actually. So that is cool for football, American football tracking data. Basketball tracking data, I haven't seen released publicly. I think NBA tracking data was available for a while, but then was not made available. Maybe the league or someone will come up with that. You can also look for places like Stats Perform is a company that collects this type of data. Sometimes they release it for research purposes. Or they might have a hackathon where you'll get access to data for some point. I would love to see more publicly available tracking data. Like I said, the big data ball is like the best initiative I've seen around that. There may be others that I'm, there's some soccer tracking data available too, actually, publicly, but there isn't a ton and not that I know of for basketball.
Maybe derived from image recognition. Yes. So there's a really great talk from Neil Johnson at MIT Sloan Conference and others probably two years ago about how to do this using open source tools. I am not a computer vision expert, but definitely could be. Your next project, maybe your next project.
Ethical considerations in player analytics
A question I had, and I'm not even sure if I'm framing this the right way, but as you think about like what to consider as you like adjust your models or adjust the ratings, are there sometimes things that like come up that like athletes decide is the wrong thing for us to be adjusting based on versus what somebody thinks, like one person thinks, and then might sell that data. And like are there ethical considerations around that?
There's definitely considerations around what you might do, how you might model things. So I would say like there's often pushback from those sort of in the industry around ratings like this for many reasons, right? As I said, we argue about the ratings. That's like the best last step of every rating system. So the thing to keep in mind as like you as the analysts, you should know the limits of what you're doing, you should know the limits of what you're doing, but also like the benefits of what you're doing. So your system is not gonna take into account everything a player does. It's not comprehensive, et cetera. It doesn't necessarily know about their motivation, though it may capture some of that based on how they play. So you don't necessarily, you wanna take that to the coach, like these are the best players, let's go one, two, three, four, five or whatever. It's one area. And then also listen about how they think about these things and also study your statistics, which trends year over year. Here, I just measured stuff. I didn't say like, does this correlate really strongly year over year or things like that. Those are really good analyses to do.
And then if you're ever gonna like present a player or something, be careful. How would you like it if someone evaluated you based on every single action you took in RStudio and the BigQuery console, for example? I wouldn't like that. So just think about that. And yeah, often you don't necessarily directly present the players, but they do. You put these ratings out and someone, we've had NFL quarterbacks complain about NFL QBR to directly or indirectly when we released that at ESPN. So being ready for criticism is, so if you go big, then you should know, you should think. Definitely, it's interesting.
How would you like it if someone evaluated you based on every single action you took in RStudio and the BigQuery console, for example? I wouldn't like that.
I wanna make sure I didn't miss anybody's question from either the chat or anything I'd missed in Slido. So feel free to jump in or raise your hand here if there's any other questions.
And thank you so much, Alec, for an awesome presentation and for staying on and answering all the questions too. Really appreciate it. Yeah, thanks so much for having me. Rachel mentioned in RStudio, like I said, big fan. So glad to do this. Everyone else, feel free to reach out. Like I said, the ways I listed, happy to answer questions.
Awesome. I also just wanted to let people know too, if you are trying to do this for yourself, I also just wanted to let people know too, if you are trying to figure out like when these events are, different meetups too, we did create a community calendar that you can use. I just put into the chat there. And so you could either add the whole calendar, but beware that adds everything to your own calendar, or you can add the individual events below. So if that's helpful for anybody, I know sometimes I'm all over the place of where I'm posting everything. So just wanted to share that there too. But thank you all so much for joining. Thank you so much, Alec and Mitch for helping to plan it too. Have a great rest of the day, everyone.