Spaces:
Running
Running
jasonshaoshun
commited on
Commit
·
51441a1
1
Parent(s):
cefacdb
debug
Browse files- src/populate.py +25 -1
src/populate.py
CHANGED
@@ -68,12 +68,32 @@ def get_leaderboard_df_mib_subgraph(results_path: str, requests_path: str, cols:
|
|
68 |
|
69 |
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
def aggregate_methods(df: pd.DataFrame) -> pd.DataFrame:
|
72 |
"""Aggregates rows with the same base method name by taking the max value for each column"""
|
73 |
df_copy = df.copy()
|
74 |
|
|
|
|
|
|
|
|
|
75 |
# Extract base method names (remove _2, _3, etc. suffixes)
|
76 |
-
base_methods = [name.split('_')[0] if '_' in name and name.split('_')[-1].isdigit()
|
77 |
else name for name in df_copy.index]
|
78 |
df_copy.index = base_methods
|
79 |
|
@@ -83,6 +103,10 @@ def aggregate_methods(df: pd.DataFrame) -> pd.DataFrame:
|
|
83 |
# Group by base method name and take the max
|
84 |
aggregated_df = numeric_df.groupby(level=0).max().round(3)
|
85 |
|
|
|
|
|
|
|
|
|
86 |
return aggregated_df
|
87 |
|
88 |
def create_intervention_averaged_df(df: pd.DataFrame) -> pd.DataFrame:
|
|
|
68 |
|
69 |
|
70 |
|
71 |
+
# def aggregate_methods(df: pd.DataFrame) -> pd.DataFrame:
|
72 |
+
# """Aggregates rows with the same base method name by taking the max value for each column"""
|
73 |
+
# df_copy = df.copy()
|
74 |
+
|
75 |
+
# # Extract base method names (remove _2, _3, etc. suffixes)
|
76 |
+
# base_methods = [name.split('_')[0] if '_' in name and name.split('_')[-1].isdigit()
|
77 |
+
# else name for name in df_copy.index]
|
78 |
+
# df_copy.index = base_methods
|
79 |
+
|
80 |
+
# # Convert scores to numeric values
|
81 |
+
# numeric_df = df_copy.select_dtypes(include=['float64', 'int64'])
|
82 |
+
|
83 |
+
# # Group by base method name and take the max
|
84 |
+
# aggregated_df = numeric_df.groupby(level=0).max().round(3)
|
85 |
+
|
86 |
+
# return aggregated_df
|
87 |
def aggregate_methods(df: pd.DataFrame) -> pd.DataFrame:
|
88 |
"""Aggregates rows with the same base method name by taking the max value for each column"""
|
89 |
df_copy = df.copy()
|
90 |
|
91 |
+
# Set Method as index if it isn't already
|
92 |
+
if 'Method' in df_copy.columns:
|
93 |
+
df_copy.set_index('Method', inplace=True)
|
94 |
+
|
95 |
# Extract base method names (remove _2, _3, etc. suffixes)
|
96 |
+
base_methods = [name.split('_')[0] if '_' in str(name) and str(name).split('_')[-1].isdigit()
|
97 |
else name for name in df_copy.index]
|
98 |
df_copy.index = base_methods
|
99 |
|
|
|
103 |
# Group by base method name and take the max
|
104 |
aggregated_df = numeric_df.groupby(level=0).max().round(3)
|
105 |
|
106 |
+
# Reset index to get Method as a column
|
107 |
+
aggregated_df.reset_index(inplace=True)
|
108 |
+
aggregated_df.rename(columns={'index': 'Method'}, inplace=True)
|
109 |
+
|
110 |
return aggregated_df
|
111 |
|
112 |
def create_intervention_averaged_df(df: pd.DataFrame) -> pd.DataFrame:
|