-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_accuracy_performance.py
86 lines (79 loc) · 3.48 KB
/
plot_accuracy_performance.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Plotting performance CNNs comparison
# Angel Canelo 2024.08.02
######### IMPORT ##########
import glob
import pandas as pd
from pymatreader import read_mat
import matplotlib.pyplot as plt
import seaborn as sns
###########################
rew_dic = {"Test_accuracy": [], "Epoch": [], "Trial": [], "Net": []}
rew_dic2 = {"Test_accuracy": [], "Epoch": [], "Trial": [], "Net": []}
standard_dataset = 0 # 0 -> Moving Patterns dataset; 1 -> COIL100
if standard_dataset == 0:
file_directory = "..\performance_mat\\*_Moving_Pattern_perf_loop*.mat"
elif standard_dataset == 1:
file_directory = "..\performance_mat\\*_COIL100_perf_loop*"
file_list = glob.glob(file_directory)
ii = 0; iii=0
for j, file_path in enumerate(file_list):
to_file = read_mat(file_path)
if '244X324' in file_path:
for i in range(len(to_file["hist_testacc"])):
rew_dic["Test_accuracy"].append(to_file["hist_acc"][i])
rew_dic["Epoch"].append(i)
rew_dic["Trial"].append(ii)
if 'FlyVisNet' in file_path:
rew_dic["Net"].append("FlyVisNet")
elif 'Dronet' in file_path:
rew_dic["Net"].append("Dronet")
elif 'MobileNetV2' in file_path:
rew_dic["Net"].append("MobileNetV2")
elif 'Random_init' in file_path:
rew_dic["Net"].append("Random_init")
ii += 1
elif '20X40' in file_path:
for i in range(len(to_file["hist_testacc"])):
rew_dic2["Test_accuracy"].append(to_file["hist_acc"][i])
rew_dic2["Epoch"].append(i)
rew_dic2["Trial"].append(iii)
if 'FlyVisNet' in file_path:
rew_dic2["Net"].append("FlyVisNet")
elif 'Dronet' in file_path:
rew_dic2["Net"].append("Dronet")
elif 'MobileNetV2' in file_path:
rew_dic2["Net"].append("MobileNetV2")
elif 'Random_init' in file_path:
rew_dic2["Net"].append("Random_init")
iii += 1
df_r = pd.DataFrame(data=rew_dic, columns=["Epoch", "Test_accuracy", "Trial", "Net"])
df_r2 = pd.DataFrame(data=rew_dic2, columns=["Epoch", "Test_accuracy", "Trial", "Net"])
max_values = df_r.groupby(['Trial', 'Net']).max()
print('Accuracies for 244x324')
print(max_values)
print(max_values.groupby(['Net']).mean())
print(max_values.groupby(['Net']).std())
print(max_values.groupby(['Net']).max())
max_values = df_r2.groupby(['Trial', 'Net']).max()
print('Accuracies for 20x40')
print(max_values)
print(max_values.groupby(['Net']).mean())
print(max_values.groupby(['Net']).std())
print(max_values.groupby(['Net']).max())
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 10))
sns.lineplot(x="Epoch", y="Test_accuracy", data=df_r, hue="Net", hue_order=["FlyVisNet", "Dronet", "MobileNetV2", "Random_init"],
errorbar=('ci', 95), palette=['blue', 'red', 'green', 'magenta'], ax=ax1)
ax1.grid(True)
ax1.set_title('Performance on pattern dataset (ci 95) \n (3000/300 frames train/test)')
ax1.set_ylabel('Accuracy (%)')
ax1.set_xlabel('Epoch (#)')
ax1.set_xlim([0, 100])
ax1.legend(loc='lower right')
sns.lineplot(x="Epoch", y="Test_accuracy", data=df_r2, hue="Net", hue_order=["FlyVisNet", "MobileNetV2", "Random_init"],
errorbar=('ci', 95), palette=['blue', 'green', 'magenta'], ax=ax2)
ax2.grid(True)
ax2.set_ylabel('Accuracy (%)')
ax2.set_xlabel('Epoch (#)')
ax2.legend(loc='lower right')
ax2.set_xlim([0, 100])
plt.show()