-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdrawFig.py
More file actions
63 lines (55 loc) · 2.35 KB
/
drawFig.py
File metadata and controls
63 lines (55 loc) · 2.35 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
60
61
62
63
import numpy as np
from matplotlib import pyplot as plt
from utils.dataset import *
cm = plt.cm.get_cmap('tab10')
COLOR = {
"Theory Best": cm(0),
"DIF": cm(1),
"Manual": cm(3),
"Random": cm(7),
"DeepGini": cm(2),
"CleanLab": cm(4),
'Uncertainty': cm(5),
'DeepState': cm(6),
'SimiFeat': cm(8),
'NCNV': cm(9),
}
datasetname = 'MTFL'
ModelTypeList = ['TCDCNN']
NoiseTypeList = ['RandomLabelNoise', 'RandomDataNoise']
MethodTypeList = ['Theory Best','Uncertainty', 'Random','Manual']
for modeltype in ModelTypeList:
for noisetype in NoiseTypeList:
plt.figure()
for method in MethodTypeList:
if method == 'Theory Best':
imagelist = load_json(
'./dataset/' + noisetype + '/' + datasetname + '/results/' + modeltype + '/Manual_results_list.json')
else:
imagelist = load_json(
'./dataset/' + noisetype + '/' + datasetname + '/results/' + modeltype + '/' + method + '_results_list.json')
name2isfault = load_json('./dataset/' + noisetype + '/' + datasetname + '/train/' + 'name2isfault.json')
X = []
Y = []
Count = 0
# convert name2isfault values to list
falutNum = sum(list(name2isfault.values()))
print('faultNum:', falutNum)
if method == 'Theory Best':
the_imagelist = [imagename for imagename in imagelist if name2isfault[imagename]]
the_imagelist.extend([imagename for imagename in imagelist if not name2isfault[imagename]])
imagelist = the_imagelist
for i, imagename in enumerate(imagelist):
X.append(i/len(imagelist))
if name2isfault[imagename]:
Count += 1
Y.append(Count/falutNum)
if method == 'Manual':
plt.plot(X, Y, color=COLOR[method], label='DfauLo', linewidth=2.0)
else:
plt.plot(X, Y, color=COLOR[method], label=method)
plt.xlabel(r'$Percentage\ of\ test\ case\ executed$')
plt.ylabel(r'$Percentage\ of\ fault\ detected$')
plt.legend(loc=4)
os.makedirs('./dataset/Figure/'+datasetname+'/'+modeltype,exist_ok=True)
plt.savefig('./dataset/Figure/'+datasetname+'/'+modeltype+'/'+noisetype+'.pdf', bbox_inches='tight')