-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
59 lines (50 loc) · 2.88 KB
/
Copy pathplot.py
File metadata and controls
59 lines (50 loc) · 2.88 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
52
53
54
55
56
57
58
59
# Fixing the syntax error and rerunning the corrected plot code
import matplotlib.pyplot as plt
import numpy as np
# Dataset and model names
datasets = ["MUTAG", "PTC-MR", "PROTEINS", "NCI1", "Mutagenicity"]
base_models = ["GCN", "GIN", "GAT", "GATv2", "ResGatedGCN", "GraphSAGE", "GraphTrans", "GraphGPS"]
variants = ["Convex (2L)", "Non-Convex (2L)", "Non-Convex (6L)"]
# Accuracy means and stds (corrected syntax)
accuracy_means = {
"GCN": [[71.2, 59.7, 70.9, 62.3, 61.9], [55.0, 48.5, 59.5, 50.8, 54.7], [61.2, 55.0, 58.7, 50.8, 54.7]],
"GIN": [[83.2, 63.2, 70.1, 63.6, 59.1], [60.0, 45.0, 50.4, 55.5, 54.8], [61.2, 48.5, 61.6, 60.8, 55.8]],
"GAT": [[72.5, 59.7, 71.8, 64.6, 58.8], [65.0, 51.4, 60.0, 51.9, 54.8], [68.7, 54.2, 63.1, 52.3, 54.8]],
"GATv2": [[68.7, 59.0, 71.3, 63.6, 62.3], [55.0, 49.2, 61.6, 49.5, 55.9], [57.5, 49.2, 63.3, 49.5, 59.6]],
"ResGatedGCN":[[68.7, 60.4, 72.5, 62.4, 59.6], [57.0, 50.7, 47.9, 56.8, 56.1], [65.0, 50.7, 55.8, 61.1, 56.1]],
"GraphSAGE": [[68.7, 65.3, 73.8, 63.7, 66.3], [57.4, 52.8, 62.5, 53.1, 58.1], [51.2, 55.7, 63.1, 53.2, 60.0]],
"GraphTrans":[[68.7, 63.3, 70.7, 63.1, 63.2], [57.4, 40.4, 60.7, 55.0, 53.6], [67.5, 49.2, 61.6, 61.5, 59.9]],
"GraphGPS": [[83.7, 65.5, 81.6, 60.1, 59.4], [50.9, 49.2, 38.0, 50.8, 41.4], [52.5, 46.4, 38.8, 49.4, 55.1]]
}
accuracy_stds = {
"GCN": [[2.1, 4.2, 2.4, 1.1, 2.7], [22.0, 10.4, 4.1, 1.7, 1.1], [21.6, 15.8, 6.1, 1.7, 1.9]],
"GIN": [[7.3, 4.7, 2.6, 2.3, 1.8], [17.6, 9.5, 12.0, 1.4, 2.0], [1.6, 13.4, 1.2, 2.8, 2.0]],
"GAT": [[4.7, 6.0, 2.5, 0.0, 3.6], [9.3, 15.7, 3.3, 2.2, 2.0], [4.1, 17.2, 1.8, 2.9, 2.0]],
"GATv2": [[4.1, 5.2, 0.6, 1.1, 4.2], [19.0, 15.3, 1.6, 2.0, 1.4], [16.0, 15.3, 2.1, 2.0, 6.2]],
"ResGatedGCN":[[4.1, 5.8, 1.0, 3.2, 3.7], [16.7, 17.7, 9.9, 6.6, 2.1], [15.8, 7.1, 8.7, 3.1, 2.1]],
"GraphSAGE": [[4.1, 11.5, 3.7, 1.0, 5.3], [16.0, 7.4, 0.8, 6.0, 3.6], [1.9, 12.5, 1.8, 6.1, 3.3]],
"GraphTrans":[[4.1, 10.8, 3.1, 2.8, 4.7], [16.0, 8.0, 2.6, 3.7, 1.3], [7.4, 12.3, 1.2, 2.5, 4.6]],
"GraphGPS": [[2.1, 9.3, 7.2, 6.1, 4.1], [19.6, 20.1, 1.9, 2.6, 8.7], [2.1, 2.3, 1.5, 1.9, 5.5]]
}
# Plot configuration
x = np.arange(len(datasets))
width = 0.25
fig, axes = plt.subplots(4, 2, figsize=(20, 22))
axes = axes.flatten()
for i, model in enumerate(base_models):
means = accuracy_means[model]
stds = accuracy_stds[model]
ax = axes[i]
for j in range(3):
offset = (j - 1) * width
ax.bar(x + offset, means[j], width, label=variants[j], yerr=stds[j], capsize=4)
ax.set_title(model, fontsize=22)
ax.set_xticks(x)
ax.set_xticklabels(datasets, rotation=45, fontsize=20)
ax.set_ylim(0, 100)
if i % 2 == 0:
ax.set_ylabel("Accuracy (%)", fontsize=20)
ax.legend(fontsize=16)
fig.tight_layout()
plt.savefig("convex_vs_nonconvex_accuracy_with_std.png", dpi=300)
plt.show()