Unveiling the Odds: A Data-Driven Exploration of Field Goal Success in the NFL
In the high-stakes world of American football, every point can make the difference between victory and defeat. One crucial aspect of the game is the field goal — a strategic play that requires precision, power, and nerves of steel. But what are the factors that contribute to the success of these pivotal kicks? Join me on a data-driven journey as we delve into the complexities of field goal success in the National Football League (NFL).
For this analysis, I’ve drawn upon a comprehensive dataset sourced from Kaggle, a leading platform for data science enthusiasts. This dataset contains a wealth of information spanning multiple NFL seasons, including game details, player statistics, and play-by-play data. With this treasure trove of information at our fingertips, we’re poised to uncover the hidden patterns and insights that shape the outcome of field goal attempts.
In our journey through NFL field goal success, we explore the data visually, engineer features, and train a logistic regression model. Leveraging machine learning, we predict success based on game-time variables and kicker performance metrics. Evaluating our model’s performance using accuracy and ROC AUC score metrics, we gain insights into its effectiveness. This process illuminates the intricate blend of skill and strategy underlying field goal outcomes. Our analysis not only deepens our understanding of football dynamics but also showcases the power of data science in unraveling the mysteries of sports performance.
Obtaining the data
The detailed play-by-play data leveraged in this project can be downloaded for free from Kaggle by following this link: https://www.kaggle.com/datasets/maxhorowitz/nflplaybyplay2009to2016?select=NFL+Play+by+Play+2009-2018+%28v5%29.csv
Exploring the data
As we dive into exploring the dataset, we’re greeted with a whopping 255 columns, each packed with valuable NFL play-by-play data. While this might seem like a lot to handle, it’s actually a good thing because it means we have a wide range of information to work with, covering everything from game details to player stats.
To get a quick feel for what’s inside the dataset, we turn to df.head()
. This handy function lets us peek at the first few rows of the data, giving us a snapshot of what's included. It's like taking a sneak peek into a book before diving into the whole thing. This way, we can get familiar with the data's layout and spot any interesting patterns or insights right off the bat.
We plot the average kick success rate for various distance ranges using the plt.bar()
method of Matplotlib. The bar plot reveals a significant trend: as kick distance increases, field goal success rate decreases. This intuitive pattern highlights the challenges kickers face with longer kicks, where precision and power must overcome increased difficulty. Factors like wind and game pressure further complicate longer attempts. Recognising kick distance as a predictor of success informs strategic decisions, emphasising the importance of accuracy amidst adversity on the field.
Feature Engineering
In this feature engineering section, we’re enhancing our dataset to capture the historical performance of kickers leading up to each field goal attempt. We begin by filtering out rows where essential columns like `field_goal_result’ , ‘kick_distance’, and ‘game_seconds_remaining’ contain missing data, using the df.dropna()
function. Then, we map the ‘field_goal_result’ to two classes, ‘made’ as 1 and both ‘missed’ and ‘blocked’ as 0, simplifying the outcome for analysis. Furthermore, one-hot encoding is used to numerically represent the `posteam_type’ column as 1 and 0, indicating whether the team attempting the field goal is playing at home or away, respectively. This transformation ensures compatibility with machine learning algorithms, enabling them to effectively interpret the categorical variable and incorporate it into the predictive model.
To provide context regarding individual kicker performance, the data frame is sorted by player and date. This arrangement ensures that the subsequent calculations consider each kicker’s historical data chronologically. The reset index operation maintains data integrity throughout the process.
Next, we introduce a new column, ‘kick_percentage_last20’, to capture the kicker’s success rate over their last 20 attempts. To calculate this, we iterate through each row in the DataFrame. For every iteration, we isolate the kicker’s last 20 attempts, calculate the mean success rate, and impute it into the corresponding ‘kick_percentage_last20’ column. In cases where a kicker has fewer than 20 previous attempts, we blend their success rate with the league-wide average, ensuring a balanced representation.
Plotting a correlation heatmap of the target variable and the selected feature using the Seaborn library, we see that kick distance has a notable negative correlation with the target column. On the other hand, the remaining three features exhibit very small positive correlations with field goal result. Despite logistic regression’s linear nature, its ability to incorporate interactions and polynomial transformations allows it to capture complex relationships between features. Hence, despite small individual correlations, including features like posteam_type and kick_percentage_last20 can still enhance the model’s predictive ability. These features may offer complementary insights and account for intricate interactions within football dynamics, ultimately improving the model’s accuracy in predicting field goal success. Therefore, even seemingly minor correlations warrant inclusion, as they collectively contribute to a more comprehensive understanding of field goal outcomes.
Training the Model
In this section, we leverage logistic regression to predict field goal success based on key game-time variables and kicker performance metrics. After splitting our dataset into training and testing sets, we employ standard scaling to normalize the feature matrix, ensuring consistent model performance across different scales. The code below utilises scikit-learn’s train_test_split
function to split the dataset into training and testing sets, maintaining 80% of the data for training and 20% for testing. It also employs StandardScaler
from scikit-learn’s preprocessing module to standardise the feature matrix, ensuring consistent scaling between the training and testing data.
Our logistic regression classifier is then trained on the scaled training data, enabling it to learn the underlying patterns in the data. We evaluate the classifier’s performance using two key metrics: ROC AUC score and accuracy. The ROC AUC score provides insight into the model’s ability to distinguish between successful and unsuccessful field goal attempts, with higher values indicating better performance. Meanwhile, accuracy measures the overall correctness of the model’s predictions.
The classifier’s accuracy, standing at an impressive 85% on the test dataset, is complemented by a commendable ROC AUC score of 0.77. Despite the positive class comprising approximately 83% of the dataset, the model’s higher accuracy suggests it effectively identifies both positive and negative instances. This discrepancy arises due to the emphasis on correctly classifying the majority class in accuracy calculation, a characteristic not entirely captured by the ROC AUC metric, which evaluates the model’s ability to rank true positives higher than false positives across various thresholds.
Logistic regression calculates the probability of field goal success by transforming a linear combination of input features into a probability score using the sigmoid function. This score, ranging from 0 to 1, represents the likelihood of successful conversion for each field goal attempt. These probabilities offer actionable insights into the chances of success, informing strategic decisions in game planning and player assessment. In essence, logistic regression provides a probabilistic framework for estimating the distribution of field goal outcomes, facilitating informed decision-making in football scenarios. See below the estimated probabilites of field goal success for five instances in the test dataset.
Among the five attempted kicks, only one fails, and notably, it exhibits the lowest probability of success. However, a challenge in predicting field goal outcomes arises from the positive class (successful field goals) being more prevalent than the negative class (missed field goals), skewing the model’s learning process. Despite this imbalance, leveraging predictive models such as logistic regression allows for insightful estimations of field goal success probabilities, aiding in strategic decision-making and performance evaluation in football scenarios.
Conclusions and Next Steps
In this analysis of field goal success in the NFL, we’ve uncovered key factors shaping the outcome of these pivotal plays. Through data visualisation, feature engineering, and logistic regression modeling, we’ve gained insights into the influence of variables like kick distance and game dynamics on field goal success rates. These findings underscore the importance of leveraging data-driven approaches for strategic decision-making in football.
Looking ahead, incorporating additional variables such as wind speed could further enhance this predictive model as wind conditions often play a significant role in field goal accuracy. By factoring in wind speed, we could improve the accuracy of our predictions and provide more nuanced insights into the complexities of field goal success. This underscores the potential of data science to revolutionise our understanding of sports performance as well as its potential for informing smarter strategies on the field.