Multichem commited on
Commit
6ad9bdc
·
verified ·
1 Parent(s): 1af1611

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -8
app.py CHANGED
@@ -63,16 +63,21 @@ def init_baselines():
63
  raw_display.replace('', np.nan, inplace=True)
64
  prop_frame = raw_display.dropna(subset='Team')
65
 
 
 
 
 
 
66
  worksheet = sh.worksheet('Pick6_ingest')
67
  raw_display = pd.DataFrame(worksheet.get_all_records())
68
  raw_display.replace('', np.nan, inplace=True)
69
  pick_frame = raw_display.dropna(subset='Player')
70
 
71
- return pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp
72
 
73
- pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
74
 
75
- tab1, tab2, tab3, tab4, tab5 = st.tabs(["Game Betting Model", "Pitcher Prop Projections", "Hitter Prop Projections", "Player Prop Simulations", "Stat Specific Simulations"])
76
 
77
  def convert_df_to_csv(df):
78
  return df.to_csv().encode('utf-8')
@@ -81,7 +86,7 @@ with tab1:
81
  st.info(t_stamp)
82
  if st.button("Reset Data", key='reset1'):
83
  st.cache_data.clear()
84
- pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
85
  line_var1 = st.radio('How would you like to display odds?', options = ['Percentage', 'American'], key='line_var1')
86
  if line_var1 == 'Percentage':
87
  team_frame = team_frame[['Names', 'Game', 'Win Percentage', 'Spread', 'Cover Spread Percentage', 'Avg Score', 'Game Total', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage']]
@@ -105,7 +110,7 @@ with tab2:
105
  st.info(t_stamp)
106
  if st.button("Reset Data", key='reset2'):
107
  st.cache_data.clear()
108
- pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
109
  split_var1 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var1')
110
  if split_var1 == 'Specific Teams':
111
  team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = pitcher_stats['Team'].unique(), key='team_var1')
@@ -127,7 +132,7 @@ with tab3:
127
  st.info(t_stamp)
128
  if st.button("Reset Data", key='reset3'):
129
  st.cache_data.clear()
130
- pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
131
  split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
132
  if split_var2 == 'Specific Teams':
133
  team_var2 = st.multiselect('Which teams would you like to include in the tables?', options = hitter_stats['Team'].unique(), key='team_var2')
@@ -149,7 +154,7 @@ with tab4:
149
  st.info(t_stamp)
150
  if st.button("Reset Data", key='reset4'):
151
  st.cache_data.clear()
152
- pitcher_stats, hitter_stats, team_frame, prop_frame, pick_frame, t_stamp = init_baselines()
153
  col1, col2 = st.columns([1, 5])
154
 
155
  with col2:
@@ -556,4 +561,27 @@ with tab5:
556
  mime='text/csv',
557
  key='prop_proj',
558
  )
559
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  raw_display.replace('', np.nan, inplace=True)
64
  prop_frame = raw_display.dropna(subset='Team')
65
 
66
+ worksheet = sh.worksheet('Prop_results')
67
+ raw_display = pd.DataFrame(worksheet.get_all_records())
68
+ raw_display.replace('', np.nan, inplace=True)
69
+ betsheet_frame = raw_display.dropna(subset='proj')
70
+
71
  worksheet = sh.worksheet('Pick6_ingest')
72
  raw_display = pd.DataFrame(worksheet.get_all_records())
73
  raw_display.replace('', np.nan, inplace=True)
74
  pick_frame = raw_display.dropna(subset='Player')
75
 
76
+ return pitcher_stats, hitter_stats, team_frame, prop_frame, betsheet_frame, pick_frame, t_stamp
77
 
78
+ pitcher_stats, hitter_stats, team_frame, prop_frame, betsheet_frame, pick_frame, t_stamp = init_baselines()
79
 
80
+ tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(["Game Betting Model", "Pitcher Prop Projections", "Hitter Prop Projections", "Player Prop Simulations", "Stat Specific Simulations", "Bet Sheet"])
81
 
82
  def convert_df_to_csv(df):
83
  return df.to_csv().encode('utf-8')
 
86
  st.info(t_stamp)
87
  if st.button("Reset Data", key='reset1'):
88
  st.cache_data.clear()
89
+ pitcher_stats, hitter_stats, team_frame, prop_frame, betsheet_frame, pick_frame, t_stamp = init_baselines()
90
  line_var1 = st.radio('How would you like to display odds?', options = ['Percentage', 'American'], key='line_var1')
91
  if line_var1 == 'Percentage':
92
  team_frame = team_frame[['Names', 'Game', 'Win Percentage', 'Spread', 'Cover Spread Percentage', 'Avg Score', 'Game Total', 'Avg Fifth Inning', 'Fifth Inning Lead Percentage']]
 
110
  st.info(t_stamp)
111
  if st.button("Reset Data", key='reset2'):
112
  st.cache_data.clear()
113
+ pitcher_stats, hitter_stats, team_frame, prop_frame, betsheet_frame, pick_frame, t_stamp = init_baselines()
114
  split_var1 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var1')
115
  if split_var1 == 'Specific Teams':
116
  team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = pitcher_stats['Team'].unique(), key='team_var1')
 
132
  st.info(t_stamp)
133
  if st.button("Reset Data", key='reset3'):
134
  st.cache_data.clear()
135
+ pitcher_stats, hitter_stats, team_frame, prop_frame, betsheet_frame, pick_frame, t_stamp = init_baselines()
136
  split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
137
  if split_var2 == 'Specific Teams':
138
  team_var2 = st.multiselect('Which teams would you like to include in the tables?', options = hitter_stats['Team'].unique(), key='team_var2')
 
154
  st.info(t_stamp)
155
  if st.button("Reset Data", key='reset4'):
156
  st.cache_data.clear()
157
+ pitcher_stats, hitter_stats, team_frame, prop_frame, betsheet_frame, pick_frame, t_stamp = init_baselines()
158
  col1, col2 = st.columns([1, 5])
159
 
160
  with col2:
 
561
  mime='text/csv',
562
  key='prop_proj',
563
  )
564
+
565
+ with tab6:
566
+ st.info(t_stamp)
567
+ if st.button("Reset Data", key='reset6'):
568
+ st.info('This sheet is more or less a static represenation of the Stat Specific Simulations. ROR is rate of return based on hit rate and payout. Use the over and under EDGEs to place bets. 20%+ should be considered a 1 unit bet, 15-20% is .75 units, 10-15% is .50 units, 5-10% is .25 units, and 0-5% is .1 units.')
569
+ st.cache_data.clear()
570
+ pitcher_stats, hitter_stats, team_frame, prop_frame, betsheet_frame, pick_frame, t_stamp = init_baselines()
571
+ split_var6 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var6')
572
+ if split_var6 == 'Specific Teams':
573
+ team_var6 = st.multiselect('Which teams would you like to include in the tables?', options = betsheet_frame['Team'].unique(), key='team_var6')
574
+ elif split_var6 == 'All':
575
+ team_var6 = pitcher_stats.Team.values.tolist()
576
+ betsheet_disp = betsheet_frame.copy()
577
+ betsheet_disp = betsheet_disp[betsheet_disp['Team'].isin(team_var6)]
578
+ betsheet_disp = betsheet_disp.set_index('Player')
579
+ betsheet_disp = betsheet_disp.sort_values(by='over_EDGE', ascending=False)
580
+ st.dataframe(betsheet_disp.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
581
+ st.download_button(
582
+ label="Export Betsheet",
583
+ data=convert_df_to_csv(betsheet_disp),
584
+ file_name='MLB_Betsheet_export.csv',
585
+ mime='text/csv',
586
+ key='MLB_Betsheet_export',
587
+ )