Repository navigation
Expand file tree
/
Copy pathresults.py
More file actions
51 lines (43 loc) · 1.83 KB
/
Copy pathresults.py
File metadata and controls
51 lines (43 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
file_path = 'PerformanceSpeeds.csv'
df = pd.read_csv(file_path)
df = df[df["Speed(milliseconds)"].notna()]
datasets = df["Dataset"].unique()
algorithms = df["Algorithm"].unique()
implementations = df["Implementation"].unique()
def dynamic_y_axis_ticks(data):
max_value = max(data)
if max_value > 60000:
step = 60000
ticks = list(range(0, int(max_value) + step, step))
labels = [f"{int(tick/60000)}min" if tick >= 60000 else f"{tick}ms" for tick in ticks]
else:
step = 10000
ticks = list(range(0, int(max_value) + step, step))
labels = [f"{tick}ms" for tick in ticks]
return ticks, labels
for dataset in datasets:
plt.figure(figsize=(10, 6))
plt.title(f"Algorithm Speeds for {dataset}", fontsize=16)
dataset_df = df[df["Dataset"] == dataset]
speeds_all = []
for i, impl in enumerate(implementations):
impl_data = dataset_df[dataset_df["Implementation"] == impl]
speeds = [impl_data[impl_data["Algorithm"] == algo]["Speed(milliseconds)"].values[0]
if algo in impl_data["Algorithm"].values else 0
for algo in algorithms]
speeds_all.extend(speeds)
plt.bar(np.arange(len(algorithms)) + i * 0.2, speeds, 0.2, label=impl)
custom_ticks, custom_labels = dynamic_y_axis_ticks(speeds_all)
plt.xlabel("Algorithm", fontsize=12)
plt.ylabel("Time", fontsize=12)
plt.xticks(np.arange(len(algorithms)) + (0.2 * (len(implementations) - 1) / 2),
algorithms, rotation=45, fontsize=10)
plt.yticks(custom_ticks, custom_labels)
plt.ylim(0, custom_ticks[-1])
plt.legend(title="Implementation", fontsize=10)
plt.tight_layout()
plt.savefig(f"results/{dataset}_speeds.png") # Save the chart as a PNG file
plt.close()