Analysis and Predictive Modeling for Play-Calling in the NFL
Five months later and it is time to finally wrap up my time with Flatiron School. I am incredibly grateful and indebted towards all the wonderful faculty and students I’ve met during my time here. Even amid a global pandemic, I was able to turn this scary time into something positive and learn something I thought seem far-fetched. It has been grueling but, at the same time, very rewarding and spectacular to have gone this far and accomplish projects I would not have thought were feasible. I wish the best of luck to my fellow classmates in their future endeavors!
To finish off my time with Flatiron, we were given free reign to pick any topic in order to demonstrate what we’ve learned in a capstone project. I wanted to make the primary focus something that I am deeply passionate about and I immediately knew that I wanted to incorporate football into it. The timing for this project couldn’t have been better with the football season returning during the middle of this program. Over recent years, I have become a more devout fan of the game of the football. I attribute that to my interest in fantasy football, which involves more in-depth knowledge and appreciation of how the sport works. It’s why I can enjoy any live matchup on TV and why I have started watching college football as well.
Project Introduction:
There is no doubt that there has been an increased interest into the analytics side of football. Anyone who watches football on TV has probably seen the advertisements for NFL Next Gen Stats, a collaboration with Amazon’s AWS. These advertisements tout the ability to analyze plays as they occur in real-time, providing stats such as the fastest speed of a given player or even the probability of success of a spectacular play. In addition, Pro Football Focus has received increased attention recently for their grading and statistical metrics in evaluating individual players.
For my project, I wanted to approach play-by-play data from the NFL with an analytics approach. There is a reason that coaches and plays spend countless hours reviewing film for their opponents. These film sessions provide valuable insight into their opponent’s tendencies and can help anticipate what type of play-call is about to occur. What if there was a way to accurately predict whether a play-call would be a run or pass ahead of time given the game situation? How much of an effect does the score differential have in determining a play-call? What about time remaining on the clock and the yards to go for a first down? These are the questions that I aimed to answer in this project.
Dataset Information:
The dataset consists of play-by-play data from the 2009 to 2019 NFL regular seasons. This dataset originates from an R package that can access an API the NFL maintains but is not publicly available. Each of the column corresponds to a certain aspect of the play details such as which team is possessing the ball, time left on the clock, and score at the time of the play. After cleaning and filtering out irrelevant plays, such as field goals and plays stopped due to penalties, I ended up with nearly 350k plays that occurred within the timespan. The overall play distribution for pass to run plays was roughly 59% vs 41%. This dataset is available from Kaggle at the following link: https://www.kaggle.com/maxhorowitz/nflplaybyplay2009to2016
NFL Team Dashboard and Visualizations:
With access to a vast amount of play-by-play data and stats, I wanted to add an additional component to my project. I decided to put it towards creating visualizations that could show how the league and individual teams have changed over the years. There are certain notions about how football has evolved over the years that I wanted to look at, such as a common thought that the NFL has become a “pass-heavy” league. In actuality, the pass-run ratio has stayed relatively consistent from 2009 to 2019, only increasing by roughly 2% in favor of passing plays. Not exactly indicative of a “pass-heavy” league but in the wake of superstar offensive talents such as Patrick Mahomes and Lamar Jackson, this might be why people feel as though the league is skewed in a certain direction.
I also created heatmaps to help visualize which sides of the field a team preferred on offense for both pass and run plays. These visualizations can be incredibly valuable as they highlight which specific areas on the field an offense liked to target. A defense looking at these heatmaps can easily notice which sides of the field to keep a closer eye on in the hopes of making a play or forcing a turnover.
I would like to implement a web dashboard implementation of these visualizations to help provide information for any team in a particular year. These visualizations could help not only a defense trying to find trends in their opponents but also help an offense that is trying to find an edge towards beating an opponent. Any offense will look for weaknesses in their opponent to exploit and what worked for one team may very well work for another.
Predictive Modeling:
This project was a binary classification problem. We were asked to make use of supervised machine learning models for our projects. Each of the models were trained on the details of a play that an NFL defense would have access to prior to the play starting. For example, a team wouldn’t know the yards gained on a play that hasn’t occurred yet but they would know how many yards to go for a first down and what the score differential is at the time of the play.
For the purpose of this project, I tested multiple models, some untuned and others finetuned using ensemble methods. The main metrics that I used to evaluate the models were overall accuracy and recall for pass plays. The reason for recall on pass plays is that, on average, a pass play would yield more yards than a run play. The best model tested was an XGBoost model that had an overall accuracy score of 75% and a pass recall of 80%. It’s worth noting that this model did not perform as well on correctly predicting run plays.
Future Work:
Overall, I was pleased to see the results that I had achieved with these models. Being able to discern a play-call irrespective of prior knowledge of a team’s offensive style is an amazing task. However, there are certain next steps that I would like to take to further my results and improve overall performance. There are key details about each play and game that I believe warrant a closer look. For example, weather conditions play a major factor into how a game would flow. Stormy and windy weather makes NFL teams more inclined to run the ball as opposed to passing. Another key detail that I feel is important would be the personnel sets and formations involved in a play. Personnel sets with more running backs and TEs will most likely better suited for a running play similar to how sets with more wide receivers are better for passing plays.
I’m looking forward to being able to work on new projects as well as reiterate and improve my older projects as I now begin my job search. I have learned so much over these five months and I am excited to see what the future holds for me. I am forever grateful for the opportunity I was given and I am ready to tackle whatever comes next.
Link to the repository: https://github.com/msf894/nfl-playcall-analysis-and-predictions