Spaces:
Sleeping
Sleeping
James McCool commited on
Commit ·
c871862
1
Parent(s): 2cd7161
Enhance lineup initialization functions by adding priority variable and mix options for Draftkings and Fanduel. Update UI to include controls for selecting priority variable and mix percentage, improving lineup customization capabilities.
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import numpy as np
|
|
| 3 |
import pandas as pd
|
| 4 |
import pymongo
|
| 5 |
import re
|
|
|
|
| 6 |
|
| 7 |
st.set_page_config(layout="wide")
|
| 8 |
|
|
@@ -136,8 +137,11 @@ def init_baselines():
|
|
| 136 |
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map
|
| 137 |
|
| 138 |
@st.cache_data(ttl = 60)
|
| 139 |
-
def init_DK_lineups(type_var, slate_var):
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
| 141 |
if type_var == 'Regular':
|
| 142 |
if slate_var == 'Main':
|
| 143 |
collection = db['DK_MLB_name_map']
|
|
@@ -146,9 +150,14 @@ def init_DK_lineups(type_var, slate_var):
|
|
| 146 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 147 |
|
| 148 |
collection = db['DK_MLB_seed_frame']
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
-
raw_display = pd.DataFrame(list(cursor))
|
| 152 |
raw_display = raw_display[['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 153 |
dict_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
| 154 |
# Map names
|
|
@@ -160,9 +169,14 @@ def init_DK_lineups(type_var, slate_var):
|
|
| 160 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 161 |
|
| 162 |
collection = db['DK_MLB_Secondary_seed_frame']
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
-
raw_display = pd.DataFrame(list(cursor))
|
| 166 |
raw_display = raw_display[['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 167 |
dict_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
| 168 |
# Map names
|
|
@@ -174,9 +188,14 @@ def init_DK_lineups(type_var, slate_var):
|
|
| 174 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 175 |
|
| 176 |
collection = db['DK_MLB_Turbo_seed_frame']
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
raw_display = raw_display[['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 181 |
dict_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
| 182 |
# Map names
|
|
@@ -184,21 +203,36 @@ def init_DK_lineups(type_var, slate_var):
|
|
| 184 |
elif type_var == 'Showdown':
|
| 185 |
if slate_var == 'Main':
|
| 186 |
collection = db['DK_MLB_SD1_seed_frame']
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 191 |
elif slate_var == 'Secondary':
|
| 192 |
collection = db['DK_MLB_SD2_seed_frame']
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 197 |
elif slate_var == 'Auxiliary':
|
| 198 |
collection = db['DK_MLB_SD3_seed_frame']
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 203 |
|
| 204 |
DK_seed = raw_display.to_numpy()
|
|
@@ -206,7 +240,7 @@ def init_DK_lineups(type_var, slate_var):
|
|
| 206 |
return DK_seed
|
| 207 |
|
| 208 |
@st.cache_data(ttl = 60)
|
| 209 |
-
def init_FD_lineups(type_var,slate_var):
|
| 210 |
|
| 211 |
if type_var == 'Regular':
|
| 212 |
if slate_var == 'Main':
|
|
@@ -216,9 +250,14 @@ def init_FD_lineups(type_var,slate_var):
|
|
| 216 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 217 |
|
| 218 |
collection = db['FD_MLB_seed_frame']
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
raw_display = raw_display[['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 223 |
dict_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
| 224 |
# Map names
|
|
@@ -230,9 +269,14 @@ def init_FD_lineups(type_var,slate_var):
|
|
| 230 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 231 |
|
| 232 |
collection = db['FD_MLB_Secondary_seed_frame']
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
raw_display = raw_display[['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 237 |
dict_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
| 238 |
# Map names
|
|
@@ -244,9 +288,14 @@ def init_FD_lineups(type_var,slate_var):
|
|
| 244 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 245 |
|
| 246 |
collection = db['FD_MLB_Turbo_seed_frame']
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
raw_display = raw_display[['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 251 |
dict_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
| 252 |
# Map names
|
|
@@ -255,21 +304,36 @@ def init_FD_lineups(type_var,slate_var):
|
|
| 255 |
elif type_var == 'Showdown':
|
| 256 |
if slate_var == 'Main':
|
| 257 |
collection = db['FD_MLB_SD1_seed_frame']
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 262 |
elif slate_var == 'Secondary':
|
| 263 |
collection = db['FD_MLB_SD2_seed_frame']
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 268 |
elif slate_var == 'Auxiliary':
|
| 269 |
collection = db['FD_MLB_SD3_seed_frame']
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 274 |
|
| 275 |
FD_seed = raw_display.to_numpy()
|
|
@@ -301,8 +365,8 @@ with col1:
|
|
| 301 |
st.cache_data.clear()
|
| 302 |
roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map = init_baselines()
|
| 303 |
hold_display = roo_data
|
| 304 |
-
dk_lineups = init_DK_lineups('Regular', 'Main')
|
| 305 |
-
fd_lineups = init_FD_lineups('Regular', 'Main')
|
| 306 |
for key in st.session_state.keys():
|
| 307 |
del st.session_state[key]
|
| 308 |
with col2:
|
|
@@ -551,8 +615,11 @@ if selected_tab == "Optimals":
|
|
| 551 |
st.header("Optimals")
|
| 552 |
with st.expander("Info and Filters"):
|
| 553 |
st.info("These filters will display various optimals in the table below to pick from. If you want to export the entire set of 10,000 optimals, hit the 'Prepare full data export' button. If you would like to apply the filters here to the 10,000 optimals before you export, use the 'Prepare full data export (Filter)' button.")
|
| 554 |
-
col1, col2, col3, col4 = st.columns(
|
| 555 |
with col1:
|
|
|
|
|
|
|
|
|
|
| 556 |
slate_type_var3 = st.radio("Which slate type are you loading?", ('Regular', 'Showdown'), key='slate_type_var3')
|
| 557 |
if slate_type_var3 == 'Regular':
|
| 558 |
raw_baselines = roo_data
|
|
@@ -561,22 +628,22 @@ if selected_tab == "Optimals":
|
|
| 561 |
slate_var3 = st.radio("Which slate data are you loading?", ('Main', 'Secondary', 'Auxiliary'), key='slate_var3')
|
| 562 |
if slate_type_var3 == 'Regular':
|
| 563 |
if site_var == 'Draftkings':
|
| 564 |
-
dk_lineups = init_DK_lineups(slate_type_var3, slate_var3)
|
| 565 |
elif site_var == 'Fanduel':
|
| 566 |
-
fd_lineups = init_FD_lineups(slate_type_var3, slate_var3)
|
| 567 |
elif slate_type_var3 == 'Showdown':
|
| 568 |
if site_var == 'Draftkings':
|
| 569 |
-
dk_lineups = init_DK_lineups(slate_type_var3, slate_var3)
|
| 570 |
elif site_var == 'Fanduel':
|
| 571 |
-
fd_lineups = init_FD_lineups(slate_type_var3, slate_var3)
|
| 572 |
-
with
|
| 573 |
lineup_num_var = st.number_input("How many lineups do you want to display?", min_value=1, max_value=1000, value=150, step=1)
|
| 574 |
player_var1 = st.radio("Do you want a frame with specific Players?", ('Full Slate', 'Specific Players'), key='player_var1')
|
| 575 |
if player_var1 == 'Specific Players':
|
| 576 |
player_var2 = st.multiselect('Which players do you want?', options = raw_baselines['Player'].unique())
|
| 577 |
elif player_var1 == 'Full Slate':
|
| 578 |
player_var2 = raw_baselines.Player.values.tolist()
|
| 579 |
-
with
|
| 580 |
if site_var == 'Draftkings':
|
| 581 |
salary_min_var = st.number_input("Minimum salary used", min_value = 0, max_value = 50000, value = 49000, step = 100, key = 'salary_min_var')
|
| 582 |
salary_max_var = st.number_input("Maximum salary used", min_value = 0, max_value = 50000, value = 50000, step = 100, key = 'salary_max_var')
|
|
@@ -587,7 +654,7 @@ if selected_tab == "Optimals":
|
|
| 587 |
elif slate_type_var3 == 'Showdown':
|
| 588 |
salary_min_var = st.number_input("Minimum salary used", min_value = 0, max_value = 60000, value = 59000, step = 100, key = 'salary_min_var')
|
| 589 |
salary_max_var = st.number_input("Maximum salary used", min_value = 0, max_value = 60000, value = 60000, step = 100, key = 'salary_max_var')
|
| 590 |
-
with
|
| 591 |
if site_var == 'Draftkings':
|
| 592 |
min_stacks_var = st.number_input("Minimum stacks used", min_value = 0, max_value = 5, value = 3, step = 1, key = 'min_stacks_var')
|
| 593 |
max_stacks_var = st.number_input("Maximum stacks used", min_value = 0, max_value = 5, value = 5, step = 1, key = 'max_stacks_var')
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
import pymongo
|
| 5 |
import re
|
| 6 |
+
import math
|
| 7 |
|
| 8 |
st.set_page_config(layout="wide")
|
| 9 |
|
|
|
|
| 137 |
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map
|
| 138 |
|
| 139 |
@st.cache_data(ttl = 60)
|
| 140 |
+
def init_DK_lineups(type_var, slate_var, prio_var, prio_mix):
|
| 141 |
+
|
| 142 |
+
if prio_var == 'Mix':
|
| 143 |
+
prio_var = None
|
| 144 |
+
|
| 145 |
if type_var == 'Regular':
|
| 146 |
if slate_var == 'Main':
|
| 147 |
collection = db['DK_MLB_name_map']
|
|
|
|
| 150 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 151 |
|
| 152 |
collection = db['DK_MLB_seed_frame']
|
| 153 |
+
if prio_var == None:
|
| 154 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 155 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 156 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 157 |
+
else:
|
| 158 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 159 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 160 |
|
|
|
|
| 161 |
raw_display = raw_display[['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 162 |
dict_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
| 163 |
# Map names
|
|
|
|
| 169 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 170 |
|
| 171 |
collection = db['DK_MLB_Secondary_seed_frame']
|
| 172 |
+
if prio_var == None:
|
| 173 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 174 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 175 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 176 |
+
else:
|
| 177 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 178 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 179 |
|
|
|
|
| 180 |
raw_display = raw_display[['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 181 |
dict_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
| 182 |
# Map names
|
|
|
|
| 188 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 189 |
|
| 190 |
collection = db['DK_MLB_Turbo_seed_frame']
|
| 191 |
+
if prio_var == None:
|
| 192 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 193 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 194 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 195 |
+
else:
|
| 196 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 197 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 198 |
+
|
| 199 |
raw_display = raw_display[['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 200 |
dict_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
| 201 |
# Map names
|
|
|
|
| 203 |
elif type_var == 'Showdown':
|
| 204 |
if slate_var == 'Main':
|
| 205 |
collection = db['DK_MLB_SD1_seed_frame']
|
| 206 |
+
if prio_var == None:
|
| 207 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 208 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 209 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 210 |
+
else:
|
| 211 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 212 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 213 |
+
|
| 214 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 215 |
elif slate_var == 'Secondary':
|
| 216 |
collection = db['DK_MLB_SD2_seed_frame']
|
| 217 |
+
if prio_var == None:
|
| 218 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 219 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 220 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 221 |
+
else:
|
| 222 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 223 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 224 |
+
|
| 225 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 226 |
elif slate_var == 'Auxiliary':
|
| 227 |
collection = db['DK_MLB_SD3_seed_frame']
|
| 228 |
+
if prio_var == None:
|
| 229 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 230 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 231 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 232 |
+
else:
|
| 233 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 234 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 235 |
+
|
| 236 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 237 |
|
| 238 |
DK_seed = raw_display.to_numpy()
|
|
|
|
| 240 |
return DK_seed
|
| 241 |
|
| 242 |
@st.cache_data(ttl = 60)
|
| 243 |
+
def init_FD_lineups(type_var,slate_var, prio_var, prio_mix):
|
| 244 |
|
| 245 |
if type_var == 'Regular':
|
| 246 |
if slate_var == 'Main':
|
|
|
|
| 250 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 251 |
|
| 252 |
collection = db['FD_MLB_seed_frame']
|
| 253 |
+
if prio_var == None:
|
| 254 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 255 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 256 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 257 |
+
else:
|
| 258 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 259 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 260 |
+
|
| 261 |
raw_display = raw_display[['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 262 |
dict_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
| 263 |
# Map names
|
|
|
|
| 269 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 270 |
|
| 271 |
collection = db['FD_MLB_Secondary_seed_frame']
|
| 272 |
+
if prio_var == None:
|
| 273 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 274 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 275 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 276 |
+
else:
|
| 277 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 278 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 279 |
+
|
| 280 |
raw_display = raw_display[['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 281 |
dict_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
| 282 |
# Map names
|
|
|
|
| 288 |
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
| 289 |
|
| 290 |
collection = db['FD_MLB_Turbo_seed_frame']
|
| 291 |
+
if prio_var == None:
|
| 292 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 293 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 294 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 295 |
+
else:
|
| 296 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 297 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 298 |
+
|
| 299 |
raw_display = raw_display[['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 300 |
dict_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
| 301 |
# Map names
|
|
|
|
| 304 |
elif type_var == 'Showdown':
|
| 305 |
if slate_var == 'Main':
|
| 306 |
collection = db['FD_MLB_SD1_seed_frame']
|
| 307 |
+
if prio_var == None:
|
| 308 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 309 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 310 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 311 |
+
else:
|
| 312 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 313 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 314 |
+
|
| 315 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 316 |
elif slate_var == 'Secondary':
|
| 317 |
collection = db['FD_MLB_SD2_seed_frame']
|
| 318 |
+
if prio_var == None:
|
| 319 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 320 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 321 |
+
cursor = pd.concat([cursor1, cursor2])
|
| 322 |
+
else:
|
| 323 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 324 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 325 |
+
|
| 326 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 327 |
elif slate_var == 'Auxiliary':
|
| 328 |
collection = db['FD_MLB_SD3_seed_frame']
|
| 329 |
+
if prio_var == None:
|
| 330 |
+
cursor1 = collection.find().limit(math.ceil(10000 * (prio_mix / 100)))
|
| 331 |
+
cursor2 = collection.find().sort('Own', -1).limit(math.ceil(10000 * ((100 - prio_mix) / 100)))
|
| 332 |
+
raw_display = pd.concat([pd.DataFrame(list(cursor1)), pd.DataFrame(list(cursor2))])
|
| 333 |
+
else:
|
| 334 |
+
cursor = collection.find().sort(prio_var, -1).limit(10000)
|
| 335 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 336 |
+
|
| 337 |
raw_display = raw_display[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 338 |
|
| 339 |
FD_seed = raw_display.to_numpy()
|
|
|
|
| 365 |
st.cache_data.clear()
|
| 366 |
roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map = init_baselines()
|
| 367 |
hold_display = roo_data
|
| 368 |
+
dk_lineups = init_DK_lineups('Regular', 'Main', 'proj')
|
| 369 |
+
fd_lineups = init_FD_lineups('Regular', 'Main', 'proj')
|
| 370 |
for key in st.session_state.keys():
|
| 371 |
del st.session_state[key]
|
| 372 |
with col2:
|
|
|
|
| 615 |
st.header("Optimals")
|
| 616 |
with st.expander("Info and Filters"):
|
| 617 |
st.info("These filters will display various optimals in the table below to pick from. If you want to export the entire set of 10,000 optimals, hit the 'Prepare full data export' button. If you would like to apply the filters here to the 10,000 optimals before you export, use the 'Prepare full data export (Filter)' button.")
|
| 618 |
+
col1, col2, col3, col4, col5 = st.columns(5)
|
| 619 |
with col1:
|
| 620 |
+
prio_var = st.radio("Which priority variable do you want to use?", ('proj', 'Own', 'Mix'), key='prio_var')
|
| 621 |
+
prio_mix = st.number_input("If Mix, what split of Projection/Ownership to dedicate to Projection?", min_value=0, max_value=100, value=50, step=1)
|
| 622 |
+
with col2:
|
| 623 |
slate_type_var3 = st.radio("Which slate type are you loading?", ('Regular', 'Showdown'), key='slate_type_var3')
|
| 624 |
if slate_type_var3 == 'Regular':
|
| 625 |
raw_baselines = roo_data
|
|
|
|
| 628 |
slate_var3 = st.radio("Which slate data are you loading?", ('Main', 'Secondary', 'Auxiliary'), key='slate_var3')
|
| 629 |
if slate_type_var3 == 'Regular':
|
| 630 |
if site_var == 'Draftkings':
|
| 631 |
+
dk_lineups = init_DK_lineups(slate_type_var3, slate_var3, prio_var, prio_mix)
|
| 632 |
elif site_var == 'Fanduel':
|
| 633 |
+
fd_lineups = init_FD_lineups(slate_type_var3, slate_var3, prio_var, prio_mix)
|
| 634 |
elif slate_type_var3 == 'Showdown':
|
| 635 |
if site_var == 'Draftkings':
|
| 636 |
+
dk_lineups = init_DK_lineups(slate_type_var3, slate_var3, prio_var, prio_mix)
|
| 637 |
elif site_var == 'Fanduel':
|
| 638 |
+
fd_lineups = init_FD_lineups(slate_type_var3, slate_var3, prio_var, prio_mix)
|
| 639 |
+
with col3:
|
| 640 |
lineup_num_var = st.number_input("How many lineups do you want to display?", min_value=1, max_value=1000, value=150, step=1)
|
| 641 |
player_var1 = st.radio("Do you want a frame with specific Players?", ('Full Slate', 'Specific Players'), key='player_var1')
|
| 642 |
if player_var1 == 'Specific Players':
|
| 643 |
player_var2 = st.multiselect('Which players do you want?', options = raw_baselines['Player'].unique())
|
| 644 |
elif player_var1 == 'Full Slate':
|
| 645 |
player_var2 = raw_baselines.Player.values.tolist()
|
| 646 |
+
with col4:
|
| 647 |
if site_var == 'Draftkings':
|
| 648 |
salary_min_var = st.number_input("Minimum salary used", min_value = 0, max_value = 50000, value = 49000, step = 100, key = 'salary_min_var')
|
| 649 |
salary_max_var = st.number_input("Maximum salary used", min_value = 0, max_value = 50000, value = 50000, step = 100, key = 'salary_max_var')
|
|
|
|
| 654 |
elif slate_type_var3 == 'Showdown':
|
| 655 |
salary_min_var = st.number_input("Minimum salary used", min_value = 0, max_value = 60000, value = 59000, step = 100, key = 'salary_min_var')
|
| 656 |
salary_max_var = st.number_input("Maximum salary used", min_value = 0, max_value = 60000, value = 60000, step = 100, key = 'salary_max_var')
|
| 657 |
+
with col5:
|
| 658 |
if site_var == 'Draftkings':
|
| 659 |
min_stacks_var = st.number_input("Minimum stacks used", min_value = 0, max_value = 5, value = 3, step = 1, key = 'min_stacks_var')
|
| 660 |
max_stacks_var = st.number_input("Maximum stacks used", min_value = 0, max_value = 5, value = 5, step = 1, key = 'max_stacks_var')
|