forked from myay/TREAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult_summarizer_nt_memory.py
61 lines (43 loc) · 1.61 KB
/
result_summarizer_nt_memory.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
import os
import joblib
from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, precision_score, recall_score, precision_recall_curve, \
average_precision_score
def main():
src_path = "./results/raw/nt/split/"
des_path = "./results/clean/nt/memory.txt"
#src_path = "./results/complete_trees/c_split/"
#des_path = "./results/clean/ct/memory.txt"
#src_path = "./results/raw/crt/split/"
#des_path = "./results/clean/crt/memory_test.txt"
out = 0
nodes = 0
counter = 0
file_counter = 0
for filename in os.listdir(src_path):
if (filename.find("pkl") != -1):
# print(filename)
model = joblib.load(src_path + filename)
if (filename.find("_T") != -1):
nodes = 0
for tree in model.estimators_:
# print(tree.tree_.node_count)
nodes += tree.tree_.node_count
out += nodes
counter += 1
print(filename, " ", nodes)
else:
#print(model.tree_.node_count)
out += model.tree_.node_count
counter += 1
print(filename, " ", model.tree_.node_count)
out = round(out / counter, 4)
# print(out)
with open(des_path, 'w+') as w:
w.write("crt,{:.4f}".format(out))
# 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()