-
Notifications
You must be signed in to change notification settings - Fork 1
/
plotres.py
49 lines (44 loc) · 1.3 KB
/
plotres.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
import matplotlib.pylab as plt
import numpy as np
import math
from commonLib import *
from getPath import *
pardir = getparentdir()
resdir = pardir+'/res'
def read_data(path):
acc = []
auc = []
loss = []
with open(path,'r',encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
arr = line.split()
if len(arr)<3:
continue
for a in arr:
barr = a.split(':')
if len(barr)<2:
continue
temp = float(barr[1])
if math.isnan(temp):
continue
if barr[0]=='acc':
acc.append(temp)
elif barr[0]=='auc':
auc.append(temp)
elif barr[0]=='loss':
loss.append(temp)
return acc,auc,loss
def plot_data():
files = listfiles(resdir)
for file in files:
name = os.path.basename(file)
acc,auc,loss = read_data(file)
# plt.title(name)
plt.plot(acc,label='acc')
plt.plot(auc,label=name+' auc')
plt.plot(loss,label=name+' loss')
plt.legend()
plt.show()
if __name__=="__main__":
plot_data()