Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
4360759
1
Parent(s):
6f36c66
Revert
Browse files
app.py
CHANGED
|
@@ -55,7 +55,7 @@ dk_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'sal
|
|
| 55 |
fd_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']
|
| 56 |
|
| 57 |
@st.cache_data(ttl = 600)
|
| 58 |
-
def init_DK_seed_frames(
|
| 59 |
|
| 60 |
collection = db["DK_NFL_seed_frame"]
|
| 61 |
cursor = collection.find()
|
|
@@ -63,12 +63,11 @@ def init_DK_seed_frames(sharp_split):
|
|
| 63 |
raw_display = pd.DataFrame(list(cursor))
|
| 64 |
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 65 |
DK_seed = raw_display.to_numpy()
|
| 66 |
-
fp_array = DK_seed[:sharp_split, :]
|
| 67 |
|
| 68 |
-
return
|
| 69 |
|
| 70 |
@st.cache_data(ttl = 600)
|
| 71 |
-
def init_DK_Secondary_seed_frames(
|
| 72 |
|
| 73 |
collection = db["DK_NFL_Secondary_seed_frame"]
|
| 74 |
cursor = collection.find()
|
|
@@ -76,12 +75,11 @@ def init_DK_Secondary_seed_frames(sharp_split):
|
|
| 76 |
raw_display = pd.DataFrame(list(cursor))
|
| 77 |
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 78 |
DK_seed = raw_display.to_numpy()
|
| 79 |
-
fp_array = DK_seed[:sharp_split, :]
|
| 80 |
|
| 81 |
-
return
|
| 82 |
|
| 83 |
@st.cache_data(ttl = 599)
|
| 84 |
-
def init_FD_seed_frames(
|
| 85 |
|
| 86 |
collection = db["FD_NFL_seed_frame"]
|
| 87 |
cursor = collection.find()
|
|
@@ -89,12 +87,11 @@ def init_FD_seed_frames(sharp_split):
|
|
| 89 |
raw_display = pd.DataFrame(list(cursor))
|
| 90 |
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 91 |
FD_seed = raw_display.to_numpy()
|
| 92 |
-
fp_array = FD_seed[:sharp_split, :]
|
| 93 |
|
| 94 |
-
return
|
| 95 |
|
| 96 |
@st.cache_data(ttl = 599)
|
| 97 |
-
def init_FD_Secondary_seed_frames(
|
| 98 |
|
| 99 |
collection = db["FD_NFL_Secondary_seed_frame"]
|
| 100 |
cursor = collection.find()
|
|
@@ -102,10 +99,8 @@ def init_FD_Secondary_seed_frames(sharp_split):
|
|
| 102 |
raw_display = pd.DataFrame(list(cursor))
|
| 103 |
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 104 |
FD_seed = raw_display.to_numpy()
|
| 105 |
-
fp_array = FD_seed[:sharp_split, :]
|
| 106 |
|
| 107 |
-
|
| 108 |
-
return fp_array
|
| 109 |
|
| 110 |
@st.cache_data(ttl = 599)
|
| 111 |
def init_baselines():
|
|
@@ -151,9 +146,10 @@ def calculate_FD_value_frequencies(np_array):
|
|
| 151 |
return combined_array
|
| 152 |
|
| 153 |
@st.cache_data
|
| 154 |
-
def sim_contest(Sim_size, seed_frame, maps_dict, Contest_Size):
|
| 155 |
SimVar = 1
|
| 156 |
Sim_Winners = []
|
|
|
|
| 157 |
|
| 158 |
# Pre-vectorize functions
|
| 159 |
vec_projection_map = np.vectorize(maps_dict['Projection_map'].__getitem__)
|
|
@@ -305,6 +301,22 @@ with tab1:
|
|
| 305 |
|
| 306 |
sim_slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate'), key='sim_slate_var1')
|
| 307 |
sim_site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='sim_site_var1')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
|
| 309 |
contest_var1 = st.selectbox("What contest size are you simulating?", ('Small', 'Medium', 'Large', 'Custom'))
|
| 310 |
if contest_var1 == 'Small':
|
|
@@ -331,14 +343,6 @@ with tab1:
|
|
| 331 |
with col2:
|
| 332 |
if st.button("Run Contest Sim"):
|
| 333 |
if 'working_seed' in st.session_state:
|
| 334 |
-
if sim_site_var1 == 'Draftkings':
|
| 335 |
-
|
| 336 |
-
raw_baselines = dk_raw
|
| 337 |
-
column_names = dk_columns
|
| 338 |
-
elif sim_site_var1 == 'Fanduel':
|
| 339 |
-
|
| 340 |
-
raw_baselines = fd_raw
|
| 341 |
-
column_names = fd_columns
|
| 342 |
st.session_state.maps_dict = {
|
| 343 |
'Projection_map':dict(zip(raw_baselines.Player,raw_baselines.Median)),
|
| 344 |
'Salary_map':dict(zip(raw_baselines.Player,raw_baselines.Salary)),
|
|
@@ -347,7 +351,7 @@ with tab1:
|
|
| 347 |
'Team_map':dict(zip(raw_baselines.Player,raw_baselines.Team)),
|
| 348 |
'STDev_map':dict(zip(raw_baselines.Player,raw_baselines.STDev))
|
| 349 |
}
|
| 350 |
-
Sim_Winners = sim_contest(1000, st.session_state.working_seed, st.session_state.maps_dict, Contest_Size)
|
| 351 |
Sim_Winner_Frame = pd.DataFrame(np.concatenate(Sim_Winners))
|
| 352 |
|
| 353 |
#st.table(Sim_Winner_Frame)
|
|
@@ -374,21 +378,9 @@ with tab1:
|
|
| 374 |
|
| 375 |
else:
|
| 376 |
if sim_site_var1 == 'Draftkings':
|
| 377 |
-
|
| 378 |
-
st.session_state.working_seed = init_DK_seed_frames(sharp_split)
|
| 379 |
-
elif sim_slate_var1 == 'Secondary Slate':
|
| 380 |
-
st.session_state.working_seed = init_DK_Secondary_seed_frames(sharp_split)
|
| 381 |
-
|
| 382 |
-
raw_baselines = dk_raw
|
| 383 |
-
column_names = dk_columns
|
| 384 |
elif sim_site_var1 == 'Fanduel':
|
| 385 |
-
|
| 386 |
-
st.session_state.working_seed = init_FD_seed_frames(sharp_split)
|
| 387 |
-
elif sim_slate_var1 == 'Secondary Slate':
|
| 388 |
-
st.session_state.working_seed = init_FD_Secondary_seed_frames(sharp_split)
|
| 389 |
-
|
| 390 |
-
raw_baselines = fd_raw
|
| 391 |
-
column_names = fd_columns
|
| 392 |
st.session_state.maps_dict = {
|
| 393 |
'Projection_map':dict(zip(raw_baselines.Player,raw_baselines.Median)),
|
| 394 |
'Salary_map':dict(zip(raw_baselines.Player,raw_baselines.Salary)),
|
|
@@ -397,7 +389,7 @@ with tab1:
|
|
| 397 |
'Team_map':dict(zip(raw_baselines.Player,raw_baselines.Team)),
|
| 398 |
'STDev_map':dict(zip(raw_baselines.Player,raw_baselines.STDev))
|
| 399 |
}
|
| 400 |
-
Sim_Winners = sim_contest(1000, st.session_state.working_seed, st.session_state.maps_dict, Contest_Size)
|
| 401 |
Sim_Winner_Frame = pd.DataFrame(np.concatenate(Sim_Winners))
|
| 402 |
|
| 403 |
#st.table(Sim_Winner_Frame)
|
|
|
|
| 55 |
fd_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']
|
| 56 |
|
| 57 |
@st.cache_data(ttl = 600)
|
| 58 |
+
def init_DK_seed_frames():
|
| 59 |
|
| 60 |
collection = db["DK_NFL_seed_frame"]
|
| 61 |
cursor = collection.find()
|
|
|
|
| 63 |
raw_display = pd.DataFrame(list(cursor))
|
| 64 |
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 65 |
DK_seed = raw_display.to_numpy()
|
|
|
|
| 66 |
|
| 67 |
+
return DK_seed
|
| 68 |
|
| 69 |
@st.cache_data(ttl = 600)
|
| 70 |
+
def init_DK_Secondary_seed_frames():
|
| 71 |
|
| 72 |
collection = db["DK_NFL_Secondary_seed_frame"]
|
| 73 |
cursor = collection.find()
|
|
|
|
| 75 |
raw_display = pd.DataFrame(list(cursor))
|
| 76 |
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 77 |
DK_seed = raw_display.to_numpy()
|
|
|
|
| 78 |
|
| 79 |
+
return DK_seed
|
| 80 |
|
| 81 |
@st.cache_data(ttl = 599)
|
| 82 |
+
def init_FD_seed_frames():
|
| 83 |
|
| 84 |
collection = db["FD_NFL_seed_frame"]
|
| 85 |
cursor = collection.find()
|
|
|
|
| 87 |
raw_display = pd.DataFrame(list(cursor))
|
| 88 |
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 89 |
FD_seed = raw_display.to_numpy()
|
|
|
|
| 90 |
|
| 91 |
+
return FD_seed
|
| 92 |
|
| 93 |
@st.cache_data(ttl = 599)
|
| 94 |
+
def init_FD_Secondary_seed_frames():
|
| 95 |
|
| 96 |
collection = db["FD_NFL_Secondary_seed_frame"]
|
| 97 |
cursor = collection.find()
|
|
|
|
| 99 |
raw_display = pd.DataFrame(list(cursor))
|
| 100 |
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 101 |
FD_seed = raw_display.to_numpy()
|
|
|
|
| 102 |
|
| 103 |
+
return FD_seed
|
|
|
|
| 104 |
|
| 105 |
@st.cache_data(ttl = 599)
|
| 106 |
def init_baselines():
|
|
|
|
| 146 |
return combined_array
|
| 147 |
|
| 148 |
@st.cache_data
|
| 149 |
+
def sim_contest(Sim_size, seed_frame, maps_dict, sharp_split, Contest_Size):
|
| 150 |
SimVar = 1
|
| 151 |
Sim_Winners = []
|
| 152 |
+
fp_array = seed_frame[:sharp_split, :]
|
| 153 |
|
| 154 |
# Pre-vectorize functions
|
| 155 |
vec_projection_map = np.vectorize(maps_dict['Projection_map'].__getitem__)
|
|
|
|
| 301 |
|
| 302 |
sim_slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate'), key='sim_slate_var1')
|
| 303 |
sim_site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='sim_site_var1')
|
| 304 |
+
if sim_site_var1 == 'Draftkings':
|
| 305 |
+
if sim_slate_var1 == 'Main Slate':
|
| 306 |
+
DK_seed = init_DK_seed_frames()
|
| 307 |
+
elif sim_slate_var1 == 'Secondary Slate':
|
| 308 |
+
DK_seed = init_DK_Secondary_seed_frames()
|
| 309 |
+
|
| 310 |
+
raw_baselines = dk_raw
|
| 311 |
+
column_names = dk_columns
|
| 312 |
+
elif sim_site_var1 == 'Fanduel':
|
| 313 |
+
if sim_slate_var1 == 'Main Slate':
|
| 314 |
+
FD_seed = init_FD_seed_frames()
|
| 315 |
+
elif sim_slate_var1 == 'Secondary Slate':
|
| 316 |
+
FD_seed = init_FD_Secondary_seed_frames()
|
| 317 |
+
|
| 318 |
+
raw_baselines = fd_raw
|
| 319 |
+
column_names = fd_columns
|
| 320 |
|
| 321 |
contest_var1 = st.selectbox("What contest size are you simulating?", ('Small', 'Medium', 'Large', 'Custom'))
|
| 322 |
if contest_var1 == 'Small':
|
|
|
|
| 343 |
with col2:
|
| 344 |
if st.button("Run Contest Sim"):
|
| 345 |
if 'working_seed' in st.session_state:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
st.session_state.maps_dict = {
|
| 347 |
'Projection_map':dict(zip(raw_baselines.Player,raw_baselines.Median)),
|
| 348 |
'Salary_map':dict(zip(raw_baselines.Player,raw_baselines.Salary)),
|
|
|
|
| 351 |
'Team_map':dict(zip(raw_baselines.Player,raw_baselines.Team)),
|
| 352 |
'STDev_map':dict(zip(raw_baselines.Player,raw_baselines.STDev))
|
| 353 |
}
|
| 354 |
+
Sim_Winners = sim_contest(1000, st.session_state.working_seed, st.session_state.maps_dict, sharp_split, Contest_Size)
|
| 355 |
Sim_Winner_Frame = pd.DataFrame(np.concatenate(Sim_Winners))
|
| 356 |
|
| 357 |
#st.table(Sim_Winner_Frame)
|
|
|
|
| 378 |
|
| 379 |
else:
|
| 380 |
if sim_site_var1 == 'Draftkings':
|
| 381 |
+
st.session_state.working_seed = DK_seed.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
elif sim_site_var1 == 'Fanduel':
|
| 383 |
+
st.session_state.working_seed = FD_seed.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
st.session_state.maps_dict = {
|
| 385 |
'Projection_map':dict(zip(raw_baselines.Player,raw_baselines.Median)),
|
| 386 |
'Salary_map':dict(zip(raw_baselines.Player,raw_baselines.Salary)),
|
|
|
|
| 389 |
'Team_map':dict(zip(raw_baselines.Player,raw_baselines.Team)),
|
| 390 |
'STDev_map':dict(zip(raw_baselines.Player,raw_baselines.STDev))
|
| 391 |
}
|
| 392 |
+
Sim_Winners = sim_contest(1000, st.session_state.working_seed, st.session_state.maps_dict, sharp_split, Contest_Size)
|
| 393 |
Sim_Winner_Frame = pd.DataFrame(np.concatenate(Sim_Winners))
|
| 394 |
|
| 395 |
#st.table(Sim_Winner_Frame)
|