transcript

Mark Rober - Stealing Baseball Signs with a Phone (Machine Learning)

Thumbnail of the video “Mark Rober - Stealing Baseball Signs with a Phone (Machine Learning)”
Download Markdown
Community upload. AI output has not been independently verified.

(audience members yelling) No steal. There's no steal there. I predict not a steal. Watch this. And he stayed. He's gonna steal. This is a steal. If this app works, this kid's about to steal. (excited vocalizing) There he goes! It fricking works. It works. Two years ago I came up with an idea for an app where you could decode baseball signs, so you would know when the other team was going to steal even after just the first inning. Then in a covert effort to get people more interested in coding and machine learning, I would make the app free and available to everyone. I'm happy to report it's no longer just an idea. Today I'm gonna show you exactly how the app works and we'll use it in the wild. And then we're gonna talk about machine learning in very simple terms with my buddy Jabril. But first, to set the stage, we need to understand the fascinating world of secret baseball signs. It's the game within the game. Most people know the catcher will give signs to the pitcher when your team is on defense, but when you're on offense, the third base coach gives signs to both the batter and the base runner. For example, he could secretly tell the batter to bunt or to not swing at the next pitch. Or you can tell the base runner to steal. And just to be clear, stealing a base is when you start running as soon as the pitch is thrown, instead of waiting for the batter to try and hit it. It's risky because if the batter doesn't hit the ball and the catcher's good, he can throw you out at second base. Because it's a big advantage, coaches will actually tell their players to watch and see if they could figure out the other team's signs. That's considered a fair play and it's part of the game. The problem is our brains aren't great at figuring out the complex pattern. So we set out to create an app that would use machine learning to do exactly that. And by we, I mean Jabril actually sat down and wrote the code and I just made sure he had unlimited Cheez-Its and LaCroix. Here's how it works. If I saw coach touched his nose, ears, arm, chin and so on, I would assign those to letters in the app. Then I would just watch him sign and record the order. After that, I would just let the app know the outcome. So was it a steal or not? After you do this for enough sequences, the app will start to make predictions. In this case, it's predicting the combination of AD or nose then chin is their steal sign. This worked well enough on my workbench, so now it was time for the first real world test in a kids versus adults Wiffle Ball game. And my friend Sarah takes the game of Wiffle Ball pretty seriously. So she was the captain of the kids team and was signaling for them to steal at just the right moments. (everyone cheering) And I wasn't sure on the ethics of using our app against a bunch of little kids, but they were scoring runs and stealing bases with impunity and then they got so confident, they started talking trash. We want a pitcher not a belly itcher. And no one says that about my pitcher, so at that point, the gloves came off. We found it easiest to film her signs with our phone and then scrub through and capture the order in the app afterwards, as opposed to trying to do it real time. And I'm very happy to report we cracked their code after only three sequences. (upbeat music) And what's cool is once you know the code, you no longer need the app because you can just watch for the steal signal. And when we saw it, we alerted our pitcher with the secret sign of our own. (upbeat music) Yeah. You're outta there buddy. And after that, the tides of the game shifted and we were able to officially prove adults rule and kids drool. So our app cracked the code after just three sequences and I'm gonna show you them to see if you can figure out the steal sign using just your brain. Here's the first one, and this was a steal. Here's the second and this was no steal and this is the third and it was a steal pause and go back if you want to try and figure it out because I'm about to tell you the answer. According to the app which Sarah later confirmed their steal sign was only if she touched her hat and then left ear back to back. Everything else was just a decoy. Now, before we tell you exactly how the app can figure this out so quickly, we need a little background information. So I've cornered my buddy Jabril here and I'm gonna make him give us a super simple explanation of machine learning. Now here's what you should know about Jabril. He's basically a genius who taught himself how to code when he was 14. He has an amazing YouTube channel you should check out with videos like this one where he made a video game where the character teaches himself how to navigate any maze using machine learning and neural networks. All right. Let's say we have Timmy here and Timmy likes certain type of toys but not others. So in our fake example here, he decides this based on how big the toy is and how complicated it is. So from small to big and then over here how many parts it has from just one piece to a really complex toy with gears and moving parts and things like that. And so if we asked Timmy about 20 different toys and start to plot those on the graph we'll start to see a pattern. So generally he likes toys that are big and complicated but does not like toys that are small and simple. And so by looking at his past preferences we can make really good predictions for the future. If you show little Timmy here a toy that is this complicated and this big, we are confident that he'll like it before we even show it to him because it is inside the like boundary. That's the big deal with machine learning. We don't have to take the time and show little Timmy here every toy that's ever been created and record his answers. After we record some likes and dislikes we're able to draw some boundaries. And precisely where we draw these boundaries is the secret sauce. In this case with just two inputs you can just eyeball it and see where to put the boundaries. But when you have thousands of inputs that interact with each other, it's impossible for our brains to comprehend where those boundaries should go. However, it's pretty trivial for a computer using machine learning. In doing research for this video, I talked to probably over 50 baseball players and coaches, and when we asked about signs, it was surprising to me how they all basically use the same strategy. See if you could pick up on it. Every coach has an indicator. I have an indicator so I could do all this, you know, random stuff like this, touch anywhere until I touch this. None of that matters. So it'd be indicator and the next sign, that's a hot sign. So it's indicator arm steal. If I just do the arm, that's nothing. Oftentimes I'll give this, Simon didn't say. If I go indicator, and then immediately to anywhere on my arm, steal. Bunt is to the belly indicator of the belly. So basically nothing matters and it's all a decoy until they touch the indicator. And then the very next sign is the instruction. So after the indicator, you might be told to bunt or to take a pitch or to steal. And so since the steal sign comes immediately after the indicator, we just look at a sequence where steal was recorded here that's showing as one. Then we look through that sequence two letters at a time and store those combos. And we do the same thing for all the sequences where steal was recorded and whatever two letter combo shows up in all of them is their indicator and steal sign. In this case it's AD. So if we decode that, that means nose is their indicator and chin is their steal sign. Now I have a confession. What I just showed you doesn't use machine learning at all. It's just a simple algorithm we realize would work once we discover that pretty much all teams will use an indicator directly before giving the real sign. But based off all the people we talk to if you're trying to decode signs this simple version should work like 90% of the time. But what about the other 10% where they do anything other than indicator followed by sign? That's where you need machine learning because if done properly machine learning can crack any code as long as you give it enough training data. So to really see how good Jabril's machine learning app was, I generated some training data based off an insanely complicated steal sign I came up with to see if he could figure it out. So my secret sign was a mustache rub as the indicator followed by any random sign and then a tooth tap as the steal sign then I can have up to 50 different signals in each sequence and then to throw 'em off even more if I ever touch my right eyebrow, it's not a steal. So you ignore everything in the sequence even if I've already given the steal sign. Now, just to set the stage if we weren't going to use machine learning this would take a normal computer thousands of years to solve because it's the same as if you're asking Timmy about every toy ever made, instead of just drawing the boundaries. Before we see if Jabril can successfully crack my code and how long it will take him let's just go one layer deeper than the Timmy toy example and see how machine learning mimics the human brain in creating neural networks that can draw those boundaries, in the more complicated case of more than two inputs. There are three main parts to a neural network. And hang with me here because I'm going to keep this simple. You have the input layer, which in our case are the signs being given. And then way over here you have the output layer in our case, steal or no steal. And then in the middle we have the hidden layers. And right now that's just a black box. So if a sign was hat, hat, nose, hand we would tweak these input knobs like this. Depending on how each of these knobs is turned each one is interconnected with the knobs to its left. So it causes some simple math to occur at each node. And when you sum up all of those numbers you're left with a number between zero and one. And if that number is really close to zero, that's no steal. And if the number is really close to one, that's a steal. So you give it a bunch of training data where given an input you know what the output should be and you start with these hidden layer knobs turned in totally random directions and when you add them all up, you get something like 0.55. Well that doesn't make sense. You can't have half a steal. And more importantly with the training data you know the answers and you know that this combination should have been a steal. So you just start tweaking these hidden layer knobs until you start to get outputs that are more correct over time. And after going through a bunch of examples where you know what the answer should be eventually you get to a point where any more tweaking of the knobs just makes it less accurate. So you stop. So now you super glue these three hidden layer knobs into place because you've trained your model. And so now with the brand new input where you don't know the answer it gives you the correct output. In this case, a steal. Of course, this is a simple model but this scales up so you could have thousands of inputs and thousands of outputs, and you're able to discover really complicated relationships. What's so cool about this is this is basically how neural networks in our own brains are set up to learn. Once I've been given enough training data to understand the interaction between my hand and arm and keeping something balanced like this then my model is trained and I super glue those middle knobs in my brain then I can introduce a totally new input I've never tried before and I still know what to do. I don't need to be trained on every possible different type of object because my brain has drawn the boundaries. Think about that. For a long time before machine learning and neural networks computers were just following hard-coded instructions given by humans. Now they can learn like humans only they can do it much faster and more comprehensively than we can. Obligatory. And that's why when I gave Jabril the challenge that would take a normal computer using brute force methods thousands of years to solve Yo man, that's fast, please tell me that your indicator is a mustache rub. And then you have whatever. And then a tooth tap. Is that it? That's it. Jabril's machine learning algorithm just created the right boundaries and solved it in less than three minutes. The machine learning model requires more data than our simple version which can solve it after like three sequences. But the upside is that it will eventually decode any set of signs as long as you're capturing the inputs right. And so now it was time for a real life test. So I asked my buddy Destin to do some secretive recon work. Okay, dude, this is the field I used to play at growing up. Today, my son is playing on the rascals. I'm gonna go film third base coaches doing their thing and we'll plug all that data into the machine learning algorithm. These kids are yelling at me wanting me to know what my channel is. And the fact they didn't recognize him just proved to me that whatever was happening in this region was a totally effective disguise. And thanks to Dustin's great interviews and raw footage we were able to get even more data to show that our methods totally worked. And while Destin just brazenly set up a tripod and filmed all these third base coaches. Before you do that, you need to talk to 'em. Say, hey, this what I'm doing. Yeah, 'cause signs are pretty secret, right? Yeah. Oh yes. Yes, sir. Got it. I got in trouble for stealing signs. I was a little more nervous and discreet. If you put a GoPro in a cup, you can actually just watch the footage and frame the shot real time and it just looks like your checking dank memes with a drink in your hand. I've actually used this trick a few times especially on my carnival scam science video. So just like with Dustin's footage, it worked perfectly at the games I went to, and it was just a cool feeling once you'd cracked their code. Okay, steal, they're about to steal. To be able to predict exactly what was coming next. There he goes, there he goes. Knew he was gonna steal. I knew it. I hope you enjoy this excuse to learn more about machine learning as much as I did. I'll put links to both versions of the app in the video description for you to check out. And of course, if there are specific rules against using technology to seal signs in your league I am not telling you to break them. Otherwise, from personal experience, you might risk getting some very important people mad at you. You cheated, Mark Rova!