Baseball pitch classification through cluster analysis

Hierarchical clustering with 5 clusters and Ward linkage for pitches thrown by Barry Zito in 2008.

Pitchers are distinguished by the types of pitches they throw. Some throw mostly fastballs while some throw mostly breaking balls. Some throw four different pitches while some throw fewer. Here, I take an unsupervised approach to classifying pitches thrown by a given pitcher. Using pitch trajectory information (e.g., starting velocity/acceleration, start and end location, spin information) from scraped Pitchf/x data from 2008, I investigate various clustering approaches for grouping pitches. I find that hierarchical clustering with Ward variance minimization linkage works well when using the horizontal/vertical accelerations and the starting speed of the ball as features. However, this approach requires the number of clusters to be known ahead of time.

To automatically determine the number of clusters, I implement density-based spatial clustering of applications with noise (DBSCAN) and devise an approach to adapt the associated model parameters based on the data. To classify the remaining outliers from DBSCAN, I use the centroids of the DBSCAN clusters to run one iteration of K-means clustering. This automatic approach to grouping pitches works well when pitches are well-separated in feature space, and requires some parameter tuning where there are variable-density or poorly-separated clusters. Overall, this approach should be taken as a simple automatic initial step in classifying the pitches of a certain pitcher.

Notebook
Pitch classification notebook