Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NHL Data -> gradient goes NaN #2

Open
lstmlover opened this issue Jan 8, 2023 · 0 comments
Open

NHL Data -> gradient goes NaN #2

lstmlover opened this issue Jan 8, 2023 · 0 comments

Comments

@lstmlover
Copy link

Hi there,
I've played around with the code, but after a few iterations, the gradient becomes NaN and some iterations later all values are becoming NaNs. I've tried to debug the formulas, but yet I couldn't identify the real ploblem.
It works fine with soccer scores, but maybe you can have a look on this problem with NHL scores.
To recreate the problem, you can get the data like this:

import requests
import sys
import csv
from datetime import datetime

path = sys.path[0]
path += "/"

startDate = "2021-10-07"
endDate = datetime.today().strftime('%Y-%m-%d')
url = "https://statsapi.web.nhl.com/api/v1/schedule?startDate="+startDate+"&endDate="+endDate

game = [date,home,away,home_goals,away_goals]

games = []

response = requests.get(url)
data = response.json()

for d in data['dates']:
for game in d['games']:
if game['status']['detailedState'] == "Final":
games.append([game['gameDate'][:10], game['teams']['home']['team']['name'], game['teams']['away']['team']['name'], float(game['teams']['home']['score']), float(game['teams']['away']['score'])])

with open(path+'nhl_results.csv', 'w', newline='') as f:
write = csv.writer(f)
write.writerow(["date", "home", "away", "home_goals", "away_goals"])
write.writerows(games)

----- And you can import the data like this:
data = pd.read_csv('nhl_results.csv', encoding='ISO-8859-1')

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant