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:
- Different data. Some providers record the positions of defenders and the goalkeeper at the moment of the shot; others do not.
- Different features. One model may include the type of pass before the shot, another may not.
- Different definitions. What counts as a "big chance" or "under pressure" varies.
- Different training sets. Leagues and seasons differ.
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
- Judging performance beyond the score. A team that loses 1–0 while creating 2.3 xG against 0.4 probably played better than the result suggests.
- Spotting finishing that will not last. A striker scoring far above their xG over a few months is often on a hot streak rather than a new level.
- Forecasting. Over a season, xG tends to predict future results better than goals do, because it is less affected by luck.
What xG does not capture
- Chances that never became shots. A dangerous cross that nobody reached has no xG.
- The finisher. Most models describe an average player. Some include player quality, many do not.
- Game state. A team leading 2–0 may sit back and let the opponent shoot from distance, which changes the numbers without changing who is in control.
- Single matches. Over 90 minutes, xG differences are small and noisy.
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.
- An xG model learns from many past shots how often each type of chance becomes a goal.
- Good models are calibrated: their probabilities match how often shots really go in.
- Providers differ in data and features, so compare xG from the same source only.
Further reading
- What are expected goals (xG)? — Opta Analyst
- Logistic regression — Wikipedia: the classic method behind early xG models
- Calibration (statistics) — Wikipedia
