Multichem commited on
Commit
8d05170
·
verified ·
1 Parent(s): ff585c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -73
app.py CHANGED
@@ -153,80 +153,81 @@ with tab3:
153
  prop_df['Over'] = np.where(prop_df['over_line'] < 0, (-(prop_df['over_line'])/((-(prop_df['over_line']))+101)), 101/(prop_df['over_line']+101))
154
  prop_df['Under'] = np.where(prop_df['under_line'] < 0, (-(prop_df['under_line'])/((-(prop_df['under_line']))+101)), 101/(prop_df['under_line']+101))
155
  df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
 
156
 
157
- prop_dict = dict(zip(df.Player, df.Prop))
158
- over_dict = dict(zip(df.Player, df.Over))
159
- under_dict = dict(zip(df.Player, df.Under))
160
-
161
- total_sims = 5000
162
-
163
- df.replace("", 0, inplace=True)
164
-
165
- if prop == 'points':
166
- df['Median'] = df['Player TP']
167
- elif prop == 'SOG':
168
- df['Median'] = df['Player SOG']
169
- elif prop == 'assists':
170
- df['Median'] = df['Player Assists']
171
- elif prop == 'blocked_shots':
172
- df['Median'] = df['Player Blocks']
173
-
174
- flex_file = df
175
- flex_file['Floor'] = (flex_file['Median'] * .15)
176
- flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * .85)
177
- flex_file['STD'] = (flex_file['Median']/3)
178
- flex_file['Prop'] = flex_file['Player'].map(prop_dict)
179
- flex_file = flex_file[['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
180
-
181
- hold_file = flex_file
182
- overall_file = flex_file
183
- prop_file = flex_file
184
-
185
- overall_players = overall_file[['Player']]
186
-
187
- for x in range(0,total_sims):
188
- prop_file[x] = prop_file['Prop']
189
-
190
- prop_file = prop_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
191
-
192
- for x in range(0,total_sims):
193
- overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
194
-
195
- overall_file=overall_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
196
-
197
- players_only = hold_file[['Player']]
198
-
199
- player_outcomes = pd.merge(players_only, overall_file, left_index=True, right_index=True)
200
-
201
- prop_check = (overall_file - prop_file)
202
-
203
- players_only['Mean_Outcome'] = overall_file.mean(axis=1)
204
- players_only['10%'] = overall_file.quantile(0.1, axis=1)
205
- players_only['90%'] = overall_file.quantile(0.9, axis=1)
206
- players_only['Over'] = prop_check[prop_check > 0].count(axis=1)/float(total_sims)
207
- players_only['Imp Over'] = players_only['Player'].map(over_dict)
208
- players_only['Over%'] = players_only[["Over", "Imp Over"]].mean(axis=1)
209
- players_only['Under'] = prop_check[prop_check < 0].count(axis=1)/float(total_sims)
210
- players_only['Imp Under'] = players_only['Player'].map(under_dict)
211
- players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
212
- players_only['Prop'] = players_only['Player'].map(prop_dict)
213
- players_only['Prop_avg'] = players_only['Prop'].mean() / 100
214
- players_only['prop_threshold'] = .10
215
- players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
216
- players_only['Over_diff'] = players_only['Over%'] - players_only['Imp Over']
217
- players_only['Under_diff'] = players_only['Under%'] - players_only['Imp Under']
218
- players_only['Bet_check'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], players_only['Over_diff'] , players_only['Under_diff'])
219
- players_only['Bet_suggest'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], "Over" , "Under")
220
- players_only['Bet?'] = np.where(players_only['Bet_check'] >= players_only['prop_threshold'], players_only['Bet_suggest'], "No Bet")
221
- players_only['Edge'] = players_only['Bet_check']
222
- players_only['Prop type'] = prop
223
-
224
- players_only['Player'] = hold_file[['Player']]
225
- players_only['Team'] = players_only['Player'].map(team_dict)
226
-
227
- leg_outcomes = players_only[['Player', 'Team', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
228
-
229
- sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
230
 
231
  final_outcomes = sim_all_hold
232
 
 
153
  prop_df['Over'] = np.where(prop_df['over_line'] < 0, (-(prop_df['over_line'])/((-(prop_df['over_line']))+101)), 101/(prop_df['over_line']+101))
154
  prop_df['Under'] = np.where(prop_df['under_line'] < 0, (-(prop_df['under_line'])/((-(prop_df['under_line']))+101)), 101/(prop_df['under_line']+101))
155
  df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
156
+ if len(df) > 0:
157
 
158
+ prop_dict = dict(zip(df.Player, df.Prop))
159
+ over_dict = dict(zip(df.Player, df.Over))
160
+ under_dict = dict(zip(df.Player, df.Under))
161
+
162
+ total_sims = 5000
163
+
164
+ df.replace("", 0, inplace=True)
165
+
166
+ if prop == 'points':
167
+ df['Median'] = df['Player TP']
168
+ elif prop == 'SOG':
169
+ df['Median'] = df['Player SOG']
170
+ elif prop == 'assists':
171
+ df['Median'] = df['Player Assists']
172
+ elif prop == 'blocked_shots':
173
+ df['Median'] = df['Player Blocks']
174
+
175
+ flex_file = df
176
+ flex_file['Floor'] = (flex_file['Median'] * .15)
177
+ flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * .85)
178
+ flex_file['STD'] = (flex_file['Median']/3)
179
+ flex_file['Prop'] = flex_file['Player'].map(prop_dict)
180
+ flex_file = flex_file[['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
181
+
182
+ hold_file = flex_file
183
+ overall_file = flex_file
184
+ prop_file = flex_file
185
+
186
+ overall_players = overall_file[['Player']]
187
+
188
+ for x in range(0,total_sims):
189
+ prop_file[x] = prop_file['Prop']
190
+
191
+ prop_file = prop_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
192
+
193
+ for x in range(0,total_sims):
194
+ overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
195
+
196
+ overall_file=overall_file.drop(['Player', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
197
+
198
+ players_only = hold_file[['Player']]
199
+
200
+ player_outcomes = pd.merge(players_only, overall_file, left_index=True, right_index=True)
201
+
202
+ prop_check = (overall_file - prop_file)
203
+
204
+ players_only['Mean_Outcome'] = overall_file.mean(axis=1)
205
+ players_only['10%'] = overall_file.quantile(0.1, axis=1)
206
+ players_only['90%'] = overall_file.quantile(0.9, axis=1)
207
+ players_only['Over'] = prop_check[prop_check > 0].count(axis=1)/float(total_sims)
208
+ players_only['Imp Over'] = players_only['Player'].map(over_dict)
209
+ players_only['Over%'] = players_only[["Over", "Imp Over"]].mean(axis=1)
210
+ players_only['Under'] = prop_check[prop_check < 0].count(axis=1)/float(total_sims)
211
+ players_only['Imp Under'] = players_only['Player'].map(under_dict)
212
+ players_only['Under%'] = players_only[["Under", "Imp Under"]].mean(axis=1)
213
+ players_only['Prop'] = players_only['Player'].map(prop_dict)
214
+ players_only['Prop_avg'] = players_only['Prop'].mean() / 100
215
+ players_only['prop_threshold'] = .10
216
+ players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
217
+ players_only['Over_diff'] = players_only['Over%'] - players_only['Imp Over']
218
+ players_only['Under_diff'] = players_only['Under%'] - players_only['Imp Under']
219
+ players_only['Bet_check'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], players_only['Over_diff'] , players_only['Under_diff'])
220
+ players_only['Bet_suggest'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], "Over" , "Under")
221
+ players_only['Bet?'] = np.where(players_only['Bet_check'] >= players_only['prop_threshold'], players_only['Bet_suggest'], "No Bet")
222
+ players_only['Edge'] = players_only['Bet_check']
223
+ players_only['Prop type'] = prop
224
+
225
+ players_only['Player'] = hold_file[['Player']]
226
+ players_only['Team'] = players_only['Player'].map(team_dict)
227
+
228
+ leg_outcomes = players_only[['Player', 'Team', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge']]
229
+
230
+ sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
231
 
232
  final_outcomes = sim_all_hold
233