@@ -172,190 +172,128 @@ def extract_metrics(exp_text, algorithm, dataset, trainers):
172172
173173
174174def generate_accuracy_comparison (df , output_file = "gc_accuracy_comparison.pdf" ):
175- """Generate accuracy plot with datasets on x-axis and algorithms as legend"""
176175 if df .empty or df ["Accuracy" ].isna ().all ():
177176 print ("No accuracy data available to plot" )
178177 return None
179-
180- # Filter out rows with missing accuracy
181178 df_filtered = df .dropna (subset = ["Accuracy" ])
182-
183- # Create a grouped DataFrame
184179 comparison_data = (
185180 df_filtered .groupby (["Dataset" , "Algorithm" ])
186181 .agg ({"Accuracy" : "mean" })
187182 .reset_index ()
188183 )
189-
190184 print (f"Plotting accuracy comparison with { len (comparison_data )} data points" )
191-
192- # Create figure
193- plt .figure (figsize = (12 , 6 ))
194-
195- # Get unique datasets and algorithms in desired order
185+ plt .figure (figsize = (14 , 8 ))
196186 datasets = sorted (
197187 comparison_data ["Dataset" ].unique (),
198188 key = lambda x : ["IMDB-BINARY" , "IMDB-MULTI" , "MUTAG" , "BZR" , "COX2" ].index (x )
199189 if x in ["IMDB-BINARY" , "IMDB-MULTI" , "MUTAG" , "BZR" , "COX2" ]
200190 else 999 ,
201191 )
202-
203192 algorithms = sorted (
204193 comparison_data ["Algorithm" ].unique (),
205194 key = lambda x : ["FedAvg" , "GCFL" , "GCFL+" , "GCFL+dWs" ].index (x )
206195 if x in ["FedAvg" , "GCFL" , "GCFL+" , "GCFL+dWs" ]
207196 else 999 ,
208197 )
209-
210- # Set x positions
211198 x_positions = np .arange (len (datasets ))
212-
213- # Bar width
214199 width = 0.8 / len (algorithms )
215-
216- # Colors
217- algorithm_colors = ["#1f77b4" , "#ff7f0e" , "#2ca02c" , "#d62728" ]
218-
219- # Plot bars for each algorithm
200+ actual_colors = ["#1f77b4" , "#ff7f0e" , "#2ca02c" , "#d62728" , "#9467bd" ]
220201 for i , algo in enumerate (algorithms ):
221202 algo_data = comparison_data [comparison_data ["Algorithm" ] == algo ]
222-
223- # Prepare data in dataset order
224203 accuracy_values = []
225-
226- # Ensure consistent ordering
227204 for dataset in datasets :
228205 dataset_row = algo_data [algo_data ["Dataset" ] == dataset ]
229206 if not dataset_row .empty and not pd .isna (dataset_row ["Accuracy" ].values [0 ]):
230207 accuracy_values .append (dataset_row ["Accuracy" ].values [0 ])
231208 else :
232209 accuracy_values .append (0 )
233-
234- # Plot bars
235210 plt .bar (
236211 x_positions + (i - len (algorithms ) / 2 + 0.5 ) * width ,
237212 accuracy_values ,
238213 width = width ,
239214 label = algo ,
240- color = algorithm_colors [i % len (algorithm_colors )],
215+ color = actual_colors [i % len (actual_colors )],
241216 )
242-
243- # Set chart properties
244- plt .title ("Accuracy Comparison" , fontsize = 30 )
217+ #plt.title("Accuracy Comparison", fontsize=30)
245218 plt .xlabel ("Dataset" , fontsize = 30 )
246219 plt .ylabel ("Accuracy" , fontsize = 30 )
247- plt .xticks (x_positions , datasets , rotation = 45 , fontsize = 30 )
220+ plt .xticks (x_positions , datasets , rotation = 30 , fontsize = 20 )
248221 plt .yticks (fontsize = 30 )
249222 plt .ylim (0 , 1.0 )
250223 plt .legend (
251- title = "Algorithms" ,
224+ # title="Algorithms",
252225 loc = "upper left" ,
253226 bbox_to_anchor = (1 , 1 ),
254- fontsize = 25 ,
255- title_fontsize = 25 ,
227+ fontsize = 22 ,
228+ # title_fontsize=25,
256229 )
257230 plt .grid (False )
258231 plt .tight_layout ()
259-
260- # Save and close
261232 plt .savefig (output_file , dpi = 300 )
262233 plt .close ()
263-
264234 print (f"Accuracy comparison plot saved to: { output_file } " )
265235 return output_file
266236
267237
268238def generate_train_time_comparison (df , output_file = "gc_train_time_comparison.pdf" ):
269- """Generate train time plot with datasets on x-axis and algorithms as legend"""
270239 if df .empty or df ["Train_Time_ms" ].isna ().all ():
271240 print ("No training time data available to plot" )
272241 return None
273-
274- # Filter out rows with missing train time
275242 df_filtered = df .dropna (subset = ["Train_Time_ms" ])
276-
277- # Create a grouped DataFrame
278243 comparison_data = (
279244 df_filtered .groupby (["Dataset" , "Algorithm" ])
280245 .agg ({"Train_Time_ms" : "mean" })
281246 .reset_index ()
282247 )
283-
284248 print (f"Plotting training time comparison with { len (comparison_data )} data points" )
285-
286- # Create figure
287- plt .figure (figsize = (12 , 6 ))
288-
289- # Get unique datasets and algorithms in desired order
249+ plt .figure (figsize = (14 , 8 ))
290250 datasets = sorted (
291251 comparison_data ["Dataset" ].unique (),
292252 key = lambda x : ["IMDB-BINARY" , "IMDB-MULTI" , "MUTAG" , "BZR" , "COX2" ].index (x )
293253 if x in ["IMDB-BINARY" , "IMDB-MULTI" , "MUTAG" , "BZR" , "COX2" ]
294254 else 999 ,
295255 )
296-
297256 algorithms = sorted (
298257 comparison_data ["Algorithm" ].unique (),
299258 key = lambda x : ["FedAvg" , "GCFL" , "GCFL+" , "GCFL+dWs" ].index (x )
300259 if x in ["FedAvg" , "GCFL" , "GCFL+" , "GCFL+dWs" ]
301260 else 999 ,
302261 )
303-
304- # Set x positions
305262 x_positions = np .arange (len (datasets ))
306-
307- # Bar width
308263 width = 0.8 / len (algorithms )
309-
310- # Colors
311- algorithm_colors = ["#1f77b4" , "#ff7f0e" , "#2ca02c" , "#d62728" ]
312-
313- # Plot bars for each algorithm
264+ actual_colors = ["#1f77b4" , "#ff7f0e" , "#2ca02c" , "#d62728" , "#9467bd" ]
314265 for i , algo in enumerate (algorithms ):
315266 algo_data = comparison_data [comparison_data ["Algorithm" ] == algo ]
316-
317- # Prepare data in dataset order
318267 time_values = []
319-
320- # Ensure consistent ordering
321268 for dataset in datasets :
322269 dataset_row = algo_data [algo_data ["Dataset" ] == dataset ]
323- if not dataset_row .empty and not pd .isna (
324- dataset_row ["Train_Time_ms" ].values [0 ]
325- ):
326- time_values .append (dataset_row ["Train_Time_ms" ].values [0 ])
270+ if not dataset_row .empty and not pd .isna (dataset_row ["Train_Time_ms" ].values [0 ]):
271+ time_values .append (dataset_row ["Train_Time_ms" ].values [0 ] / 1000.0 )
327272 else :
328273 time_values .append (0 )
329-
330- # Plot bars
331274 plt .bar (
332275 x_positions + (i - len (algorithms ) / 2 + 0.5 ) * width ,
333276 time_values ,
334277 width = width ,
335278 label = algo ,
336- color = algorithm_colors [i % len (algorithm_colors )],
279+ color = actual_colors [i % len (actual_colors )],
337280 )
338-
339- # Set chart properties
340- plt .title ("Training Time Comparison" , fontsize = 30 )
281+ #plt.title("Training Time Comparison", fontsize=30)
341282 plt .xlabel ("Dataset" , fontsize = 30 )
342- plt .ylabel ("Training Time (ms )" , fontsize = 28 )
343- plt .xticks (x_positions , datasets , rotation = 45 , fontsize = 30 )
283+ plt .ylabel ("Training Time (s )" , fontsize = 28 )
284+ plt .xticks (x_positions , datasets , rotation = 30 , fontsize = 20 )
344285 plt .yticks (fontsize = 28 )
345286 plt .legend (
346- title = "Algorithms" ,
287+ # title="Algorithms",
347288 loc = "upper left" ,
348289 bbox_to_anchor = (1 , 1 ),
349- fontsize = 25 ,
350- title_fontsize = 25 ,
290+ fontsize = 22 ,
291+ # title_fontsize=25,
351292 )
352293 plt .grid (False )
353294 plt .tight_layout ()
354-
355- # Save and close
356295 plt .savefig (output_file , dpi = 300 )
357296 plt .close ()
358-
359297 print (f"Training time comparison plot saved to: { output_file } " )
360298 return output_file
361299
@@ -457,17 +395,17 @@ def generate_comm_cost_comparison(df, output_file="gc_comm_cost_comparison.pdf")
457395 current_pos += 1
458396
459397 # Plot settings
460- plt .title ("Communication Cost Comparison" , fontsize = 30 )
398+ # plt.title("Communication Cost Comparison", fontsize=30)
461399 plt .xlabel ("Dataset" , fontsize = 30 )
462400 plt .ylabel ("Communication Cost (MB)" , fontsize = 28 )
463- plt .xticks (x_positions , datasets , rotation = 45 , fontsize = 30 )
401+ plt .xticks (x_positions , datasets , rotation = 30 , fontsize = 20 )
464402 plt .yticks (fontsize = 28 )
465403 plt .legend (
466- title = "Legend" ,
404+ # title="Legend",
467405 loc = "upper left" ,
468406 bbox_to_anchor = (1 , 1 ),
469- fontsize = 22 ,
470- title_fontsize = 25 ,
407+ fontsize = 18 ,
408+ # title_fontsize=25,
471409 )
472410 plt .grid (False )
473411 plt .tight_layout ()
0 commit comments