Spaces:
Running
Running
Commit
·
60f5ddc
1
Parent(s):
3d79939
Update data
Browse files- get_record.py +36 -12
- update_data.bat +3 -0
get_record.py
CHANGED
@@ -23,32 +23,56 @@ for game_id,home,away,season,week,total in tqdm(gbg_and_odds_this_year[['game_id
|
|
23 |
if week!=1:
|
24 |
predictions[game_id] = predict(home,away,season,week,total)
|
25 |
|
26 |
-
#
|
27 |
predictions_df = pd.DataFrame(predictions).T
|
28 |
predictions_df['predicted_winner'] = [i['Winner'][0] if type(i['Winner'])==list else None for i in predictions_df[1]]
|
29 |
predictions_df['predicted_winner'] = predictions_df['predicted_winner'].map(team_abbreviation_to_name)
|
|
|
30 |
predictions_df['predicted_over_under'] = [i['Over/Under'][0] if type(i['Over/Under'])==list else None for i in predictions_df[2]]
|
31 |
-
predictions_df =
|
|
|
32 |
predictions_df['over_under'] = ['Over' if t>tsc else 'Under' if t<tsc else 'Push' for t,tsc in predictions_df[['total','Total Score Close']].values]
|
33 |
predictions_df['game_date'] = pd.to_datetime(predictions_df['game_date'])
|
34 |
|
35 |
-
|
36 |
-
predictions_df['
|
37 |
-
predictions_df['
|
38 |
-
predictions_df['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
winners_correct = predictions_df['winner_correct'].sum()
|
41 |
-
winners_incorrect = predictions_df['winner_incorrect'].sum()
|
42 |
-
over_unders_correct = predictions_df['over_under_correct'].sum()
|
43 |
-
over_unders_incorrect = predictions_df['over_under_incorrect'].sum()
|
44 |
max_date = predictions_df['game_date'].max()
|
45 |
-
|
46 |
-
latest_game = date_obj.strftime("%A, %m/%d")
|
47 |
|
48 |
record = {"winners_correct":str(winners_correct),
|
49 |
"winners_incorrect":str(winners_incorrect),
|
|
|
|
|
50 |
"over_unders_correct":str(over_unders_correct),
|
51 |
"over_unders_incorrect":str(over_unders_incorrect),
|
|
|
|
|
52 |
"latest_game":latest_game}
|
53 |
|
54 |
import json
|
|
|
23 |
if week!=1:
|
24 |
predictions[game_id] = predict(home,away,season,week,total)
|
25 |
|
26 |
+
# merge data
|
27 |
predictions_df = pd.DataFrame(predictions).T
|
28 |
predictions_df['predicted_winner'] = [i['Winner'][0] if type(i['Winner'])==list else None for i in predictions_df[1]]
|
29 |
predictions_df['predicted_winner'] = predictions_df['predicted_winner'].map(team_abbreviation_to_name)
|
30 |
+
predictions_df['predicted_winner_probability'] = [i['Probabilities'][0] if type(i['Probabilities'])==list else None for i in predictions_df[1]]
|
31 |
predictions_df['predicted_over_under'] = [i['Over/Under'][0] if type(i['Over/Under'])==list else None for i in predictions_df[2]]
|
32 |
+
predictions_df['predicted_over_under_probability'] = [i['Probability'][0] if type(i['Probability'])==list else None for i in predictions_df[2]]
|
33 |
+
predictions_df = predictions_df.merge(results, left_index=True, right_on='game_id').merge(gbg_and_odds_this_year[['game_id','Total Score Close','home_team','away_team','game_date','Home Odds Close','Away Odds Close']]).dropna(subset=['predicted_winner'])
|
34 |
predictions_df['over_under'] = ['Over' if t>tsc else 'Under' if t<tsc else 'Push' for t,tsc in predictions_df[['total','Total Score Close']].values]
|
35 |
predictions_df['game_date'] = pd.to_datetime(predictions_df['game_date'])
|
36 |
|
37 |
+
# get returns
|
38 |
+
predictions_df['home'] = predictions_df['home_team'].map(team_abbreviation_to_name)
|
39 |
+
predictions_df['away'] = predictions_df['away_team'].map(team_abbreviation_to_name)
|
40 |
+
predictions_df['picked_home'] = (predictions_df['home']==predictions_df['predicted_winner'])
|
41 |
+
predictions_df['picked_away'] = (predictions_df['away']==predictions_df['predicted_winner'])
|
42 |
+
|
43 |
+
predictions_df['winner_correct'] = (predictions_df['predicted_winner']==predictions_df['winner'])
|
44 |
+
predictions_df['winner_incorrect'] = ((predictions_df['predicted_winner']!=predictions_df['winner']) & (predictions_df['winner']!='Tie'))
|
45 |
+
predictions_df['winner_tie'] = (predictions_df['winner']=='Tie')
|
46 |
+
predictions_df['over_under_correct'] = (predictions_df['predicted_over_under']==predictions_df['over_under'])
|
47 |
+
predictions_df['over_under_incorrect'] = ((predictions_df['predicted_over_under']!=predictions_df['over_under']) & (predictions_df['over_under']!='Push'))
|
48 |
+
predictions_df['over_under_push'] = (predictions_df['over_under']=='Push')
|
49 |
+
|
50 |
+
predictions_df['winner_return'] = [ao-1 if (pa and wc) else ho-1 if (ph and wc) else -1 for ao,ho,pa,ph,wc in predictions_df[['Away Odds Close','Home Odds Close','picked_away','picked_home','winner_correct']].values]
|
51 |
+
predictions_df['over_under_return'] = [0.91 if ouc else -1 for ouc in predictions_df['over_under_correct']]
|
52 |
+
|
53 |
+
threshold = 0.6
|
54 |
+
|
55 |
+
winners_correct = predictions_df.loc[predictions_df['predicted_winner_probability']>threshold, 'winner_correct'].sum()
|
56 |
+
winners_incorrect = predictions_df.loc[predictions_df['predicted_winner_probability']>threshold,'winner_incorrect'].sum()
|
57 |
+
winners_tie = predictions_df.loc[predictions_df['predicted_winner_probability']>threshold,'winner_tie'].sum()
|
58 |
+
winners_return = predictions_df.loc[predictions_df['predicted_winner_probability']>threshold, 'winner_return'].sum()
|
59 |
+
|
60 |
+
over_unders_correct = predictions_df.loc[predictions_df['predicted_over_under_probability']>threshold,'over_under_correct'].sum()
|
61 |
+
over_unders_incorrect = predictions_df.loc[predictions_df['predicted_over_under_probability']>threshold,'over_under_incorrect'].sum()
|
62 |
+
over_unders_push = predictions_df.loc[predictions_df['predicted_over_under_probability']>threshold,'over_under_push'].sum()
|
63 |
+
over_unders_return = predictions_df.loc[predictions_df['predicted_over_under_probability']>threshold,'over_under_return'].sum()
|
64 |
|
|
|
|
|
|
|
|
|
65 |
max_date = predictions_df['game_date'].max()
|
66 |
+
latest_game = pd.Timestamp(max_date).strftime("%A, %m/%d")
|
|
|
67 |
|
68 |
record = {"winners_correct":str(winners_correct),
|
69 |
"winners_incorrect":str(winners_incorrect),
|
70 |
+
"winners_tie":("-"+str(winners_tie) if winners_tie>0 else ''),
|
71 |
+
"winners_return":str(round(winners_return,1))+"x return",
|
72 |
"over_unders_correct":str(over_unders_correct),
|
73 |
"over_unders_incorrect":str(over_unders_incorrect),
|
74 |
+
"over_unders_push":("-"+str(over_unders_push) if over_unders_push>0 else ''),
|
75 |
+
"over_unders_return":str(round(over_unders_return,1))+"x return",
|
76 |
"latest_game":latest_game}
|
77 |
|
78 |
import json
|
update_data.bat
CHANGED
@@ -1,7 +1,10 @@
|
|
1 |
python "C:\Users\Brayden\OneDrive - stern.nyu.edu\Brayden Moore LLC\Python\Projects\MARCI 3.0\MARCI-NFL-Betting\Source\Build\update.py"
|
|
|
2 |
cd "C:\Users\Brayden\OneDrive - stern.nyu.edu\Brayden Moore LLC\Python\Projects\MARCI 3.0\MARCI-NFL-Betting"
|
3 |
git add "Source\Data\gbg_and_odds_this_year.csv"
|
4 |
git add "Source\Data\gbg_this_year.csv"
|
|
|
|
|
5 |
git commit -m "Update with 2023 data"
|
6 |
git push
|
7 |
pause
|
|
|
1 |
python "C:\Users\Brayden\OneDrive - stern.nyu.edu\Brayden Moore LLC\Python\Projects\MARCI 3.0\MARCI-NFL-Betting\Source\Build\update.py"
|
2 |
+
python "C:\Users\Brayden\OneDrive - stern.nyu.edu\Brayden Moore LLC\Python\Projects\MARCI 3.0\MARCI-NFL-Betting\get_record.py"
|
3 |
cd "C:\Users\Brayden\OneDrive - stern.nyu.edu\Brayden Moore LLC\Python\Projects\MARCI 3.0\MARCI-NFL-Betting"
|
4 |
git add "Source\Data\gbg_and_odds_this_year.csv"
|
5 |
git add "Source\Data\gbg_this_year.csv"
|
6 |
+
git add "Source\Data\results.csv"
|
7 |
+
git add "Source\Data\record.json"
|
8 |
git commit -m "Update with 2023 data"
|
9 |
git push
|
10 |
pause
|