# Analyzing the Value of the Shotgun Formation With Python

Yesterday, I released an article in which I used machine learning in Python to train a model that could predict offensive play-calling. The model had an impressive final accuracy of 75.19%. While analyzing the most important features (or independent variables) of the model, I noticed that the shotgun formation was by far the most significant indicator of an offense’s play call. This piqued my interest; I wanted to take a deeper look at the shotgun formation in the NFL.

First of all, let’s define the shotgun formation. From Wikipedia: “In the shotgun, instead of the quarterback receiving the snap from the center at the line of scrimmage, he stands farther behind the line of scrimmage, often five to seven yards back.”

In the previous article, I found that the Saints passed the ball 78% of the time while in the shotgun formation. This trend happened to be shared by the vast majority of the league. A model trained on data from only the Saints had an average accuracy of 71.72% when applied to all 32 NFL teams because of how many teams follow this tendency for predictability. Intuitively, one might think that this makes sense, though. Passing might be more efficient in a formation where the quarterback is given more space from pass rushers. But forget intuition. Let’s prove it with facts.

First, we’re going to load the same database from the previous article. It’s a dataset with every NFL play through the 2009-2018 seasons. It was compiled with the nflscrapR package. We’ll also reduce the data frame into the only columns we care about.

```import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

df = df[['game_date', 'yards_gained','play_type','shotgun']]```

Let’s start this off by taking a look at the average passing efficiency inside and outside the shotgun formation. We’ll create two new data frames, one with pass plays in shotgun formation, and the other with pass plays not in shotgun formation. We’ll then be able to take the average of the “yards_gained” column in both data frames, which is equivalent to the average yards per pass attempt.

```pass_yes_shotgun_df = df[(df.play_type == 'pass') & (df.shotgun == 1)]
pass_no_shotgun_df = df[(df.play_type == 'pass') & (df.shotgun == 0)]

shotgun_ypa = round(pass_yes_shotgun_df.yards_gained.mean(),3)
non_shotgun_ypa = round(pass_no_shotgun_df.yards_gained.mean(),3)

print("yards per pass attempt in shotgun formation: {}".format(shotgun_ypa))
print("yards per pass attempt out of shotgun formation: {}".format(non_shotgun_ypa))```
```yards per pass attempt in shotgun formation: 6.119
yards per pass attempt out of shotgun formation: 6.784```

Huh. Contrary to our intuition, passing the ball is not more efficient in the shotgun formation. In fact, it was significantly more inefficient from 2009-2018. So, why are teams overwhelmingly more likely to pass the ball while in this less efficient formation? Maybe it’s because running the ball is the only other option and it’s even less efficient. Let’s see. The code will use the exact same concept as before, it will just be adjusted to analyze run plays, not pass plays.

```run_yes_shotgun_df = df[(df.play_type == 'run') & (df.shotgun == 1)]
run_no_shotgun_df = df[(df.play_type == 'run') & (df.shotgun == 0)]

shotgun_ypc = round(run_yes_shotgun_df.yards_gained.mean(),3)
non_shotgun_ypc = round(run_no_shotgun_df.yards_gained.mean(),3)

print("yards per carry in shotgun formation: {}".format(shotgun_ypc))
print("yards per carry out of shotgun formation: {}".format(non_shotgun_ypc))```
```yards per carry in shotgun formation: 5.036
yards per carry out of shotgun formation: 4.099```

Wait, what? From 2009-2018, teams passed the ball 77.81% of the time while in the shotgun formation as opposed to a frequency of 62.82% while in any other formation. Why do they do that when running the ball is apparently more efficient in the shotgun formation? Maybe it’s because passing is also more efficient in the shotgun formation? Nope, because we just showed that passing is less efficient from the shotgun. So, what other explanation could there be?

It’s possible that this discrepancy is the result of defensive adjustments. I’m sure that defenses and coaches are aware that offenses are more likely to pass the ball in the shotgun formation. This might make it harder for them to successfully complete passes in situations where the defense isn’t expecting a run … which is also why running the ball is more efficient in the shotgun formation. Defenses aren’t expecting it.

It turns out that the shotgun formation wasn’t always as popular as it is today. Let’s visualize the league-wide increase in the usage of the shotgun formation and compare it to league-wide passing efficiency both in and out of the shotgun formation. That might sound complicated, but it should make sense when you see the graph. The code for this part is a bit long, so I’m putting it on GitHub to avoid filling this entire page with one block of code. Anyway, here’s the resulting plot:

In the early 2010s, the usage of the shotgun formation exploded. Notice in 2013 particularly that the frequency of the shotgun formation spiked up to around 44%. Passing efficiency was hardly impacted, though. My theory is that it took time for defenses to adjust to this sharp change. Once they did, it became more and more beneficial to pass the ball outside of the shotgun formation because defenses had locked in on the trend.

It appears to me that the shotgun formation has perhaps become too common. While I randomly came across this topic through a completely unrelated project, I’m not the first person to question the meteoric rise of the shotgun formation. I found this article from nearly three years ago which posed the same question. Here’s an interesting quote:

“Notably, most of the league’s very best offenses relied comparatively little on the shotgun this season. The five highest-gaining teams (Saints, Falcons, Redskins, Patriots, Cowboys) all ranked among the eight that used the shotgun least frequently. Four of the five teams that used the shotgun most ranked among the 10 poorest-performing offenses … The key, it turns out, might be moderation: With Tom Brady running the show for Belichick, the Patriots never started less than 43.4 percent, or more than 55.6 percent, of their plays from the shotgun in any season from 2011-15, reaching at least the AFC title game every time.”

After my own research on the subject, I would have to agree. None of the evidence supports excessive passing out of the shotgun formation. It might be time for NFL offenses to adjust.