Define the shot sample
State which events count as shots and how penalties, own goals, blocked attempts, shoot-outs and missing coordinates are handled. Opta's xG explanation describes one provider model and example inputs; other providers can make different choices.
Build the training row
| Field family | Examples | Leakage check |
|---|---|---|
| Geometry | Distance, angle, location | Use coordinates available at shot time |
| Technique | Body part, set play, assist type | Apply one provider vocabulary |
| Sequence | Cross, through ball, rebound | Do not use later sequence outcome |
| Context | Defender or goalkeeper positions | Record tracking or freeze-frame coverage |
| Label | Goal or no goal | Exclude post-shot information from pre-shot xG |
StatsBomb's open-data repository exposes one inspectable event structure and selected contextual data. Open access does not make provider definitions interchangeable.
Fit a probability model
Logistic regression, boosted trees and neural models can all estimate shot probability. Use a simple geometric baseline first. Fit preprocessing inside training data, preserve feature definitions, and version the model. scikit-learn's common-pitfalls guide documents inconsistent preprocessing and leakage risks.
Worked interpretation
Suppose a model assigns three shots 0.08, 0.22 and 0.45. Their match xG sum is 0.08 + 0.22 + 0.45 = 0.75. That total is the sum of estimated shot probabilities. It is not the probability of at least one goal and does not say the team should have scored exactly 0.75 goals.
Validation
- Split chronologically or by later competitions.
- Compare with a simple distance-angle baseline.
- Report log loss or Brier score and sample size.
- Plot calibration by probability band.
- Inspect penalties, headers, rebounds and rare high-value shots.
- Test provider or model-version drift separately. Calibration guidance supports the probability-band check, and football benchmark research supports controlled feature and model comparisons.
Calibration guidance explains probability reliability. Football benchmark research supports controlled feature and model comparisons.
Keep the intents separate
Use xG explained to interpret an xG value and xG research workflow to test lagged xG features for future prediction. This page owns model construction.
Define the training label without ambiguity
The usual shot-level target is whether the recorded attempt became a goal under the provider's event rules. Decide how to handle penalties, own goals, blocked shots, rebounds, shoot-outs and missing coordinates before fitting. A provider's definition and data corrections are part of the model contract.
| Audit | Reader-facing question |
|---|---|
| Label exclusions | Which attempts can enter the model? |
| Location quality | Are coordinates complete and consistently oriented? |
| Body part and assist type | Which categories exist and how are unknowns handled? |
| Competition coverage | Where was the model trained and tested? |
| Version boundary | Can historical values change after a model update? |
Opta's xG explainer provides one established provider description of model inputs. It supports provider-specific interpretation, not a universal feature list.
Test transfer and drift
Train on earlier shots and test on later competitions or seasons without letting later encodings affect the earlier pipeline. Report calibration and score by shot type, league and model version. A model can be well calibrated overall while overstating headers or understating penalties.
When the provider changes event collection or the xG implementation, retain the version boundary. Recalculating an archive can improve consistency for description, but a prediction backtest must still reproduce the values available at each historical cutoff. scikit-learn's common-pitfalls guidance supports keeping later information and changed transformations out of historical evaluation states.
Continue learning
- Next guide: Live AI Football Predictions
- Related guide: NLP for Football Prediction
Assumptions and limitations
The three-shot example is illustrative. Event data can omit goalkeeper, defender and off-ball context. Calibration can change by competition, provider and time, so versioned future-sample testing remains necessary.

