Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
9fa6f26
1
Parent(s):
8833483
Refactor reassess_finish_percentile function in reassess_edge.py to simplify calculations by using ownership and median differences, improving accuracy in finish_percentile adjustments. Update column drop logic to remove unnecessary columns for cleaner data handling.
Browse files- global_func/reassess_edge.py +5 -26
global_func/reassess_edge.py
CHANGED
|
@@ -44,31 +44,10 @@ def calculate_weighted_ownership_single_row(row_ownerships):
|
|
| 44 |
# Convert back to percentage form
|
| 45 |
return weighted * 10000
|
| 46 |
|
| 47 |
-
def reassess_finish_percentile(row: pd.Series, own_columns: list
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
Args:
|
| 52 |
-
row: pandas Series containing the row data
|
| 53 |
-
own_columns: list of ownership column names
|
| 54 |
-
|
| 55 |
-
Returns:
|
| 56 |
-
float: new finish_percentile value
|
| 57 |
-
"""
|
| 58 |
-
percentile_multiplier = 1.00
|
| 59 |
-
|
| 60 |
-
# Step 1: Adjust Finish_percentile
|
| 61 |
-
finish_percentile = row['Finish_percentile'] + 0.005 + (0.005 * (Contest_Size / 10000))
|
| 62 |
-
|
| 63 |
-
# Step 2: Apply multiplier and ownership adjustment
|
| 64 |
-
finish_percentile = finish_percentile * percentile_multiplier * (row['Own'] / (100 + (Contest_Size / 1000)))
|
| 65 |
-
|
| 66 |
-
# Step 3: Count low ownership players
|
| 67 |
-
low_own_count = sum(1 for col in own_columns if row[col] < 0.10)
|
| 68 |
-
|
| 69 |
-
# Step 4: Apply low ownership adjustment
|
| 70 |
-
if low_own_count > 0:
|
| 71 |
-
finish_percentile = finish_percentile / low_own_count
|
| 72 |
|
| 73 |
return finish_percentile
|
| 74 |
|
|
@@ -139,6 +118,6 @@ def reassess_edge(refactored_frame: pd.DataFrame, original_frame: pd.DataFrame,
|
|
| 139 |
refactored_df.loc[lineups, 'Weighted Own'] = calculate_weighted_ownership_single_row(refactored_df.loc[lineups, own_columns])
|
| 140 |
refactored_df.loc[lineups, 'Geomean'] = np.power((refactored_df.loc[lineups, own_columns] * 100).product(), 1 / len(own_columns))
|
| 141 |
|
| 142 |
-
refactored_df = refactored_df.drop(columns=own_columns)
|
| 143 |
|
| 144 |
return refactored_df
|
|
|
|
| 44 |
# Convert back to percentage form
|
| 45 |
return weighted * 10000
|
| 46 |
|
| 47 |
+
def reassess_finish_percentile(row: pd.Series, own_columns: list) -> float:
|
| 48 |
+
own_diff = float(row['own_diff'])
|
| 49 |
+
median_diff = float(row['median_diff'])
|
| 50 |
+
finish_percentile = row['Finish_percentile'] + (own_diff / 2) - (median_diff / 100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
return finish_percentile
|
| 53 |
|
|
|
|
| 118 |
refactored_df.loc[lineups, 'Weighted Own'] = calculate_weighted_ownership_single_row(refactored_df.loc[lineups, own_columns])
|
| 119 |
refactored_df.loc[lineups, 'Geomean'] = np.power((refactored_df.loc[lineups, own_columns] * 100).product(), 1 / len(own_columns))
|
| 120 |
|
| 121 |
+
refactored_df = refactored_df.drop(columns=['salary_diff', 'median_diff', 'own_diff', 'player_0_own', 'Edge'] + own_columns)
|
| 122 |
|
| 123 |
return refactored_df
|