Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c29c593

Browse files
committed
Removed print statements.
Added a new variable - average number of shifts. This did not appear to have bearing on the output.
1 parent 2c33d60 commit c29c593

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/nhl_model/ann.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ def correctData(df, droppable=[]):
387387
output = df["winner"]
388388

389389
labelsToRemove = ["atTeamname", "atTricode", "htTeamname", "htTricode"] + droppable
390+
currentLabels = df.columns.tolist()
391+
for label in labelsToRemove.copy():
392+
if label not in currentLabels:
393+
labelsToRemove.remove(label)
390394

391395
# Drop the output from the Dataframe, leaving the only data left as
392396
# the dataset to train.
@@ -600,7 +604,6 @@ def _setPredictions(todaysData):
600604
originalDF = _readPredictionsFile()
601605
if originalDF is None:
602606
logger.debug("failed to read predictions file, setting current data")
603-
print("here")
604607
pd.DataFrame.from_dict(outputForDF, orient='columns').to_excel(filename)
605608
return
606609

@@ -686,14 +689,10 @@ def _execAnnCommon(model, predictionFile, comparisonFunction, day, month, year):
686689
todaysGameData = findGamesByDate(day, month, year)
687690
outputForDF = []
688691

689-
print(dumps(todaysGameData, indent=2))
690-
691692
for index, game in enumerate(todaysGameData["games"]):
692-
print("homeTeam data")
693693
for x in teams:
694694
if x['id'] == game['homeTeam']['id']:
695695
print(x['fullName'])
696-
print("awayTeam data")
697696
for x in teams:
698697
if x['id'] == game['awayTeam']['id']:
699698
print(x['fullName'])

src/nhl_model/dataset.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ def _parseInternalBoxScorePlayersNew(teamDict): # pylint: disable=too-many-bran
284284
"assists": 0,
285285
"shortHandedGoals": 0,
286286
"shortHandedAssists": 0,
287-
"powerPlayAssists": 0
287+
"powerPlayAssists": 0,
288+
"shiftsPerPlayer": 0.0,
288289
}
289290
goalieDict = {
290291
"saves": 0,
@@ -302,7 +303,6 @@ def _parseInternalBoxScorePlayersNew(teamDict): # pylint: disable=too-many-bran
302303
}
303304

304305
for playerType, playerValues in teamDict.items():
305-
306306
if playerType in ("forwards", "defense",):
307307
for playerData in playerValues:
308308
spTOI = playerData["toi"].split(":")
@@ -315,6 +315,7 @@ def _parseInternalBoxScorePlayersNew(teamDict): # pylint: disable=too-many-bran
315315
playerData.get("powerPlayGoals", 0)
316316
skaterDict["shortHandedAssists"] += playerData.get("shPoints", 0) - \
317317
playerData.get("shorthandedGoals", 0)
318+
skaterDict["shiftsPerPlayer"] += playerData.get("shifts", 0)
318319

319320
elif playerType in ("goalies",):
320321
for playerData in playerValues:
@@ -364,6 +365,7 @@ def _parseInternalBoxScorePlayersNew(teamDict): # pylint: disable=too-many-bran
364365
skaterDict.update(goalieDict)
365366
skaterDict["numGoalies"] = numGoalies
366367
skaterDict["numPlayers"] = numPlayers
368+
skaterDict["shiftsPerPlayer"] = skaterDict["shiftsPerPlayer"] / numPlayers if numPlayers > 0 else 0.0
367369

368370
return skaterDict
369371

0 commit comments

Comments
 (0)