forked from myay/TREAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult_summarizer_rsdts.py
79 lines (54 loc) · 2.39 KB
/
result_summarizer_rsdts.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
68
69
70
71
72
73
74
75
76
77
78
79
import os
def main():
src_path = "./results/raw/rsdt/split_full/"
des_path = "./results/clean/rsdt/"
#src_path = "./results/raw/rsdt/fval_full/"
#des_path = "./results/clean/rsdt/fval_full/"
#src_path = "./results/raw/rsdt/fidx_full/"
#des_path = "./results/clean/rsdt/fidx_full/"
#src_path = "./results/raw/rsdt/chidx_full/"
#des_path = "./results/clean/rsdt/chidx_full/"
out = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
counter = 0
for filename in os.listdir(src_path):
if(filename.find("pkl") == -1 and filename.find("output") == -1 and filename.find("results") == -1):
counter = counter + 1
#print(filename)
with open(src_path + filename, 'r') as f:
#with open(des_path + filename, 'w+') as w:
for idx, line in enumerate(f.readlines()):
#print(line)
if(idx != 0):
for idxy, num in enumerate(line.split(",")):
out[idx-1][idxy] = out[idx-1][idxy] + float(num)
#out[idx-1] += float(line.split(",")[1][:-2])
#else:
#out = line.split()
#out = line.split(" ")[1] + line.split(" ")[3]
#w.write(out + "\n")
for idx, line in enumerate(out):
for idxy, sum in enumerate(line):
out[idx][idxy] = round(sum / counter, 4)
with open(des_path + "sum.txt", 'w+') as w:
w.write("BERs, rsdt0, rsdt5, rsdt10,rsdt15,rsdt20,rsdt25,rsdt30,rsdt35,rsdt40,rsdt45,rsdt50\n")
for line in out:
for idx, num in enumerate(line):
w.write("{:.4f}".format(num))
if(idx < len(line) - 1):
w.write(",")
w.write("\n")
#print(out)
#print("BER: {:.4f}, Accuracy: {:.4f} ({:.4f},{:.4f})".format(ber, acc_mean, acc_mean - acc_min, acc_max - acc_mean))
if __name__ == '__main__':
main()