How Models Work

xG Explained: The Stat That Changed Football Analysis

How an expected goals model is built from thousands of past shots, why different providers give different xG, and what the number can and cannot tell you.

AI Sports Editorial · · 4 min read

Expected goals, or xG, is probably the most successful piece of machine learning in football. It went from analytics blogs to television graphics in a few years and changed how people talk about matches. Most explanations stop at "xG measures the quality of a chance". This one goes a step further and shows how an xG model is actually built, because knowing how it is made explains both its power and its limits.

The question xG answers

For every shot, xG asks: how often does a shot like this one become a goal? The answer is a probability between 0 and 1. A penalty is usually valued at around 0.75 or more, while a speculative effort from 35 metres may be worth 0.02. Add up the xG of all a team's shots and you get the number of goals its chances would produce, on average.

Step 1: collect a lot of shots

An xG model starts with a large history of shots, typically hundreds of thousands, each recorded with details such as:

Feature Why it matters
Distance to goal Closer shots go in more often
Angle to the goal A shot from a tight angle sees less of the goal
Body part Headers convert less often than shots with the feet
Type of play Open play, set piece, counter-attack, penalty
Type of assist A cross, a through ball or a cut-back
Defensive pressure Defenders and the goalkeeper's position (in richer data)

Each shot is labelled with its outcome: goal (1) or no goal (0).

Step 2: train a model

The model learns how each feature changes the chance of scoring. Early xG models used logistic regression, a classic statistical method that turns a weighted sum of features into a probability. Modern ones often use gradient-boosted trees or neural networks, which can capture interactions, for example that a header is much more dangerous from six yards than from twelve.

Example: Invented numbers for illustration. Imagine that in the training data, 1,000 shots were taken from roughly the same spot, with the feet, in open play, and 120 of them were goals. A well-trained model will give a new shot from that situation an xG of about 0.12. The model's job is to make that estimate for every possible situation, including ones with few past examples.

Step 3: check that the probabilities are honest

A good xG model is calibrated: among all the shots it rates at 0.10, about 10% should go in. Builders check this on shots the model did not see during training. If 0.10 shots turn out to score 15% of the time, the model is underrating them.

Why providers disagree

Different companies give different xG for the same match. That is not a scandal; it follows from how the models are made:

Key point: Compare xG figures from the same provider. Mixing numbers from two sources is like comparing distances measured in different units.

What xG is good for

What xG does not capture

For how xG fits into wider match forecasts, read How AI Predicts Football Matches, and for why even good numbers cannot settle a single match, The Limits of AI Predictions in Football.

Further reading