Commit dbaeeff0 by Tianqi Yang

feat(handle_data): support threshold

parent 96ec9f28
......@@ -3,7 +3,7 @@
import numpy as np
import math
print ( ' '.join ( list ( map ( str, range ( 100, 501, 5 ) ) ) ) )
print ( ' '.join ( list ( map ( str, range ( 100, 501, 2 ) ) ) ) )
a = np.logspace(math.log(0.0001,10),math.log(0.01,10),40).tolist()[0:-1] + np.logspace(math.log(0.01,10),math.log(1,10),80).tolist()
print ( ' '.join ( list ( map ( str, a ) ) ) )
......
......@@ -32,11 +32,12 @@ def main ():
try:
cur = data[line_id].split ()
line_id += 1
if len(cur) != 2:
print ('Syntax error at line {}: lambda or p not found: {}'.format (line_id, cur))
if len(cur) != 3:
print ('Syntax error at line {}: lambda, p, threshold, not found: {}'.format (line_id, cur))
raise Exception ()
lbd = int (cur[0])
p = float (cur[1])
thres = int (cur[2])
cur_res = []
for i in range (args.repeat): # pylint: disable=unused-variable
cur = data[line_id]
......@@ -49,7 +50,7 @@ def main ():
raise Exception ()
mean = np.mean (cur_res)
var = np.var (cur_res)
result[(lbd, p)] =(mean, var)
result[(lbd, p, thres)] =(mean, var)
except Exception:
print ('Exception at line {}'.format (line_id))
else:
......@@ -57,38 +58,45 @@ def main ():
lbd_axis = []
p_axis = []
thres_axis = []
for i in result.keys ():
if i[0] not in lbd_axis:
lbd_axis.append (i[0])
if i[1] not in p_axis:
p_axis.append (i[1])
if i[2] not in thres_axis:
thres_axis.append (i[2])
lbd_axis.sort ()
p_axis.sort ()
thres_axis.sort ()
with open (args.output, 'w') as OUT:
for thres in thres_axis:
mean_format = ',{:.%d}' % (args.precision_mean)
if args.precision_var == -1:
var_format = ',{}'
else:
var_format = ',{:.%d}' % (args.precision_var)
print (','.join (['Mean'] + list (map (str, p_axis))), file=OUT)
print (','.join (['Mean (threshold={})'.format (thres)] + list (map (str, p_axis))), file=OUT)
for lbd in lbd_axis:
print ('{}'.format (lbd), end='', file=OUT)
for p in p_axis:
if (lbd, p) in result:
print (mean_format.format (result[(lbd, p)][0]), end='', file=OUT)
if (lbd, p, thres) in result:
print (mean_format.format (result[(lbd, p, thres)][0]), end='', file=OUT)
else:
print (',N/A', file=OUT)
print (',N/A', end='', file=OUT)
print (file=OUT)
print (file=OUT)
print (','.join (['Variance'] + list (map (str, p_axis))), file=OUT)
for thres in thres_axis:
print (','.join (['Variance (threshold={})'.format (thres)] + list (map (str, p_axis))), file=OUT)
for lbd in lbd_axis:
print ('{}'.format (lbd), end='', file=OUT)
for p in p_axis:
if (lbd, p) in result:
print (var_format.format (result[(lbd, p)][1]), end='', file=OUT)
if (lbd, p, thres) in result:
print (var_format.format (result[(lbd, p, thres)][1]), end='', file=OUT)
else:
print (',N/A', file=OUT)
print (',N/A', end='', file=OUT)
print (file=OUT)
print (file=OUT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment