Skip to content

Instantly share code, notes, and snippets.

@ldacosta
Created February 19, 2018 17:02
Show Gist options
  • Save ldacosta/c76297654794813219cc8972f9f1cf96 to your computer and use it in GitHub Desktop.
Save ldacosta/c76297654794813219cc8972f9f1cf96 to your computer and use it in GitHub Desktop.
from os import path
from Utils.programming.ut_find_folders import *
from ReinforcementLearning.NHL.playbyplay.playbyplay_data import *
# Pointers to the data
repoCode = '/Users/hectorb/Desktop/Younes/Code/NHL_stats_SL'
db_root = '/Users/hectorb/Desktop/Younes/Databases/Hockey'
repoPbP = path.join(db_root, 'PlayByPlay')
repoPSt = path.join(db_root, 'PlayerStats/player')
repoModel = path.join(repoCode, 'ReinforcementLearning/NHL/playerstats/offVSdef/Automatic_classification/MODEL_backup_trainedonallseasons_rankstatprediction')
repoModel = path.join(repoCode, 'ReinforcementLearning/NHL/playerstats/offVSdef/Automatic_classification/MODEL_perceptron_1layer_10units_relu')
repoSave = None #path.join(repoCode, 'ReinforcementLearning/NHL/playbyplay/data')
# List seasons available
lsSea = ut_find_folders( path.join(db_root, 'PlayByPlay'), True )
# Pick season: 2007-2008
iSea = Season(db_root, 2007)
# List all games
iSea.list_game_ids()
lsGames = iSea.games_id
# Loop over games
lineSh = pd.DataFrame()
for iG in lsGames['gcode'].values:
# Build the game
iGame = Game(iSea, iG)
# Get line shifts
lineShft = iGame.lineShifts
lineSh = pd.concat( (lineSh, lineShft.as_df('both', True, True, 20)), axis=0 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment