Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,6 +46,11 @@ def init_baselines():
|
|
| 46 |
raw_display.replace('', np.nan, inplace=True)
|
| 47 |
overall_stats = raw_display.dropna()
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
worksheet = sh.worksheet('DK_ROO')
|
| 50 |
timestamp = worksheet.acell('U2').value
|
| 51 |
|
|
@@ -55,18 +60,21 @@ def init_baselines():
|
|
| 55 |
raw_display.replace('#DIV/0!', np.nan, inplace=True)
|
| 56 |
prop_frame = raw_display.dropna()
|
| 57 |
|
| 58 |
-
return game_model, overall_stats, timestamp, prop_frame
|
| 59 |
|
| 60 |
-
game_model, overall_stats, timestamp, prop_frame = init_baselines()
|
| 61 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 62 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 63 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
| 64 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
| 65 |
|
|
|
|
|
|
|
|
|
|
| 66 |
all_sim_vars = ['pass_yards', 'rush_yards', 'rec_yards', 'receptions', 'rush_attempts']
|
| 67 |
sim_all_hold = pd.DataFrame(columns=['Player', 'Team', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge'])
|
| 68 |
|
| 69 |
-
tab1, tab2, tab3, tab4, tab5 = st.tabs(["Game Betting Model", "QB Projections", "RB/WR/TE Projections", "Player Prop Simulations", "Stat Specific Simulations"])
|
| 70 |
|
| 71 |
def convert_df_to_csv(df):
|
| 72 |
return df.to_csv().encode('utf-8')
|
|
@@ -75,7 +83,7 @@ with tab1:
|
|
| 75 |
st.info(t_stamp)
|
| 76 |
if st.button("Reset Data", key='reset1'):
|
| 77 |
st.cache_data.clear()
|
| 78 |
-
game_model, overall_stats, timestamp, prop_frame = init_baselines()
|
| 79 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 80 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 81 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
@@ -103,7 +111,7 @@ with tab2:
|
|
| 103 |
st.info(t_stamp)
|
| 104 |
if st.button("Reset Data", key='reset2'):
|
| 105 |
st.cache_data.clear()
|
| 106 |
-
game_model, overall_stats, timestamp, prop_frame = init_baselines()
|
| 107 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 108 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 109 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
@@ -129,7 +137,7 @@ with tab3:
|
|
| 129 |
st.info(t_stamp)
|
| 130 |
if st.button("Reset Data", key='reset3'):
|
| 131 |
st.cache_data.clear()
|
| 132 |
-
game_model, overall_stats, timestamp, prop_frame = init_baselines()
|
| 133 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 134 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 135 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
@@ -150,12 +158,39 @@ with tab3:
|
|
| 150 |
mime='text/csv',
|
| 151 |
key='hitter_prop_export',
|
| 152 |
)
|
| 153 |
-
|
| 154 |
with tab4:
|
| 155 |
st.info(t_stamp)
|
| 156 |
if st.button("Reset Data", key='reset4'):
|
| 157 |
st.cache_data.clear()
|
| 158 |
-
game_model, overall_stats, timestamp, prop_frame = init_baselines()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 160 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 161 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
@@ -297,12 +332,12 @@ with tab4:
|
|
| 297 |
plot_hold_container = st.empty()
|
| 298 |
st.plotly_chart(fig, use_container_width=True)
|
| 299 |
|
| 300 |
-
with
|
| 301 |
st.info(t_stamp)
|
| 302 |
st.info('The Over and Under percentages are a compositve percentage based on simulations, historical performance, and implied probabilities, and may be different than you would expect based purely on the median projection. Likewise, the Edge of a bet is not the only indicator of if you should make the bet or not as the suggestion is using a base acceptable threshold to determine how much edge you should have for each stat category.')
|
| 303 |
-
if st.button("Reset Data/Load Data", key='
|
| 304 |
st.cache_data.clear()
|
| 305 |
-
game_model, overall_stats, timestamp, prop_frame = init_baselines()
|
| 306 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 307 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 308 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
|
|
| 46 |
raw_display.replace('', np.nan, inplace=True)
|
| 47 |
overall_stats = raw_display.dropna()
|
| 48 |
|
| 49 |
+
worksheet = sh.worksheet('prop_frame')
|
| 50 |
+
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 51 |
+
raw_display.replace('', np.nan, inplace=True)
|
| 52 |
+
prop_trends = raw_display.dropna()
|
| 53 |
+
|
| 54 |
worksheet = sh.worksheet('DK_ROO')
|
| 55 |
timestamp = worksheet.acell('U2').value
|
| 56 |
|
|
|
|
| 60 |
raw_display.replace('#DIV/0!', np.nan, inplace=True)
|
| 61 |
prop_frame = raw_display.dropna()
|
| 62 |
|
| 63 |
+
return game_model, overall_stats, timestamp, prop_frame, prop_trends
|
| 64 |
|
| 65 |
+
game_model, overall_stats, timestamp, prop_frame, prop_trends = init_baselines()
|
| 66 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 67 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 68 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
| 69 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
| 70 |
|
| 71 |
+
prop_table_options = ['pass_yards', 'rush_yards', 'rec_yards', 'receptions', 'rush_attempts', 'pass_attempts']
|
| 72 |
+
prop_format = {'L3 Success': '{:.2%}', 'L6_Success': '{:.2%}', 'L10_success': '{:.2%}', 'Trending Over': '{:.2%}', 'Trending Under': '{:.2%}',
|
| 73 |
+
'Implied Over': '{:.2%}', 'Implied Under': '{:.2%}', 'Over Edge': '{:.2%}', 'Under Edge': '{:.2%}'}
|
| 74 |
all_sim_vars = ['pass_yards', 'rush_yards', 'rec_yards', 'receptions', 'rush_attempts']
|
| 75 |
sim_all_hold = pd.DataFrame(columns=['Player', 'Team', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge'])
|
| 76 |
|
| 77 |
+
tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(["Game Betting Model", "QB Projections", "RB/WR/TE Projections", "Player Prop Trends", "Player Prop Simulations", "Stat Specific Simulations"])
|
| 78 |
|
| 79 |
def convert_df_to_csv(df):
|
| 80 |
return df.to_csv().encode('utf-8')
|
|
|
|
| 83 |
st.info(t_stamp)
|
| 84 |
if st.button("Reset Data", key='reset1'):
|
| 85 |
st.cache_data.clear()
|
| 86 |
+
game_model, overall_stats, timestamp, prop_frame, prop_trends = init_baselines()
|
| 87 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 88 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 89 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
|
|
| 111 |
st.info(t_stamp)
|
| 112 |
if st.button("Reset Data", key='reset2'):
|
| 113 |
st.cache_data.clear()
|
| 114 |
+
game_model, overall_stats, timestamp, prop_frame, prop_trends = init_baselines()
|
| 115 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 116 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 117 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
|
|
| 137 |
st.info(t_stamp)
|
| 138 |
if st.button("Reset Data", key='reset3'):
|
| 139 |
st.cache_data.clear()
|
| 140 |
+
game_model, overall_stats, timestamp, prop_frame, prop_trends = init_baselines()
|
| 141 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 142 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 143 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
|
|
| 158 |
mime='text/csv',
|
| 159 |
key='hitter_prop_export',
|
| 160 |
)
|
| 161 |
+
|
| 162 |
with tab4:
|
| 163 |
st.info(t_stamp)
|
| 164 |
if st.button("Reset Data", key='reset4'):
|
| 165 |
st.cache_data.clear()
|
| 166 |
+
game_model, overall_stats, timestamp, prop_frame, prop_trends = init_baselines()
|
| 167 |
+
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 168 |
+
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 169 |
+
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
| 170 |
+
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
| 171 |
+
split_var5 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var5')
|
| 172 |
+
if split_var5 == 'Specific Teams':
|
| 173 |
+
team_var5 = st.multiselect('Which teams would you like to include in the tables?', options = prop_trends['Team'].unique(), key='team_var5')
|
| 174 |
+
elif split_var5 == 'All':
|
| 175 |
+
team_var5 = prop_trends.Team.values.tolist()
|
| 176 |
+
prop_type_var2 = st.selectbox('Select type of prop are you wanting to view', options = prop_table_options)
|
| 177 |
+
prop_frame_disp = prop_trends[prop_trends['Team'].isin(team_var5)]
|
| 178 |
+
prop_frame_disp = prop_frame_disp[prop_frame_disp['prop_type'] == prop_type_var2]
|
| 179 |
+
prop_frame_disp = prop_frame_disp.set_index('Player')
|
| 180 |
+
prop_frame_disp = prop_frame_disp.sort_values(by='Trending Over', ascending=False)
|
| 181 |
+
st.dataframe(prop_frame_disp.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(prop_format, precision=2), use_container_width = True)
|
| 182 |
+
st.download_button(
|
| 183 |
+
label="Export Prop Trends Model",
|
| 184 |
+
data=convert_df_to_csv(prop_frame_disp),
|
| 185 |
+
file_name='NFL_prop_trends_export.csv',
|
| 186 |
+
mime='text/csv',
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
with tab5:
|
| 190 |
+
st.info(t_stamp)
|
| 191 |
+
if st.button("Reset Data", key='reset5'):
|
| 192 |
+
st.cache_data.clear()
|
| 193 |
+
game_model, overall_stats, timestamp, prop_frame, prop_trends = init_baselines()
|
| 194 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 195 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 196 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|
|
|
|
| 332 |
plot_hold_container = st.empty()
|
| 333 |
st.plotly_chart(fig, use_container_width=True)
|
| 334 |
|
| 335 |
+
with tab6:
|
| 336 |
st.info(t_stamp)
|
| 337 |
st.info('The Over and Under percentages are a compositve percentage based on simulations, historical performance, and implied probabilities, and may be different than you would expect based purely on the median projection. Likewise, the Edge of a bet is not the only indicator of if you should make the bet or not as the suggestion is using a base acceptable threshold to determine how much edge you should have for each stat category.')
|
| 338 |
+
if st.button("Reset Data/Load Data", key='reset6'):
|
| 339 |
st.cache_data.clear()
|
| 340 |
+
game_model, overall_stats, timestamp, prop_frame, prop_trends = init_baselines()
|
| 341 |
qb_stats = overall_stats.loc[overall_stats['Position'] == 'QB']
|
| 342 |
non_qb_stats = overall_stats.loc[overall_stats['Position'] != 'QB']
|
| 343 |
team_dict = dict(zip(prop_frame['Player'], prop_frame['Team']))
|