James McCool
commited on
Commit
·
521dad6
1
Parent(s):
7ba4f09
had to designate a maliable target
Browse files
global_func/stratification_function.py
CHANGED
|
@@ -4,6 +4,7 @@ import numpy as np
|
|
| 4 |
def stratification_function(portfolio: pd.DataFrame, lineup_target: int, exclude_cols: list, sport: str, sorting_choice: str, low_threshold: float, high_threshold: float):
|
| 5 |
excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Size', 'Win%', 'Lineup Edge', 'Weighted Own', 'Geomean', 'Diversity', 'SE Score']
|
| 6 |
player_columns = [col for col in portfolio.columns if col not in excluded_cols]
|
|
|
|
| 7 |
|
| 8 |
# Work with indices instead of copying entire DataFrame
|
| 9 |
if sorting_choice == 'Finish_percentile':
|
|
@@ -16,7 +17,7 @@ def stratification_function(portfolio: pd.DataFrame, lineup_target: int, exclude
|
|
| 16 |
similarity_ceiling = portfolio[sorting_choice].quantile(high_threshold / 100)
|
| 17 |
|
| 18 |
for range_var in range(1, 10):
|
| 19 |
-
target_similarities = np.linspace(similarity_floor, similarity_ceiling,
|
| 20 |
|
| 21 |
# Find the closest lineup to each target similarity score
|
| 22 |
selected_indices = []
|
|
@@ -34,7 +35,7 @@ def stratification_function(portfolio: pd.DataFrame, lineup_target: int, exclude
|
|
| 34 |
print(len(selected_indices))
|
| 35 |
range_var = 10
|
| 36 |
else:
|
| 37 |
-
|
| 38 |
|
| 39 |
# Return view instead of copy
|
| 40 |
return portfolio.loc[selected_indices].sort_values(by=sorting_choice, ascending=False)
|
|
|
|
| 4 |
def stratification_function(portfolio: pd.DataFrame, lineup_target: int, exclude_cols: list, sport: str, sorting_choice: str, low_threshold: float, high_threshold: float):
|
| 5 |
excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Size', 'Win%', 'Lineup Edge', 'Weighted Own', 'Geomean', 'Diversity', 'SE Score']
|
| 6 |
player_columns = [col for col in portfolio.columns if col not in excluded_cols]
|
| 7 |
+
base_target = lineup_target
|
| 8 |
|
| 9 |
# Work with indices instead of copying entire DataFrame
|
| 10 |
if sorting_choice == 'Finish_percentile':
|
|
|
|
| 17 |
similarity_ceiling = portfolio[sorting_choice].quantile(high_threshold / 100)
|
| 18 |
|
| 19 |
for range_var in range(1, 10):
|
| 20 |
+
target_similarities = np.linspace(similarity_floor, similarity_ceiling, base_target)
|
| 21 |
|
| 22 |
# Find the closest lineup to each target similarity score
|
| 23 |
selected_indices = []
|
|
|
|
| 35 |
print(len(selected_indices))
|
| 36 |
range_var = 10
|
| 37 |
else:
|
| 38 |
+
base_target += 5 * range_var
|
| 39 |
|
| 40 |
# Return view instead of copy
|
| 41 |
return portfolio.loc[selected_indices].sort_values(by=sorting_choice, ascending=False)
|