-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateReport.py
53 lines (46 loc) · 1.36 KB
/
generateReport.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
#%%
import pickle
import numpy as np
import os
from sklearn.metrics import accuracy_score
import matplotlib.pyplot as plt
# %%
rootdir = 'results'
labels =[]
file_list = os.listdir(path=rootdir)
if '.DS_Store' in file_list:
file_list.remove('.DS_Store')
for filename in file_list:
dir = os.path.join(rootdir, filename)
with open(dir,"rb") as fp:
label = pickle.load(fp)
labels.append(label)
labelroot = 'labelSet/StandardLabel_source.pickle'
with open(labelroot,"rb") as fp:
test_label = pickle.load(fp)
test_label = test_label['test_label']
# %%
accAll = np.zeros((len(file_list),len(label)))
for methodINX,supervisionMethod in enumerate(file_list):
# 选择了不同方法的标签
label = labels[methodINX]
for subINX in range(len(label)):
predict_label = label[subINX]
true_label = test_label[subINX]
accAll[methodINX,subINX] = accuracy_score(true_label,predict_label)
# %%
x = np.linspace(1,accAll.shape[1],accAll.shape[1])
plt.bar(x,accAll[0,:],label=file_list[0],alpha=1)
plt.bar(x,accAll[1,:],label=file_list[1],alpha=0.5)
plt.bar(x,accAll[2,:],label=file_list[2],alpha=0.5)
plt.ylim(0, 1.4)
plt.legend()
plt.show()
# %%
plt.plot(x,accAll[0,:],label=file_list[0])
plt.plot(x,accAll[1,:],label=file_list[1])
plt.plot(x,accAll[2,:],label=file_list[2])
plt.ylim(0, 1.2)
plt.legend()
plt.show()
# %%