| calculate_expected_goals | R Documentation |
calculate_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.
calculate_expected_goals(play_by_play, model = NULL)
calculate_xG(play_by_play, model = NULL)
play_by_play |
data.frame of play-by-play(s) using the current public
schema returned by |
model |
deprecated legacy model selector; ignored |
data.frame with one row per event (play) and added xG column
# May take >5s, so skip.
pbp <- gc_play_by_play()
pbp_with_xg <- calculate_expected_goals(play_by_play = pbp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.