Coding for Major League Baseball

By: Eli Katz

undefined

Hi! I’m Eli, a Master’s Student at Johns Hopkins University studying Applied Mathematics and Statistics, and an incoming Analytics Fellow at the Baltimore Orioles.

I’ve always been an avid sports fan and adept at math, but the combination of the two is not something people always think about. I had never considered how they could work together, that is until 8th grade when I saw the movie Moneyball. Like so many others, that movie (and of course the book it was based on) inspired me to dive headfirst into the field of Sports Analytics. After that movie, I had the singular goal of working in a front office of a major league franchise as an analyst. After many research opportunities and projects over the past few years, I was lucky enough to intern with the San Diego Padres this past summer, and will be continuing my work in baseball with the Baltimore Orioles following the completion of my degree.

Many factors go into making a successful analyst. I’d say the most important is knowledge of the sport, since no analysis can be done without first asking the right questions, and then being able to translate your results into actionable change on the field. However, the next most important skill is programming.

With so much data being created in every play, every dribble, or every pitch, sports analytics needs to be able to collect large data sets and analyze it efficiently to find those important insights.

My first exposure to coding came in the summer following 11th grade, when I signed up to be a part of a program called the Wharton Moneyball Academy. This program was a week long course that included a basic statistics class, an amazing set of speakers including MLB pitching coaches and baseball analytics, as well as an introduction to programming in R. Following that course, I tried to find whatever resources I could to expand my R knowledge. I remember spending hours trying to download years of baseball data and try my hand at replicating some analysis that I had found online.

My goal in college was to gain as many analytics skills as I could, and become extremely versatile as an analyst. Through my time at Johns Hopkins, I’ve learned optimization techniques using MATLAB, how to use machine learning in Python, how to perform statistical analyses using R, and much much more. Even more important than the coding experience from my classes has been the research projects where I’ve been able to apply what I’ve learned.

My favorite project that I’ve worked on has been creating schedules for Minor League Baseball using MATLAB and Gurobi Optimization software. Working with many of the Minor Leagues, our research team works to translate the scheduling parameters that the league presidents want to see into mathematical equations, and then into code which can optimize for the best possible schedule. Additionally, I’ve worked on projects such as finding the best strategy in extra innings when a runner begins on second base (a scenario which we’ll see in the Major Leagues for the first time this upcoming season), modeling bullpen fatigue in order to decide which pitchers are rested enough to pitch on a given day, and projecting how international prospects would perform in the Major Leagues.

Sports Analytics is an exciting and rapidly expanding field. While this analytical revolution began in baseball, you can now find analysts working for almost every team in every sport. There’s no limit to what kind of new insights Sports Analytics can offer in any sport, and that is thanks to the many analysts who have contributed to the Sports Analytics world, and have made their data collection and analysis open for anyone to learn from and use.

My advice to anyone trying to break into the sports world: become familiar with a programming language where you can download and analyze data in your favorite sport, search for an exciting question and see what discoveries you can find!

Tools and Programming Languages I Use:

  • R
  • Python
  • MATLAB
  • Gurobi Optimization
  • SQL
undefined

Outside of work, Eli likes playing video games, playing poker with friends, and watching whatever sports he can find on TV.


Interested in utilizing this resource in your elementary classroom? Check out our elementary version of this blog here. Comprehension is designed for younger students and can easily be incorporated into your curriculum.