Spaces:
Running
Running
jasonshaoshun
commited on
Commit
·
202dbe2
1
Parent(s):
51441a1
debug
Browse files- src/populate.py +37 -3
src/populate.py
CHANGED
@@ -109,13 +109,43 @@ def aggregate_methods(df: pd.DataFrame) -> pd.DataFrame:
|
|
109 |
|
110 |
return aggregated_df
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
def create_intervention_averaged_df(df: pd.DataFrame) -> pd.DataFrame:
|
113 |
"""Creates a DataFrame where columns are model_task and cells are averaged over interventions"""
|
114 |
df_copy = df.copy()
|
115 |
|
116 |
-
#
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
# Group columns by model_task
|
121 |
model_task_groups = {}
|
@@ -131,6 +161,10 @@ def create_intervention_averaged_df(df: pd.DataFrame) -> pd.DataFrame:
|
|
131 |
for model_task, cols in model_task_groups.items()
|
132 |
})
|
133 |
|
|
|
|
|
|
|
|
|
134 |
return averaged_df
|
135 |
|
136 |
# def get_leaderboard_df_mib_causalgraph(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
|
|
109 |
|
110 |
return aggregated_df
|
111 |
|
112 |
+
# def create_intervention_averaged_df(df: pd.DataFrame) -> pd.DataFrame:
|
113 |
+
# """Creates a DataFrame where columns are model_task and cells are averaged over interventions"""
|
114 |
+
# df_copy = df.copy()
|
115 |
+
|
116 |
+
# # Remove the Method column and eval_name if present
|
117 |
+
# columns_to_drop = ['Method', 'eval_name']
|
118 |
+
# df_copy = df_copy.drop(columns=[col for col in columns_to_drop if col in df_copy.columns])
|
119 |
+
|
120 |
+
# # Group columns by model_task
|
121 |
+
# model_task_groups = {}
|
122 |
+
# for col in df_copy.columns:
|
123 |
+
# model_task = '_'.join(col.split('_')[:2]) # Get model_task part
|
124 |
+
# if model_task not in model_task_groups:
|
125 |
+
# model_task_groups[model_task] = []
|
126 |
+
# model_task_groups[model_task].append(col)
|
127 |
+
|
128 |
+
# # Create new DataFrame with averaged intervention scores
|
129 |
+
# averaged_df = pd.DataFrame({
|
130 |
+
# model_task: df_copy[cols].mean(axis=1).round(3)
|
131 |
+
# for model_task, cols in model_task_groups.items()
|
132 |
+
# })
|
133 |
+
|
134 |
+
# return averaged_df
|
135 |
+
|
136 |
def create_intervention_averaged_df(df: pd.DataFrame) -> pd.DataFrame:
|
137 |
"""Creates a DataFrame where columns are model_task and cells are averaged over interventions"""
|
138 |
df_copy = df.copy()
|
139 |
|
140 |
+
# Store Method column if it exists
|
141 |
+
method_col = None
|
142 |
+
if 'Method' in df_copy.columns:
|
143 |
+
method_col = df_copy['Method']
|
144 |
+
df_copy = df_copy.drop('Method', axis=1)
|
145 |
+
|
146 |
+
# Remove eval_name if present
|
147 |
+
if 'eval_name' in df_copy.columns:
|
148 |
+
df_copy = df_copy.drop('eval_name', axis=1)
|
149 |
|
150 |
# Group columns by model_task
|
151 |
model_task_groups = {}
|
|
|
161 |
for model_task, cols in model_task_groups.items()
|
162 |
})
|
163 |
|
164 |
+
# Add Method column back
|
165 |
+
if method_col is not None:
|
166 |
+
averaged_df.insert(0, 'Method', method_col)
|
167 |
+
|
168 |
return averaged_df
|
169 |
|
170 |
# def get_leaderboard_df_mib_causalgraph(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|