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