James McCool
commited on
Commit
·
1d2969e
1
Parent(s):
fc194d7
Enhance exposure_spread function to include stacking_sports parameter, improving player selection logic for size 5 lineups in app.py and exposure_spread.py.
Browse files- app.py +2 -3
- global_func/exposure_spread.py +7 -7
app.py
CHANGED
@@ -26,7 +26,6 @@ from global_func.reduce_volatility_preset import reduce_volatility_preset
|
|
26 |
from global_func.analyze_player_combos import analyze_player_combos
|
27 |
from global_func.stratification_function import stratification_function
|
28 |
from global_func.exposure_spread import exposure_spread
|
29 |
-
from global_func.reassess_edge import reassess_edge
|
30 |
|
31 |
freq_format = {'Finish_percentile': '{:.2%}', 'Lineup Edge': '{:.2%}', 'Win%': '{:.2%}'}
|
32 |
stacking_sports = ['MLB', 'NHL', 'NFL', 'LOL']
|
@@ -1348,7 +1347,7 @@ with tab2:
|
|
1348 |
if reg_submitted:
|
1349 |
st.session_state['settings_base'] = False
|
1350 |
prior_frame = st.session_state['working_frame'].copy()
|
1351 |
-
parsed_frame = exposure_spread(st.session_state['working_frame'], st.session_state['exposure_player'], exposure_target, exposure_stack_bool, remove_teams_exposure, st.session_state['projections_df'], sport_var, type_var, salary_max)
|
1352 |
|
1353 |
if type_var == 'Classic':
|
1354 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
@@ -1441,7 +1440,7 @@ with tab2:
|
|
1441 |
elif exp_submitted:
|
1442 |
st.session_state['settings_base'] = False
|
1443 |
prior_frame = st.session_state['export_base'].copy()
|
1444 |
-
parsed_frame = exposure_spread(st.session_state['export_base'], st.session_state['exposure_player'], exposure_target, exposure_stack_bool, remove_teams_exposure, st.session_state['projections_df'], sport_var, type_var, salary_max)
|
1445 |
|
1446 |
if type_var == 'Classic':
|
1447 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
|
|
26 |
from global_func.analyze_player_combos import analyze_player_combos
|
27 |
from global_func.stratification_function import stratification_function
|
28 |
from global_func.exposure_spread import exposure_spread
|
|
|
29 |
|
30 |
freq_format = {'Finish_percentile': '{:.2%}', 'Lineup Edge': '{:.2%}', 'Win%': '{:.2%}'}
|
31 |
stacking_sports = ['MLB', 'NHL', 'NFL', 'LOL']
|
|
|
1347 |
if reg_submitted:
|
1348 |
st.session_state['settings_base'] = False
|
1349 |
prior_frame = st.session_state['working_frame'].copy()
|
1350 |
+
parsed_frame = exposure_spread(st.session_state['working_frame'], st.session_state['exposure_player'], exposure_target, exposure_stack_bool, remove_teams_exposure, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
1351 |
|
1352 |
if type_var == 'Classic':
|
1353 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
|
|
1440 |
elif exp_submitted:
|
1441 |
st.session_state['settings_base'] = False
|
1442 |
prior_frame = st.session_state['export_base'].copy()
|
1443 |
+
parsed_frame = exposure_spread(st.session_state['export_base'], st.session_state['exposure_player'], exposure_target, exposure_stack_bool, remove_teams_exposure, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
1444 |
|
1445 |
if type_var == 'Classic':
|
1446 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
global_func/exposure_spread.py
CHANGED
@@ -148,7 +148,7 @@ def check_position_eligibility(sport, column_name, player_positions):
|
|
148 |
# Default fallback - assume exact position match
|
149 |
return column_name in player_positions
|
150 |
|
151 |
-
def exposure_spread(working_frame, exposure_player, exposure_target, exposure_stack_bool, remove_teams, projections_df, sport_var, type_var, salary_max):
|
152 |
comparable_players = projections_df[projections_df['player_names'] == exposure_player]
|
153 |
|
154 |
comparable_players = comparable_players.reset_index(drop=True)
|
@@ -266,12 +266,12 @@ def exposure_spread(working_frame, exposure_player, exposure_target, exposure_st
|
|
266 |
(projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row])) &
|
267 |
(projections_df['position'].apply(lambda x: has_position_overlap(x, comp_player_position)))
|
268 |
]
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
|
276 |
if remove_teams is not None:
|
277 |
remove_mask = comparable_players.apply(
|
|
|
148 |
# Default fallback - assume exact position match
|
149 |
return column_name in player_positions
|
150 |
|
151 |
+
def exposure_spread(working_frame, exposure_player, exposure_target, exposure_stack_bool, remove_teams, projections_df, sport_var, type_var, salary_max, stacking_sports):
|
152 |
comparable_players = projections_df[projections_df['player_names'] == exposure_player]
|
153 |
|
154 |
comparable_players = comparable_players.reset_index(drop=True)
|
|
|
266 |
(projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row])) &
|
267 |
(projections_df['position'].apply(lambda x: has_position_overlap(x, comp_player_position)))
|
268 |
]
|
269 |
+
if sport_var in stacking_sports:
|
270 |
+
if row['Size'] == 5 and comp_team != row['Stack']:
|
271 |
+
remove_mask = comparable_players.apply(
|
272 |
+
lambda row: not any(team in list(row) for team in working_frame['Stack'][row]), axis=1
|
273 |
+
)
|
274 |
+
comparable_players = comparable_players[remove_mask]
|
275 |
|
276 |
if remove_teams is not None:
|
277 |
remove_mask = comparable_players.apply(
|