James McCool
commited on
Commit
·
a8635e8
1
Parent(s):
47fd581
the while loop broke things, doing a range instead
Browse files
global_func/stratification_function.py
CHANGED
|
@@ -15,7 +15,7 @@ def stratification_function(portfolio: pd.DataFrame, lineup_target: int, exclude
|
|
| 15 |
similarity_floor = portfolio[sorting_choice].quantile(low_threshold / 100)
|
| 16 |
similarity_ceiling = portfolio[sorting_choice].quantile(high_threshold / 100)
|
| 17 |
|
| 18 |
-
|
| 19 |
target_similarities = np.linspace(similarity_floor, similarity_ceiling, lineup_target)
|
| 20 |
|
| 21 |
# Find the closest lineup to each target similarity score
|
|
@@ -29,7 +29,7 @@ def stratification_function(portfolio: pd.DataFrame, lineup_target: int, exclude
|
|
| 29 |
selected_indices = selected_indices[:lineup_target]
|
| 30 |
break
|
| 31 |
else:
|
| 32 |
-
lineup_target += 5
|
| 33 |
|
| 34 |
# Return view instead of copy
|
| 35 |
return portfolio.loc[selected_indices].sort_values(by=sorting_choice, ascending=False)
|
|
|
|
| 15 |
similarity_floor = portfolio[sorting_choice].quantile(low_threshold / 100)
|
| 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, lineup_target)
|
| 20 |
|
| 21 |
# Find the closest lineup to each target similarity score
|
|
|
|
| 29 |
selected_indices = selected_indices[:lineup_target]
|
| 30 |
break
|
| 31 |
else:
|
| 32 |
+
lineup_target += 5 * range_var
|
| 33 |
|
| 34 |
# Return view instead of copy
|
| 35 |
return portfolio.loc[selected_indices].sort_values(by=sorting_choice, ascending=False)
|