James McCool
commited on
Commit
·
1e4e9b8
1
Parent(s):
fb33fb9
Add salary, median, and ownership calculations for Classic and Showdown types in exposure_spread function
Browse filesEnhance the exposure_spread function to compute salary, median projections, and ownership metrics based on player data for both Classic and Showdown types. Implement conditional logic to differentiate calculations for CS2 and LOL sports, ensuring accurate data handling and type-specific adjustments.
app.py
CHANGED
@@ -1199,6 +1199,63 @@ with tab2:
|
|
1199 |
st.session_state['settings_base'] = False
|
1200 |
parsed_frame = exposure_spread(st.session_state['working_frame'], exposure_player, exposure_target, exposure_stack_bool, remove_teams_exposure, st.session_state['projections_df'], sport_var, type_var, salary_max)
|
1201 |
st.session_state['working_frame'] = parsed_frame.reset_index(drop=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1202 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
1203 |
with st.container():
|
1204 |
if 'export_base' not in st.session_state:
|
|
|
1199 |
st.session_state['settings_base'] = False
|
1200 |
parsed_frame = exposure_spread(st.session_state['working_frame'], exposure_player, exposure_target, exposure_stack_bool, remove_teams_exposure, st.session_state['projections_df'], sport_var, type_var, salary_max)
|
1201 |
st.session_state['working_frame'] = parsed_frame.reset_index(drop=True)
|
1202 |
+
if type_var == 'Classic':
|
1203 |
+
if sport_var == 'CS2' or sport_var == 'LOL':
|
1204 |
+
# Calculate salary (CPT uses cpt_salary_map, others use salary_map)
|
1205 |
+
st.session_state['working_frame']['salary'] = st.session_state['working_frame'].apply(
|
1206 |
+
lambda row: st.session_state['map_dict']['cpt_salary_map'].get(row.iloc[0], 0) +
|
1207 |
+
sum(st.session_state['map_dict']['salary_map'].get(player, 0) for player in row.iloc[1:]),
|
1208 |
+
axis=1
|
1209 |
+
)
|
1210 |
+
|
1211 |
+
# Calculate median (CPT uses cpt_proj_map, others use proj_map)
|
1212 |
+
st.session_state['working_frame']['median'] = st.session_state['working_frame'].apply(
|
1213 |
+
lambda row: st.session_state['map_dict']['cpt_proj_map'].get(row.iloc[0], 0) +
|
1214 |
+
sum(st.session_state['map_dict']['proj_map'].get(player, 0) for player in row.iloc[1:]),
|
1215 |
+
axis=1
|
1216 |
+
)
|
1217 |
+
|
1218 |
+
# Calculate ownership (CPT uses cpt_own_map, others use own_map)
|
1219 |
+
st.session_state['working_frame']['Own'] = st.session_state['working_frame'].apply(
|
1220 |
+
lambda row: st.session_state['map_dict']['cpt_own_map'].get(row.iloc[0], 0) +
|
1221 |
+
sum(st.session_state['map_dict']['own_map'].get(player, 0) for player in row.iloc[1:]),
|
1222 |
+
axis=1
|
1223 |
+
)
|
1224 |
+
|
1225 |
+
elif sport_var != 'CS2' and sport_var != 'LOL':
|
1226 |
+
st.session_state['working_frame']['salary'] = st.session_state['working_frame'].apply(lambda row: sum(st.session_state['map_dict']['salary_map'].get(player, 0) for player in row), axis=1)
|
1227 |
+
st.session_state['working_frame']['median'] = st.session_state['working_frame'].apply(lambda row: sum(st.session_state['map_dict']['proj_map'].get(player, 0) for player in row), axis=1)
|
1228 |
+
st.session_state['working_frame']['Own'] = st.session_state['working_frame'].apply(lambda row: sum(st.session_state['map_dict']['own_map'].get(player, 0) for player in row), axis=1)
|
1229 |
+
if 'stack_dict' in st.session_state:
|
1230 |
+
st.session_state['working_frame']['Stack'] = st.session_state['working_frame'].index.map(st.session_state['stack_dict'])
|
1231 |
+
st.session_state['working_frame']['Size'] = st.session_state['working_frame'].index.map(st.session_state['size_dict'])
|
1232 |
+
elif type_var == 'Showdown':
|
1233 |
+
# Calculate salary (CPT uses cpt_salary_map, others use salary_map)
|
1234 |
+
st.session_state['working_frame']['salary'] = st.session_state['working_frame'].apply(
|
1235 |
+
lambda row: st.session_state['map_dict']['cpt_salary_map'].get(row.iloc[0], 0) +
|
1236 |
+
sum(st.session_state['map_dict']['salary_map'].get(player, 0) for player in row.iloc[1:]),
|
1237 |
+
axis=1
|
1238 |
+
)
|
1239 |
+
|
1240 |
+
# Calculate median (CPT uses cpt_proj_map, others use proj_map)
|
1241 |
+
st.session_state['working_frame']['median'] = st.session_state['working_frame'].apply(
|
1242 |
+
lambda row: st.session_state['map_dict']['cpt_proj_map'].get(row.iloc[0], 0) +
|
1243 |
+
sum(st.session_state['map_dict']['proj_map'].get(player, 0) for player in row.iloc[1:]),
|
1244 |
+
axis=1
|
1245 |
+
)
|
1246 |
+
|
1247 |
+
# Calculate ownership (CPT uses cpt_own_map, others use own_map)
|
1248 |
+
st.session_state['working_frame']['Own'] = st.session_state['working_frame'].apply(
|
1249 |
+
lambda row: st.session_state['map_dict']['cpt_own_map'].get(row.iloc[0], 0) +
|
1250 |
+
sum(st.session_state['map_dict']['own_map'].get(player, 0) for player in row.iloc[1:]),
|
1251 |
+
axis=1
|
1252 |
+
)
|
1253 |
+
# st.session_state['working_frame']['Own'] = st.session_state['working_frame']['Own'].astype('float32')
|
1254 |
+
st.session_state['working_frame']['median'] = st.session_state['working_frame']['median'].astype('float32')
|
1255 |
+
st.session_state['working_frame']['salary'] = st.session_state['working_frame']['salary'].astype('uint16')
|
1256 |
+
|
1257 |
+
print(st.session_state['working_frame'].head(10))
|
1258 |
+
st.session_state['working_frame'] = predict_dupes(st.session_state['working_frame'], st.session_state['map_dict'], site_var, type_var, Contest_Size, strength_var, sport_var)
|
1259 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
1260 |
with st.container():
|
1261 |
if 'export_base' not in st.session_state:
|