Machine Learning (Part 8)

Baseball Signs

Stealing Baseball Signs

Can we predict when a baseball player is going to try to "steal"?

Mark Rober and Jabril created an application to predict when a Baseball player had been directed to "steal".

Stealing Baseball Signs

Stealing Baseball Signs with a Phone (Machine Learning)

Stealing Baseball Signs with a Phone (Machine Learning)

How does the application work?

Jabril hosts a copy of his application on his web site and the source code of the application is available on GitHub.

I reviewed the code to see how the application worked.

Sequence

Mark and Jabril created a way to encode Baseball signals using letters. 

Each Baseball coach will use a unique set of signals to communicate with her players.

The coach in the example below signals to her players by touching her nose, touching her right ear, touching her right arm, touching her chin, touching her left ear, touching her left arm, touching her chest, touching her hat or touching her belt.

Baseball signal encoding

Encode

Internally the application works with sequences of letters. To make the application easier to operate a user can enter a description for each signal.

A description for each signal

Apply

When Apply is pressed the Encode() function is run.

The Apply button

Encode() 

When the Encode() function executes the descriptions provided by the user are copied to the the web page's HTML.

When the Encode() function executes

CheckSeq()

The user watches the coach communicating with the players and records the signals.

As a sequence is entered into the app the CheckSeq() function is used to make a live prediction.

The dict variable contains an entry for every possible two letter combination. A value of 1 is used to mark all combinations that are present in the *current* sequence.

Dataset

After the pitch is made the user watches to see if a player attempts to steal a base. 

If there is an attempt to steal a base the user clicks the "Steal" button.

If there is no attempt to steal a base the user clicks the "Not Steal" button.

Every time the Steal or No Steal button is pressed the app has new intelligence and the Label() function is called.

The Label() function adds the current sequence and label (steal 1 or no steal 0) to the page's HTML, adds the current sequence and label to a "dataset" variable and then calls the FindSteal() function.

The Label() function adds the current sequence and label (steal 1 or no steal 0) to the page's HTML

The Label() function adds the current sequence and label to a "dataset" variable and then calls the FindSteal() function.

FindSteal()

The variable "top" in the FindSteal() function is used to score all possible two letter combinations as candidates (based on all of the labeled sequences in the dataset).

The web page is updated to show the most likely candidate.

The variable "top"

updated prediction

Machine learning?

The application developed by Jabril and demonstrated by Mark is a nice reinforcement learning example (just as Hexapawn is).