Spaces:
Sleeping
Sleeping
Update src/vis_utils.py
Browse files- src/vis_utils.py +6 -6
src/vis_utils.py
CHANGED
@@ -30,7 +30,7 @@ def benchmark_plot(benchmark_type, methods_selected, x_metric, y_metric, aspect,
|
|
30 |
elif benchmark_type == 'function':
|
31 |
return plot_function_results(methods_selected, aspect, single_metric)
|
32 |
elif benchmark_type == 'family':
|
33 |
-
return plot_family_results(methods_selected, dataset
|
34 |
elif benchmark_type == "affinity":
|
35 |
return plot_affinity_results(methods_selected, single_metric)
|
36 |
else:
|
@@ -170,7 +170,7 @@ def plot_function_results(method_names, aspect, metric, function_path="/tmp/func
|
|
170 |
|
171 |
return filename
|
172 |
|
173 |
-
def plot_family_results(method_names, dataset,
|
174 |
if not os.path.exists(family_path):
|
175 |
benchmark_types = ["similarity", "function", "family", "affinity"] #download all files for faster results later
|
176 |
download_from_hub(benchmark_types)
|
@@ -180,14 +180,14 @@ def plot_family_results(method_names, dataset, metric, family_path="/tmp/family_
|
|
180 |
# Filter by method names and selected dataset columns
|
181 |
df = df[df['Method'].isin(method_names)]
|
182 |
|
183 |
-
# Filter columns based on the
|
184 |
value_vars = [col for col in df.columns if col.startswith(f"{dataset}_") and "_" in col]
|
185 |
|
186 |
# Reshape the DataFrame to long format
|
187 |
-
df_long = pd.melt(df, id_vars=["Method"], value_vars=value_vars, var_name="
|
188 |
|
189 |
-
# Split the "
|
190 |
-
df_long[["Metric", "Fold"]] = df_long["
|
191 |
df_long["Fold"] = df_long["Fold"].astype(int)
|
192 |
|
193 |
# Set up the plot
|
|
|
30 |
elif benchmark_type == 'function':
|
31 |
return plot_function_results(methods_selected, aspect, single_metric)
|
32 |
elif benchmark_type == 'family':
|
33 |
+
return plot_family_results(methods_selected, dataset)
|
34 |
elif benchmark_type == "affinity":
|
35 |
return plot_affinity_results(methods_selected, single_metric)
|
36 |
else:
|
|
|
170 |
|
171 |
return filename
|
172 |
|
173 |
+
def plot_family_results(method_names, dataset, family_path="/tmp/family_results.csv"):
|
174 |
if not os.path.exists(family_path):
|
175 |
benchmark_types = ["similarity", "function", "family", "affinity"] #download all files for faster results later
|
176 |
download_from_hub(benchmark_types)
|
|
|
180 |
# Filter by method names and selected dataset columns
|
181 |
df = df[df['Method'].isin(method_names)]
|
182 |
|
183 |
+
# Filter columns based on the dataset and metrics
|
184 |
value_vars = [col for col in df.columns if col.startswith(f"{dataset}_") and "_" in col]
|
185 |
|
186 |
# Reshape the DataFrame to long format
|
187 |
+
df_long = pd.melt(df, id_vars=["Method"], value_vars=value_vars, var_name="Dataset_Metric_Fold", value_name="Value")
|
188 |
|
189 |
+
# Split the "Dataset_Metric_Fold" column into "Metric" and "Fold"
|
190 |
+
df_long[["Metric", "Fold"]] = df_long["Dataset_Metric_Fold"].str[len(dataset) + 1:].str.split("_", expand=True)
|
191 |
df_long["Fold"] = df_long["Fold"].astype(int)
|
192 |
|
193 |
# Set up the plot
|