-
Notifications
You must be signed in to change notification settings - Fork 3
/
plot_bench_detect.py
67 lines (49 loc) · 1.67 KB
/
plot_bench_detect.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
# coding=utf-8
# Subterm statistics. Given a dataset, sensitive attribute, class
# attribute, and classifier parameters, trains the classifier to
# predict class attribute. Then for each sub-expression in the
# resulting classifier, provides normalized mutual information and
# influence metrics.
import sys
reload(sys)
sys.setdefaultencoding('utf8')
sys.tracebacklimit=2
from detect import *
from util import *
from ml_util import *
from plot_util import *
import matplotlib.pyplot as plt
e = generated_from_args()
c = e.args
plots_x = []
plots_y = []
for d in e.data1:
plot_x = []
plot_y = []
for r_temp in d.iterrows():
r = r_temp[1]
plot_x.append(r['dataset_size'])
plot_y.append(r['runtime'])
plots_x.append(plot_x)
plots_y.append(plot_y)
plt.xlabel(r'dataset size [count]')
plt.ylabel(r'real runtime [s]')
plt.grid(True)
labels = ['tree','forest','logistic']
handles = []
markers = ['-bo', '-b+', '-bx']
for (plot_x,plot_y) in zip(plots_x, plots_y):
i = plots_y.index(plot_y)
line1, = plt.semilogy(plot_x,plot_y,'bo-',color=str(float(i)/len(plots_y)),label=labels[i],linewidth=2-0.5*i)
#plt.semilogy(plot_x,plot_y,'bo',color=str(float(i)/len(plots_y)))
handles.append(line1)
#plt.autoscale(enable=True,tight=False,axis='both')
#plt.legend(handles=handles,loc='upper left',handlelength=1, frameon=True)
plt.axes().set_xlim(0,max(lists_flatten(plots_x))*1.1)
plt.axes().set_ylim(0,max(lists_flatten(plots_y))*10)
plt.tight_layout()
if c.output is not None:
print "saving figure to " + c.output
plt.savefig(c.output)
if c.show:
plt.show()