SPORTS ANALYTICS · PROJECT 21

Project 06 · Football analytics
Machine Learning Model · Expected Goals (xG)
Analysis of shots recorded in men's football competitions using public StatsBomb data. The project develops a Machine Learning model that estimates each shot's probability of becoming a goal based on its location and characteristics. The predictions measure shot quality beyond the outcome and show how scoring chances are distributed by match, team and player.
CONTEXT AND OBJECTIVE
Two shots can have different outcomes even when taken from similar positions. Expected goals (xG) use the probability of scoring to assess these chances. The expected goals value assigned to each shot ranges between 0 and 1 and is estimated from shots with similar characteristics.
The project uses shot records from StatsBomb covering various men's football competitions with seasons available from 2015 onwards. The competitions analysed include:
- World Cups: Russia 2018 and Qatar 2022.
- National team tournaments: Copa América 2024, European Championships 2020 and 2024, and Africa Cup of Nations 2023.
- European leagues: La Liga, Premier League, Serie A, Bundesliga and Ligue 1.
- Other competitions: Champions League, Major League Soccer and Indian Super League.
The analysis covered 63,482 shots taken during regular play and extra time, with information on location, shot type, body part used and the context of each action.
The objective is to develop an independent xG estimate, evaluate its performance on matches excluded from training and compare it with StatsBomb's published probabilities. Qatar 2022 World Cup matches involving Argentina, France, Croatia and Morocco are held out to apply the model to an independent sample.
MODEL AND VALIDATION
PREPARING THE SHOTS
The analysis starts with shot records and identifies which resulted in goals. It includes shots in normal and extra time, including penalties taken during the match. Shot location is used to calculate the distance to the centre of the goal and the viewing angle between the posts.
DISTANCE TO THE CENTRE OF THE GOAL
d=\sqrt{(120-x)^2+(40-y)^2}
x and y indicate the shot location in StatsBomb coordinates. The point (120, 40) represents the centre of the opposing goal. Distance summarises how far from goal the shot was taken.
The main variables prepared for the model include:
- Distance to goal and shot angle.
- Foot used, technique and type of play.
- Defensive pressure and player position.
These variables are converted into numerical values. Distance to goal made the largest contribution.
LOGISTIC REGRESSION AND xG ESTIMATION
Logistic regression combines each shot's characteristics to estimate its probability of becoming a goal. The model learns the influence of the variables from shots with known outcomes and uses the sigmoid function to transform their combination into a value between 0 and 1. The final version combines 12 variables for each estimate.
ESTIMATED PROBABILITY OF SCORING
xG_i=\frac{1}{1+e^{-z_i}},\quad z_i=\beta_0+\sum_{j=1}^{12}\beta_jx_{ij}
xG(i) is the estimated probability for shot i. Each beta coefficient represents a variable's fitted weight; the sigmoid function transforms the combination of these variables into a probability.
Performance is evaluated by splitting entire matches, so all shots from the same game remain together in either training or testing. Of the sample allocated to model development, approximately 75% of shots are used for training and the remaining 25% for evaluating predictions.
VALIDATION AND COMPARISON WITH STATSBOMB
Evaluation considers two aspects: the ability to assign higher values to shots that become goals, and how closely estimated probabilities match observed outcomes. The test set contained 1,688 goals and the model accumulated 1,674 expected goals, producing similar aggregate results.
CUMULATIVE EXPECTED GOALS
xG_{\mathrm{total}}=\sum_{i=1}^{n}xG_i
Adding the xG values of all shots by a player, team or in a match gives the total expected goals for those scoring opportunities. This is a statistical expectation and can differ from the goals actually scored.
In the held-out Qatar 2022 matches, the developed model came closer to the observed total number of goals. StatsBomb performed better at ranking shots by scoring probability and measuring the error of those estimates. The comparison distinguishes between matching the cumulative total and estimating each shot accurately.
DELIVERABLES AND LEARNING
The project presents probabilities for each shot, the most influential variables and a comparison with StatsBomb. The charts show shot locations on the pitch and the evolution of expected goals throughout a match.
The model was applied to the Qatar 2022 World Cup final between Argentina and France to analyse the quality of each team's chances. Argentina accumulated 2.81 xG from 20 shots and France 1.87 xG from 10 shots. Both teams scored three goals during the match. The comparison shows the relationship between attacking threat and goals scored.
The xG momentum analysis compares the difference in expected goals generated by Argentina and France in three-minute intervals. The indicator identifies which team created more threat in each interval and how that difference changed throughout the match.
The model combines the quality of each chance with its evolution during the match. The final result can thus be interpreted alongside each team's most threatening periods.

















