James McCool
commited on
Commit
·
2bbbfdd
1
Parent(s):
33beedc
Refactor hedging_preset.py to use a configurable list size for top owned players. This change enhances flexibility in player selection and adjusts lineup target calculations accordingly.
Browse files
global_func/hedging_preset.py
CHANGED
@@ -6,10 +6,11 @@ from global_func.large_field_preset import large_field_preset
|
|
6 |
def hedging_preset(portfolio: pd.DataFrame, lineup_target: int, projections_file: pd.DataFrame):
|
7 |
|
8 |
excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Size', 'Win%', 'Lineup Edge', 'Weighted Own', 'Geomean', 'Similarity Score']
|
|
|
9 |
|
10 |
check_own_df = projections_file.copy()
|
11 |
check_own_df = check_own_df.sort_values(by='ownership', ascending=False)
|
12 |
-
top_owned = check_own_df['player_names'].head(
|
13 |
|
14 |
concat_portfolio = pd.DataFrame(columns=portfolio.columns)
|
15 |
|
@@ -29,8 +30,8 @@ def hedging_preset(portfolio: pd.DataFrame, lineup_target: int, projections_file
|
|
29 |
removed_df = working_df[remove_mask]
|
30 |
locked_df = working_df[lock_mask]
|
31 |
|
32 |
-
removed_lineups = small_field_preset(removed_df, math.ceil(lineup_target / 2), excluded_cols)
|
33 |
-
locked_lineups = large_field_preset(locked_df, math.ceil(lineup_target / 2), excluded_cols)
|
34 |
|
35 |
concat_portfolio = pd.concat([concat_portfolio, removed_lineups, locked_lineups])
|
36 |
|
|
|
6 |
def hedging_preset(portfolio: pd.DataFrame, lineup_target: int, projections_file: pd.DataFrame):
|
7 |
|
8 |
excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Size', 'Win%', 'Lineup Edge', 'Weighted Own', 'Geomean', 'Similarity Score']
|
9 |
+
list_size = 3
|
10 |
|
11 |
check_own_df = projections_file.copy()
|
12 |
check_own_df = check_own_df.sort_values(by='ownership', ascending=False)
|
13 |
+
top_owned = check_own_df['player_names'].head(list_size).tolist()
|
14 |
|
15 |
concat_portfolio = pd.DataFrame(columns=portfolio.columns)
|
16 |
|
|
|
30 |
removed_df = working_df[remove_mask]
|
31 |
locked_df = working_df[lock_mask]
|
32 |
|
33 |
+
removed_lineups = small_field_preset(removed_df, math.ceil(lineup_target / (list_size * 2)), excluded_cols)
|
34 |
+
locked_lineups = large_field_preset(locked_df, math.ceil(lineup_target / (list_size * 2)), excluded_cols)
|
35 |
|
36 |
concat_portfolio = pd.concat([concat_portfolio, removed_lineups, locked_lineups])
|
37 |
|