About the xG Calculator

Who is behind this project?

The xG Calculator is an independent, non-commercial project built by Andre Schlaepfer. It grew out of his undergraduate final project at UFRJ (Universidade Federal do Rio de Janeiro) on expected goals models, supervised by Prof. Dr. Pedro Henrique Gonzalez Silva at the ACE Lab. The goal is simple: give curious fans, students and analysts a single place where they can experiment with shot scenarios and see how several academic xG models evaluate the same situation. No login, no paywall, no data collection beyond what is needed to serve the ads that keep the site running.

What is Expected Goals (xG)?

Expected goals (xG) is a statistical metric that estimates the probability that a given shot will result in a goal, based on factors such as shot location, angle to the goal, distance, defensive pressure, and body part used. Rather than simply counting goals or shots, xG evaluates the quality of each scoring opportunity.

This metric has become a standard tool in professional football analytics. Coaches, analysts, and broadcasters use xG to assess team and player performance more accurately than traditional statistics allow. A team that consistently creates high-xG chances is generating better opportunities, even if the scoreline does not always reflect it.

How Does This Tool Work?

This interactive simulator lets you recreate any shot scenario on a half-pitch. You place attackers, defenders, and a goalkeeper, select which attacker is taking the shot, then submit the scenario to the backend. The backend computes xG values using multiple academic models simultaneously, allowing you to compare how different approaches evaluate the same shot.

Each model uses different inputs and methodologies. Some rely primarily on distance and angle, while others incorporate defender positions, goalkeeper location, and shot context such as technique and body part. Seeing the outputs side by side highlights how model assumptions affect the estimated probability.

Training data

The four models are trained on 23,098 open-play shots from Statsbomb's open-data release, accessed through the mplsoccer Python library. The dataset combines shots from Bundesliga 2023-24, Ligue 1 2022-23, Serie A 2015-16, Premier League 2015-16, the UEFA Champions League 2018-19, UEFA Euro 2020 and the 2022 FIFA World Cup.

Set-pieces and penalties are excluded — the calculator only estimates xG for open-play shots, which is where xG modelling is most informative and where the academic literature is deepest.

Methodology

Not every published xG model fits this calculator. Three filters shaped the selection: the model must (a) work without player-quality features, since Statsbomb open data does not carry them, (b) be replicable from Statsbomb alone, without access to proprietary tracking feeds, and (c) be methodologically distinct from the other implementations so that, for the same shot, the simulator shows genuinely different values rather than near-duplicates.

Each machine-learning model was trained across several classifiers — decision trees, random forests, gradient boosting, logistic regression and AdaBoost — and the version with the strongest Pearson correlation against Statsbomb's reference xG was selected for production. Evaluation metrics include ROC-AUC, mean absolute error (MAE) and root-mean-square error (RMSE). Full details, hyperparameter tables and three worked example shots live in the accompanying UFRJ bachelor's thesis.

Implemented Models

The calculator currently implements four distinct approaches to estimating xG, from zone-based probabilities to convolutional neural networks with positional data:

  • Rathke (2017) — Zone-based xG. The attacking half is divided into eight zones; each shot's xG equals the historical percentage of training shots from that zone that became goals. Simple, robust and used here as a baseline.
  • Karim & Marwane (2023) — Introduces the Kos Angle: shot angle minus the angular space occupied by players in the shooter-to-posts triangle, using fixed widths (0.4 m attacker, 0.5 m defender, 1.4 m goalkeeper). A gradient-boosting classifier trained on the Kos Angle plus distance, pressure, body part and technique reaches Pearson 0.80 against Statsbomb xG.
  • Matteotti & Sotudeh (2024) — Turns every shot into a 30×40 two-channel tensor (channel 1 = ball, channel 2 = defenders in front) with Gaussian smoothing σ=1.25, then learns xG with a convolutional neural network. Both the locally retrained model and the authors' original weights are served for comparison.
  • Aggregated xG — A hybrid drawing features from Hewitt & Karakuş (2023), Anzer & Bauer (2021) and Narayanan & Pifer (2024): shooter and goalkeeper coordinates, distances, angle, nearest-defender distance, player density, body part, technique, pressure and open-goal state. Gradient-boosting classifier, Pearson 0.91.

Why Use This Tool?

Most xG tools show a single value for a shot. This calculator is different because it shows how multiple academic models evaluate the same scenario. This is useful for:

  • Understanding how shot context (position, defenders, angle) affects xG across different models.
  • Learning about xG methodology by experimenting with player placements.
  • Comparing academic xG models side by side in an interactive environment.
  • Importing real match shots to see how models would have evaluated them.

References

  1. Rathke, Alex. "An Examination of Expected Goals and Shot Efficiency in Soccer." Journal of Human Sport and Exercise, vol. 12, no. 2, 2017, pp. 514-529. Available here.
  2. Anzer, Gabriel; Bauer, Pascal. "A Goal Scoring Probability Model for Shots Based on Synchronized Positional and Event Data in Football (Soccer)." Frontiers in Sports and Active Living, vol. 3, pp. 1-15, 2021. DOI: 10.3389/fspor.2021.624475. Available here.
  3. Karim, Hassani; Marwane, Lotfi. "The Kos Angle, an optimizing parameter for football expected goals (xG) models." International Journal of Computer Science in Sport, vol. 22, no. 2, pp. 49-61, 2023. DOI: 10.2478/ijcss-2023-0010. Available here.
  4. Narayanan, Sachin; Pifer, N. David. "An xG of Their Own: Using Expected Goals to Explore the Analytical Shortcomings of Misapplied Gender Schemas in Football." Journal of Sport Management, vol. 38, no. 2, pp. 92-109, 2024. DOI: 10.1123/jsm.2023-0022. Available here.
  5. Matteotti, Matteo; Sotudeh, Hadi. "The Power of Pixels: Exploring the Potential of CNNs for Expected Goals (xG) in Football." Available here.
  6. Hewitt, James H.; Karakus, Oktay. "A machine learning approach for player and position adjusted expected goals in football (soccer)." Franklin Open, vol. 4, pp. 1-16, 2023. Available here.