Skip to main content
Version: 0.1.5

NHL — additional Python functions

Hand-written wrappers, loaders, and helpers in sportsdataverse.nhl not covered by the generated API-endpoint reference above.

ESPN​

FunctionSummary
espn_nhl_game_rostersespn_nhl_game_rosters() - Pull the game by id.
espn_nhl_pbpespn_nhl_pbp() - Pull the game by id. Data from API endpoints - nhl/playbyplay, nhl/summary
espn_nhl_player_statsPull an NHL athlete's ESPN season stat line as one wide row.
espn_nhl_scheduleespn_nhl_schedule - look up the NHL schedule for a given date
espn_nhl_teamsespn_nhl_teams - look up NHL teams
scoreboard_event_parsingFlatten one ESPN scoreboard event for the schedule frame, in place.

sportsdataverse-data releases​

FunctionSummary
load_nhl_gamesLoad the NHL games-in-data-repo manifest (no seasons argument).
load_nhl_goalie_boxAlias of load_nhl_goalie_boxscores() for naming parity with fastRhockey (R).
load_nhl_player_boxAlias of load_nhl_player_boxscore() for naming parity with fastRhockey (R).
load_nhl_skater_boxAlias of load_nhl_skater_boxscores() for naming parity with fastRhockey (R).
load_nhl_team_boxAlias of load_nhl_team_boxscore() for naming parity with fastRhockey (R).

NHL Web API​

FunctionSummary
nhl_scoreboardIn-game scoreboard payload (renamed from nhl_web_scoreboard).

NHL Records​

FunctionSummary
nhl_records_coach_milestone_winsCoaches who reached a wins milestone in fewest games.
nhl_records_comeback_winsComeback wins from a multi-goal deficit.
nhl_records_consecutive_goal_seasonsSkaters with the most consecutive N-goal seasons.
nhl_records_fastest_goalsFastest N goals by one team in a single game.
nhl_records_fastest_goals_both_teamsFastest N goals combined (both teams) in a single game.
nhl_records_games_played_streak_skatersConsecutive games-played streaks for skaters.

Fox Sports API​

FunctionSummary
fox_nhl_boxscoreNHL boxscore (long: one row per player-stat).
fox_nhl_event_matchupFox Sports nhl pregame team-stat comparison (one row per stat).
fox_nhl_event_recapFox Sports nhl postgame top performers (one row per player).
fox_nhl_event_standingsFox Sports nhl the two teams' standings context.
fox_nhl_league_conferencesFox Sports nhl conference / group directory.
fox_nhl_league_headerFox Sports nhl league header (one row).
fox_nhl_league_leadersNHL statistical leaders (stats-con); who=player|team.
fox_nhl_league_oddsFox Sports nhl league odds board (one row per team per game).
fox_nhl_league_player_newsFox Sports nhl league-wide player news feed.
fox_nhl_league_pollsFox Sports nhl rankings / polls rendered as standings tables.
fox_nhl_league_scheduleFox Sports nhl league schedule nav selections.
fox_nhl_league_scoresFox Sports nhl league scores nav selections.
fox_nhl_league_standingsFox Sports nhl league-wide standings tables.
fox_nhl_league_stat_leadersFox Sports nhl league stats landing leaders.
fox_nhl_oddsNHL game odds six-pack (spread / to-win / total per team).
fox_nhl_pbpNHL play-by-play (one row per play; period-based).
fox_nhl_scoreboardFox Sports nhl scoreboard nav selections (weeks / dates / groups).
fox_nhl_scorechipFox Sports nhl compact live score chip (raw dict -- live-only, uncaptured shape).
fox_nhl_scores_segmentFox Sports nhl one row per game in a scoreboard segment.
fox_nhl_standingsNHL standings for a team's conference/division.
fox_nhl_team_gamelogNHL team game log (long: one row per game-stat).
fox_nhl_team_headerFox Sports nhl team header (one row).
fox_nhl_team_rosterNHL team roster (one row per player).
fox_nhl_team_statsNHL team stat leaders by category.
fox_nhl_teamnavFox Sports nhl team directory (one row per team).

Play-by-play processing​

FunctionSummary
nhl_pbp_diskRead a saved ESPN NHL play-by-play payload from disk.

Models and calculators​

FunctionSummary
ImpactConfigLeague-specific constants consumed by every player-impact engine function.
LeagueConstantsFitted, league-specific constants for the NHL/PWHL prediction spine.
add_shot_geometryAttach distance_to_net / shot_angle / shot_danger (descriptive output only).
adjust_rate_opponentOpponent-adjust a per-game for/against rate by iterative fixed-point, then shrink.
as_of_ratings_splitFilter a frame to rows strictly before cutoff_date (the leakage boundary).
booster_cache_dirResolve the local cache directory for the downloaded nhl_xg_models boosters.
brier_scoreMean squared error between predicted probabilities and binary outcomes.
build_designBuild the sparse RAPM design matrix -- two rows per stint (one per attacking team).
build_stintsFold load_nhl_shifts CHANGE events into contiguous constant-personnel intervals.
calibration_tableBucket predicted probabilities into bins and compare to actual outcome rates.
ensure_xg_modelsReturn a dir holding the 3 published booster files, downloading any missing ones.
get_constantsResolve the fitted-constants row for a league.
load_xg_modelsLoad the two published boosters (+ embedded feature names) and the penalty-shot constant.
log_loss_scoreBinary cross-entropy loss between predicted probabilities and outcomes.
maeMean absolute error between two arrays.
nhl_expected_assistsPer-player expected primary/secondary assists from xG-weighted goal credit.
nhl_goalie_gsaxPer-goalie goals-saved-above-expected (GSAx) for the games in pbp.
nhl_skater_rapmPer-skater xG-based Regularized Adjusted Plus-Minus (RAPM), per 60 minutes.
nhl_skater_warPer-skater GAR/WAR composite -- EV + special-teams + faceoffs + penalties.
nhl_team_ratingsOpponent-adjusted, shrunk even-strength xG (+ goal) team ratings.
nhl_unit_ratingsPer on-ice skater combination: observed xGF/xGA + shrinkage-blended summed RAPM.
nhl_xgScore every unblocked shot in pbp with the published nhl_xg_models boosters.
prepare_xg_featuresPort of helper_nhl_prepare_xg_data -- one row per unblocked shot, model features.
spearman_corrSpearman rank correlation between two arrays.
team_fullname_to_abbrMap an NHL full team display name to its abbreviation, or None if unknown.
team_game_xg_ratesPer-(game, team) even-strength xG-for/against + realized goals.
weighted_ridgeSolve the weighted ridge normal equations (X'WX + lam*I)^-1 X'Wy.

Analytics​

FunctionSummary
expected_goalsPer-team expected goals, blending own offense with opponent defense.
in_game_featuresPer-play in-game win-probability features from game state.
nhl_edge_skating_valuePer-skater EDGE skating-value composite (z-score or percentile blend).
nhl_faceoff_valuePer-player context-adjusted faceoff-win value.
nhl_game_totalPer-game expected total goals -- a thin re-export of model ②'s expected-goals helper.
nhl_in_game_win_probPer-play live home win probability from the bundled in-game logistic.
nhl_penalty_valuePer-player net penalty drawn/taken value.
nhl_player_propsEmpirical-Bayes shots/points player-prop projections.
nhl_predict_gamesVectorized pregame margin/win-prob/total (+ market edge) over a schedule.
nhl_special_teams_valuePer-skater power-play/penalty-kill value (goals) above/below league baseline.
nhl_zone_transitionsPer-player controlled/dump entry & exit rates + xG-weighted values.
predict_marginExpected home-minus-away goal margin.
predict_totalExpected total goals, variance-corrected by the fitted total_scale.
win_prob_from_marginConvert an expected goal margin to a home win probability via Phi(margin/sigma).

Dates and seasons​

FunctionSummary
most_recent_nhl_seasonmost_recent_nhl_season - return the season year for "today".
year_to_seasonyear_to_season - format a starting year as the canonical YYYY-YY season string.