PuckQLAsk PuckQL

Methodology

Expected goals (xG)

Methodology note ยท revised 4 December 2026 ยท production model: gradient-boosted trees, 408 iterations

Abstract

We estimate the probability that an unblocked shot attempt in the NHL becomes a goal, using only information recorded before the puck reaches the net. The model is a gradient-boosted ensemble of 408 regression trees on 39 features, trained on 1,386,487 attempts from 2013-14 onward. Two choices shape it more than anything else. First, the league's scorekeeping changed materially after 2019, and a season index lets the trees learn that change instead of mistaking it for a decline in shooting. Second, no shot is ever scored by a model that was trained on it. On five seasons held out entirely (2021-22 to 2025-26), the model reaches an AUC between 0.765 and 0.793 and a calibration slope between 0.94 and 1.02.

1What we are estimating

For an unblocked attempt ๐‘– with pre-shot description ๐‘ฅ๐‘–, the target is

xG๐‘–=Pr⁡(๐‘Œ๐‘–=1|๐‘ฅ๐‘–)(1)

where ๐‘Œ๐‘– is 1 if the attempt is a goal. The quantity is deliberately shooter-agnostic: it describes the chance, not the person taking it. Shooter and goalie identity are left out of ๐‘ฅ๐‘– so that finishing and goaltending can be measured later as departures from xG (see Team ratings). Putting them inside the model would quietly absorb the very signal those ratings exist to find.

The unit is the unblocked attempt: goals, saves and missed shots. Blocked attempts are excluded because the NHL records the location of the block, not the release point, so their geometry describes the defender rather than the shooter. We also drop shootout attempts and penalty shots (identified as one skater against none), which are different events with their own base rates, and the small number of attempts without coordinates. After these exclusions 99.7% of all goals remain in the data.

2Data and coordinate frame

Every attempt comes from the NHL's public play-by-play feed, 2013-14 to the present: 16,272 completed games through 2025-26, every one with play-by-play, plus the current season as it is played. Before any modelling we rebuilt the standings from our own game records and matched all 375 official weekly NHL standings snapshots exactly, which is a reasonable check that no games are missing or duplicated.

The feed reports rink coordinates in feet with the origin at centre ice, but it does not consistently say which end each team attacks. Older seasons omit it entirely. We infer the direction per game and period by a signed vote over all non-faceoff events with a zone code: an event in a team's offensive zone at positive ๐‘ฅ is evidence that the team attacks toward +๐‘ฅ. Where newer feeds do record the home team's defending end, that record overrides the inference. The two agree on 99.9% of 2023-24 periods, and the disagreements are short overtime periods with few events. Coordinates are then reflected so that the shooting team always attacks the net at ๐‘ฅ=89 ft, with +๐‘ฆ to the shooter's left.

3Features

The model sees 38 numeric features plus a season index, 39 in all. The geometric terms are

๐‘‘๐‘–=(89โˆ’๐‘ฅ๐‘–)2+๐‘ฆ๐‘–2(2)๐œƒ๐‘–=atan2⁡(|๐‘ฆ๐‘–|,89โˆ’๐‘ฅ๐‘–)

with ๐œƒ๐‘– in degrees: 0 is straight out from the goal along its normal, and values above 90 mean the shot was released from behind the goal line.

Feature groups
GroupFeaturesNotes
Locationd, ฮธ, x, |y|, behind-net flagx and |y| are kept alongside d and ฮธ; trees find interactions the polar form hides.
Shot type8 indicatorsWrist, snap, slap, backhand, tip-in, deflected, wraparound, other or unrecorded.
Manpowerown skaters, opposing skaters, empty net, own goalie pulledFrom the feed's four-digit situation code.
Game statescore difference, period, seconds into period, seconds into game, overtime, homeScore difference is from the shooter's side, clipped to ยฑ3. Overtime periods share one index.
Preceding eventtime gap, same team, event type (5 indicators), zone (3 indicators), distance travelled, speedThe last non-stoppage event in the same period; a stoppage clears it. Zone and coordinates are re-expressed from the shooter's side.
Derivedrebound, rush, rebound angle changeDefined below.
Eraseason indexStarting year minus 2013. See section 6.

Two derived flags carry a lot of weight, so we define them exactly. An attempt is a rebound when the preceding event was a shot attempt by the same team (blocked attempts included) no more than 3 seconds earlier; for rebounds we also record the absolute change in angle between the two attempts, since a goalie who has to move laterally is the mechanism that makes rebounds dangerous. An attempt is a rush when the preceding event, by either team, happened in the neutral or the shooter's defensive zone no more than 4 seconds earlier. Speed is the straight-line distance between the two events divided by the gap. It is a crude proxy for puck movement and we treat it as such.

When no preceding event exists (the first play after a stoppage), the gap is set to a sentinel of 999 seconds and the "other" category is switched on. Trees handle the sentinel cleanly because it sits far outside the range of real gaps.

4Model and training

We fit a gradient-boosted decision-tree classifier (LightGBM) with the binary log-loss objective. The ensemble's raw score is a sum of tree outputs, mapped to a probability by the logistic function:

๐‘ง๐‘–=โˆ‘๐‘ก=1408๐‘“๐‘ก(๐‘ฅ๐‘–)(3)xG๐‘–=11+exp⁡(โˆ’๐‘ง๐‘–)
SettingValue
Learning rate0.03
Leaves per tree63
Minimum observations per leaf300
Feature and row subsampling0.8 and 0.8, rows resampled every iteration
L2 penalty on leaf values5.0
Iterations408, chosen by early stopping (patience 100) on the validation seasons

These settings were fixed before the comparison in section 5; only the number of iterations was tuned, by early stopping. The 300-observation floor on leaves keeps rare situations, such as 3-on-5 attempts from behind the net, from getting leaves of their own.

The fitted trees are exported to JSON and evaluated by a small JavaScript scorer so that the same model runs in offline jobs and in production. The scorer reproduces LightGBM's own predictions to within 3.5 ร— 10โˆ’7.

5Model selection

We compared three candidates, each trained on 2013-14 to 2018-19 and evaluated on 2019-20 and 2020-21. None of those seasons is part of any later test.

ModelLog lossAUC
Gradient-boosted trees (all features)0.21660.781
Logistic regression, spline terms on all features0.22030.771
Logistic regression, distance and angle only0.23230.724

Validation seasons 2019-20 and 2020-21. Log loss is โˆ’(1/n) ฮฃ [y ln p + (1 โˆ’ y) ln(1 โˆ’ p)]; lower is better. AUC is the probability that a randomly chosen goal receives a higher xG than a randomly chosen non-goal.

The gap between the spline logistic model and the trees is modest, about 1.7% in log loss. We think most of it comes from interactions an additive model cannot represent without hand-built terms: the value of a rebound depends heavily on distance and on the angle change, and the value of a rush depends on manpower. We took the trees because they found those interactions without our having to guess them.

6Scorekeeping drift

The most consequential thing we found was not about hockey. From 2019-20, and sharply from 2022-23, the play-by-play began recording many more quick, close-range attempts that rarely score. The share of attempts classified as rebounds roughly doubled, from about 5% to 10.5%, while the conversion rate on those rebounds fell from 21% to 12%. Missed shots rose from 28% to 35% of unblocked attempts. Nothing about the game changed that quickly; what changed is what gets written down.

A model trained only on the earlier era overpredicted goals in 2021 and later seasons by 5% to 11%. The remedy we adopted, chosen on the validation seasons, is a season index among the features. It has an appealing property: the trees can split on era where the recording changed and ignore it where it didn't. Its cost is an assumption we should state plainly. For a season the model has not seen, the trees behave as they do for the latest season in training, so we are assuming the current scorekeeping resembles the most recent completed season. When the recording changes again we will see it first as a level gap between xG and goals.

7Leakage control

Every shot used anywhere downstream, in the team ratings or in the forecast backtest, carries an xG from a model that never saw it:

  • 2021-22 onward (forward chaining): each season is scored by a model trained on all earlier seasons only.
  • 2013-14 to 2020-21 (cross-fitting): each season is scored by a model trained on the other seasons of that span, so the early seasons also receive honest out-of-sample values.
  • Live games are scored by a production model trained on every completed season.

This matters for the ratings in particular. In-sample xG is slightly too close to the actual outcomes, which would make finishing and goaltending look less variable than they are.

8Out-of-sample performance

For each season from 2021-22 to 2025-26 we trained on all earlier seasons, scored the held-out season, and recorded three statistics. None of these results was used to make any modelling choice.

StatisticRange across the five seasonsIdeal
AUC0.765 to 0.793higher
Calibration slope0.94 to 1.021.00
Total xG รท total goals0.99 to 1.071.00

The calibration slope is the coefficient ๐‘ in a logistic regression of the outcome on logit(xG). Values below 1 mean the predictions are too spread out; above 1, too timid.

Ranking quality is stable and the slopes sit close to 1, so the model is neither over- nor under-confident in the spread of its predictions. The level is the weaker part: in some seasons total xG runs up to 7% above total goals. We leave that alone deliberately. The team-ratings model estimates its own league-wide goals-per-xG term each season, which absorbs a uniform level error without distorting comparisons between teams or shots.

9Limitations

  • No tracking data. Pre-shot passes, screens, goalie position and shot speed are not in the public feed. Our preceding-event features are a thin substitute: a cross-ice pass that precedes a one-timer is invisible unless something else was recorded in between.
  • Recorded locations are human. Coordinates are entered by off-ice officials and vary by arena. We do not currently correct for arena-level recording differences.
  • Blocked attempts carry no xG. Measures built on xG therefore credit shot blocking only indirectly, through attempts that never become unblocked.
  • Era extrapolation. As section 6 explains, a new scorekeeping change will bias the level of xG until a season of data captures it.

References

  1. Friedman, J. H. (2001). Greedy function approximation: a gradient boosting machine. Annals of Statistics, 29(5), 1189โ€“1232.
  2. Ke, G., Meng, Q., Finley, T., Wang, T., Chen, W., Ma, W., Ye, Q., & Liu, T.-Y. (2017). LightGBM: a highly efficient gradient boosting decision tree. Advances in Neural Information Processing Systems, 30.
  3. Hanley, J. A., & McNeil, B. J. (1982). The meaning and use of the area under a receiver operating characteristic (ROC) curve. Radiology, 143(1), 29โ€“36.
  4. Cox, D. R. (1958). Two further applications of a model for binary regression. Biometrika, 45(3โ€“4), 562โ€“565. (Calibration slope.)
PuckQL Computed from official NHL data. PuckQL is not affiliated with the NHL.
Playoff oddsGamesAsk PuckQLMethodologyGlossaryTermsPrivacy