Attendance Prediction for Professional Sports Leagues
By: Aishwary Bahirat
Tags: Data Processing, Predictions, Analytics, Data Model, Train Test Split

Authors: Prashant Kumar, Aishwary Bahirat

Ticket sales and attendance prediction have always been a major challenge for sporting teams and leagues around the world. Having an estimate of ticket sales or predicted attendance helps stakeholders and marketers decide on logistics and marketing spends. These parameters help the teams and league to plan out marketing strategies effectively over a season’s timeline and meet expectations by achieving KPIs and reducing wastage.

We at MIQ tried to design an approach that considers factors like upcoming match variables, previous match statistics, cumulative performance, environmental, and other macro factors to predict attendance for the imminent match. The match performance stats were collected from www.baseball-reference.com and other macro datasets were collected using MIQ’s partnership with various data providers.

The data ingestion and modeling were automated using MIQ’s tech stack, once these data points were collected dynamically, we tried to deploy supervised machine learning models to predict attendance for the next imminent match.

Introduction

Major League Baseball is the professional baseball league in the US & Canada and is made up of the National League and the American League. MLB is composed of 30 teams: 29 in the United States and 1 in Canada. Teams play 162 games each season and five teams in each league advance to a four-round postseason tournament that culminates in the World Series, a best-of-seven championship series between the two league champions. With 81 home games per season, ticket sales and attendance prediction become an important aspect of managing a budget (especially the variable cost associated with the event), logistics and media planning for each participating team.

We performed this exercise for one of the participating teams of our interest and gathered data for five consecutive seasons of MLB (2015-2019). We only considered the Home games for this analysis due to limitations of available data.

Baseball as a sport has a long list of selected specialized terms, phrases, and other jargon related to game, player, and season statistics. These terms are used widely by players, teams, and sports analysts across the vertical. Glossary of baseball terms with explanations can be found here Glossary of baseball terms. This would help you understand the independent variables which were shortlisted by us for the analysis.

Methodology

The next few paragraphs outline our approach for attendance prediction and how these exercises can be performed for other leagues and teams

Based on the steps taken these have been divided into five categories

Data Preparation Data Pre-processing and Exploration Data Modelling Results Key Takeaways

Data Preparation

Based on the source, we divided our variable of interests into 4 categories and collated the data points for each individual game, across 5 seasons.

Previous Game Stats – Taken from www.baseball-reference.com Dynamics for Next Game – MLB official season schedule Environmental Factors – MIQ’s weather data partner Derived Variables – Derived from previous games stats

Previous Game Stats

Previous Game Stats

Dynamics for Next Game

Day/Night fixture for the Next game Event (Y/N) – Whether the next game falls on holidays/special events Next Match Opposition Days to Next Match

Environmental Factors

Temperature forecast Wind speed forecast Humidity forecast Precipitation forecast

Derived Variables

Percentage Cumulative Loss till an imminent match Percentage Cumulative Win till an imminent match Cumulative Win – Cumulative Loss Runs Scored – Runs Allowed Opposition Team Rating (Aggregated on a player level for each team) - http://www.espn.com/mlb/playerratings

Data Pre-processing & Exploration

Data Pre-processing

Conversion of categorical features into factors PDF & CDF inspection – for variable transformation and stats gathering Basic outlier treatment – Based on the inspection done earlier, some of the numerical variables were scaled and data points lying beside 3 standard deviations of mean were removed. Correlation Analysis – Multicollinearity occurs when independent variables in the model are highly correlated causing problems during model fitting & interpretation. Variables with more than 75% correlation among themselves were removed from the data set with their effect being accounted for by including the best predictor among those. Chi-Square test for Categorical Variables – Chi-square test was used to determine whether two categorical variables had any significant correlation between them. The Hypothesis being =>H0: The two Categorical Variables are independent, H1: The two Categorical Variables relate to each other In our analysis, Day/Night conditions of the match and Weekday of the match were suitable candidates to check any association. We got a Chi-squared value of 103.22. Since we got a p-Value less than the significance level of 0.05, we rejected the null hypothesis and concluded that these two are, in fact, dependent. One Hot Encoding for categorical Variables – Many Machine Learning algorithms cannot operate on labeled data correctly. They require all input variables to be numeric, one hot encoding was deployed to convert categorical data into a numerical form (wherever required).

Models & Results

Model Training & Test Split

80% of the available data was used to train the model while 20% was used to verify the results. Mean absolute error (MAE) was chosen as the evaluation metric. MAE is the average of absolute errors |e|=|Y-X|, where Y is the predicted value and X is the actual value. The MAE uses the same scale as the data being measured, in our case, the Match attendance. In addition to this, separate cross-validation strategies were employed with different models for tuning parameters and assessing performance.

Data Modelling

Independent variables – After pre-processing and univariate analysis, the following variables were identified for the modeling purpose

Independent Variables

Target Variable — The aim of the analysis was to predict attendance, hence attendance was chosen as the target or dependent variable.

Models Deployed

Linear Regression –A linear Model was deployed for the problem on each year’s data followed by the combined data set. We observed that the R-square took a hit once we combined the data set of all the years. This was probably because the model was overfitting each individual year’s data. (Figure 1) Regularized Linear Models — In these models, we typically keep the same number of features, but reduce the magnitude of coefficients (by penalizing), in order to avoid overfitting. For our case, we deployed Ridge, Lasso, as well as a series of Elasticnet models by varying the penalty magnitude. The results of these as well as subsequent models are clubbed together in illustration (Model Performance Comparison). Ensemble Models — We deployed Random Forest & Gradient boosting machine ensemble techniques on our training data. A grid search was done to tune parameters going into the Random Forest model. Parallelly, We deployed a large number of shallow decision trees while boosting, with the objective to compare and contrast these popular ensemble techniques. The results of both these models are in illustration (Model Performance Comparison). XGBoost — XGBoost is an implementation of gradient boosted decision trees designed for speed and performance. Boosting is an ensemble technique where new models are added to correct the errors made by existing models. It has recently been dominating applied Machine learning and various Data Science competitions for structured and tabular data. The performance is illustrated in the Model performance Comparison chart below. (Figure 2)

Figure 1 — Linear Regression on each year’s dataset and combined dataset

Figure 2 — MAE comparison between different models

Key Takeaways

Selected Model

Given the problem statement and model comparison, we decided to go ahead with the Elasticnet model as it gives the minimum (10.1%) Mean absolute error on the test data set among all the competing ones. Please note that MAE was not the only assessment criteria for conflicting models. However, for simplicity, we have documented MAE throughout this document.

Final Output

A final dashboard was presented to the client which provides them with attendance prediction for the imminent match. The dashboard updates itself by taking stats from previous matches and the model gets trained over the updated data to provide predictions. These predictions help them to plan media, logistics and also influence the pacing of media campaigns.

Caveats