-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_model_accuracies_inversion.py
38 lines (33 loc) · 1.43 KB
/
print_model_accuracies_inversion.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
#models = [0,1,2] # For RF and w2v
#models = [1,2,3] # For NN
models = [0,1,2,3] # for w2v
model_accuracies = []
finished_models = []
for mo_no in models:
for ii in range(3):
for j in range(3):
m_string = str(mo_no)+","+str(ii)+","+str(j)
f = open(m_string+"_p_values.txt","r")
p_values = f.readlines()
f.close()
f = open(m_string+"_labels.txt","r")
labels = f.readlines()
f.close()
correct = 0
incorrect = 0
for i in range(len(p_values)):
#p = str(round(float(p_values[i].strip())))
if p_values[i].split(",")[0].strip() == "0.5":
continue
p = str(round(float(p_values[i].split(",")[0].strip())))
l = str(float(labels[i].strip()))
if p == l:
correct += 1
else:
incorrect += 1
finished_models.append(m_string)
model_accuracies.append(float(correct)/(float(correct)+float(incorrect)))
print "Model "+m_string+" ~ correct: "+str(correct)+" | incorrect: "+str(incorrect)
print "Model "+m_string+" Accuracy: "+str(float(correct)/(float(correct)+float(incorrect)))
best_index = model_accuracies.index(max(model_accuracies))
print "Best Model: "+str(finished_models[best_index])+" | Accuracy: "+str(model_accuracies[best_index])