Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
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 |
|