mgyigit commited on
Commit
478dc91
·
verified ·
1 Parent(s): d71c7e5

Update src/vis_utils.py

Browse files
Files changed (1) hide show
  1. src/vis_utils.py +22 -16
src/vis_utils.py CHANGED
@@ -179,31 +179,37 @@ def plot_family_results(method_names, dataset, metric, family_path="/tmp/family_
179
 
180
  # Filter by method names and selected dataset columns
181
  df = df[df['Method'].isin(method_names)]
182
- metric_columns = [col for col in df.columns if col.startswith(f"{dataset}_{metric}_")]
183
-
184
- # Reshape data for plotting
185
- df_long = pd.melt(df[['Method'] + metric_columns], id_vars=['Method'], var_name='Fold', value_name='Value')
186
- df_long['Fold'] = df_long['Fold'].apply(lambda x: int(x.split('_')[-1])) # Extract fold index
187
 
188
- df = df.fillna(0)
 
 
 
 
 
 
 
 
189
 
190
  # Set up the plot
191
- sns.set(rc={'figure.figsize': (13.7, 18.27)})
192
  sns.set_theme(style="whitegrid", color_codes=True)
193
- ax = sns.boxplot(data=df_long, x='Value', y='Method', hue='Fold', whis=np.inf, orient="h")
194
-
195
- # Customize x-axis and y-axis tickers and grid
 
 
196
  ax.xaxis.set_major_locator(ticker.MultipleLocator(0.2))
197
- ax.get_xaxis().set_minor_locator(ticker.AutoMinorLocator())
198
- ax.get_yaxis().set_minor_locator(ticker.AutoMinorLocator())
199
- ax.grid(visible=True, which='major', color='gainsboro', linewidth=1.0)
200
- ax.grid(visible=True, which='minor', color='whitesmoke', linewidth=0.5)
201
  ax.set_xlim(0, 1)
202
 
203
- # Draw dashed lines between different representations on y-axis
204
  yticks = ax.get_yticks()
205
  for ytick in yticks:
206
- ax.hlines(ytick + 0.5, -0.1, 1, linestyles='dashed')
 
207
 
208
  # Apply color settings to y-axis labels
209
  for label in ax.get_yticklabels():
 
179
 
180
  # Filter by method names and selected dataset columns
181
  df = df[df['Method'].isin(method_names)]
 
 
 
 
 
182
 
183
+ # Filter columns based on the aspect 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="Aspect_Metric_Fold", value_name="Value")
188
+
189
+ # Split the "Aspect_Metric_Fold" column into "Metric" and "Fold"
190
+ df_long[["Metric", "Fold"]] = df_long["Aspect_Metric_Fold"].str[len(aspect) + 1:].str.split("_", expand=True)
191
+ df_long["Fold"] = df_long["Fold"].astype(int)
192
 
193
  # Set up the plot
194
+ sns.set(rc={"figure.figsize": (13.7, 18.27)})
195
  sns.set_theme(style="whitegrid", color_codes=True)
196
+
197
+ # Create boxplot
198
+ ax = sns.boxplot(data=df_long, x="Value", y="Method", hue="Metric", whis=np.inf, orient="h")
199
+
200
+ # Customize grid and ticks
201
  ax.xaxis.set_major_locator(ticker.MultipleLocator(0.2))
202
+ ax.xaxis.set_minor_locator(ticker.AutoMinorLocator())
203
+ ax.yaxis.set_minor_locator(ticker.AutoMinorLocator())
204
+ ax.grid(visible=True, which="major", color="gainsboro", linewidth=1.0)
205
+ ax.grid(visible=True, which="minor", color="whitesmoke", linewidth=0.5)
206
  ax.set_xlim(0, 1)
207
 
208
+ # Add dashed lines between methods
209
  yticks = ax.get_yticks()
210
  for ytick in yticks:
211
+ ax.hlines(ytick + 0.5, -0.1, 1, linestyles="dashed", color="gray")
212
+
213
 
214
  # Apply color settings to y-axis labels
215
  for label in ax.get_yticklabels():