
Calculate the expected goals for all the shots in (a) play-by-plays
Source:R/Model.R
calculate_expected_goals.Rdcalculate_expected_goals() scores shot events with nhlscraper's rolling
XGBoost expected-goals models. The package ships the small preprocessing
bundle and downloads needed boosters from the companion NHLxG model store
into a local user cache on first use. Each shot is routed to the matching
season vintage and one of six game-state partitions: sd (5v5), ev (other
even strength), pp (power play), sh (short-handed), en (empty net
against), and ps (penalty shot; trained on penalty-shot and shootout-style
rows). The legacy model argument is accepted for backward compatibility but
ignored.
Arguments
- play_by_play
data.frame of play-by-play(s) using the current public schema returned by
gc_play_by_play(),gc_play_by_plays(),wsc_play_by_play(), orwsc_play_by_plays(). Legacy alias-only columns such astypeDescKey,period,SOGFor,SOGAgainst, andSOGDifferentialare no longer backfilled by the xG scorer.- model
deprecated legacy model selector; ignored
Examples
# May take >5s, so skip.
# \donttest{
pbp <- gc_play_by_play()
pbp_with_xg <- calculate_expected_goals(play_by_play = pbp)
# }