BraydenMoore commited on
Commit
e0391c1
·
1 Parent(s): a575a22

Speed improvements

Browse files
Source/Build/update.py CHANGED
@@ -26,6 +26,14 @@ year = dt.datetime.now().year
26
  month = dt.datetime.now().month
27
  current_season = year if month in [8,9,10,11,12] else year-1
28
 
 
 
 
 
 
 
 
 
29
  # update current season
30
  build.build_gbg_data(get_seasons=[current_season])
31
  #build.build_gbg_data(get_seasons=range(2014,2024))
@@ -33,7 +41,6 @@ build.add_odds_data()
33
 
34
  # get winners
35
  pbp = build.get_pbp_data([current_season])
36
-
37
  pbp = pbp.drop_duplicates(subset='game_id')
38
  pbp[['season','week','away','home']] = pbp['game_id'].str.split('_', expand=True)
39
  games = pbp[['game_id','away_score','home_score','season','week','away','home']]
 
26
  month = dt.datetime.now().month
27
  current_season = year if month in [8,9,10,11,12] else year-1
28
 
29
+ # get schedule
30
+ print('Getting schedule.\n')
31
+ url = 'https://www.nbcsports.com/nfl/schedule'
32
+ df = pd.read_html(url)
33
+ file_path = os.path.join(pickle_directory, 'schedule.pkl')
34
+ with open(file_path, 'wb') as f:
35
+ pkl.dump(df, f)
36
+
37
  # update current season
38
  build.build_gbg_data(get_seasons=[current_season])
39
  #build.build_gbg_data(get_seasons=range(2014,2024))
 
41
 
42
  # get winners
43
  pbp = build.get_pbp_data([current_season])
 
44
  pbp = pbp.drop_duplicates(subset='game_id')
45
  pbp[['season','week','away','home']] = pbp['game_id'].str.split('_', expand=True)
46
  games = pbp[['game_id','away_score','home_score','season','week','away','home']]
Source/Predict/__pycache__/predict.cpython-311.pyc CHANGED
Binary files a/Source/Predict/__pycache__/predict.cpython-311.pyc and b/Source/Predict/__pycache__/predict.cpython-311.pyc differ
 
Source/Predict/predict.py CHANGED
@@ -31,6 +31,11 @@ file_path = os.path.join(pickle_directory, 'team_abbreviation_to_name.pkl')
31
  with open(file_path, 'rb') as f:
32
  team_abbreviation_to_name = pkl.load(f)
33
 
 
 
 
 
 
34
  # load models
35
  # moneyline
36
  model = 'xgboost_ML_no_odds_71.4%'
@@ -67,8 +72,9 @@ def get_week():
67
 
68
  def get_games(week):
69
  # pull from NBC
70
- url = 'https://www.nbcsports.com/nfl/schedule'
71
- df = pd.read_html(url)[week-1]
 
72
  df['Away Team'] = [' '.join(i.split('\xa0')[1:]) for i in df['Away TeamAway Team']]
73
  df['Home Team'] = [' '.join(i.split('\xa0')[1:]) for i in df['Home TeamHome Team']]
74
  df['Date'] = pd.to_datetime(df['Game TimeGame Time'])
@@ -121,7 +127,6 @@ def predict(home,away,season,week,total):
121
 
122
  # create game id
123
  game_id = str(season) + '_0' + str(int(week)) + '_' + away_abbrev + '_' + home_abbrev
124
- print(game_id)
125
 
126
  try:
127
  moneyline_result = results.loc[results['game_id']==game_id, 'winner'].item()
 
31
  with open(file_path, 'rb') as f:
32
  team_abbreviation_to_name = pkl.load(f)
33
 
34
+ # get schedule
35
+ file_path = os.path.join(pickle_directory, 'schedule.pkl')
36
+ with open(file_path, 'rb') as f:
37
+ schedule = pkl.load(f)
38
+
39
  # load models
40
  # moneyline
41
  model = 'xgboost_ML_no_odds_71.4%'
 
72
 
73
  def get_games(week):
74
  # pull from NBC
75
+ #url = 'https://www.nbcsports.com/nfl/schedule'
76
+ #df = pd.read_html(url)[week-1]
77
+ df = schedule[week-1]
78
  df['Away Team'] = [' '.join(i.split('\xa0')[1:]) for i in df['Away TeamAway Team']]
79
  df['Home Team'] = [' '.join(i.split('\xa0')[1:]) for i in df['Home TeamHome Team']]
80
  df['Date'] = pd.to_datetime(df['Game TimeGame Time'])
 
127
 
128
  # create game id
129
  game_id = str(season) + '_0' + str(int(week)) + '_' + away_abbrev + '_' + home_abbrev
 
130
 
131
  try:
132
  moneyline_result = results.loc[results['game_id']==game_id, 'winner'].item()