-
Notifications
You must be signed in to change notification settings - Fork 0
/
result_finder.py
118 lines (111 loc) · 4.33 KB
/
result_finder.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# -*- coding: utf-8 -*-
import glob
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
import time
import datetime
import pandas as pd
name_list= ['Densenet without Gender','Resnet without Gender','Densenet without Age','Resnet without Age','Densenet without age and gender','Resnet without age and gender']
#name_list=['DenseNet w/o FE','DenseNet w FE','ResNet w/o FE','ResNet w FE','AlexNet with w/o FE','AlexNet w FE','VGG w/o FE','VGG w FE','Inception w/o FE','Inception w FE']
time_ = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')
auc_list=[]
epoch_list=[]
mean_auc_list=[]
std_list=[]
value_dict={}
count=0
start_run=int(input('Input First Run Number: '))
end_run=int(input('Input End Run Number: '))+1
sequence= int(input('Input Sequence Number: '))
analysis_name=str(input('Input Analysis Name: '))
x=0
for i in range (0,51,10):
if i==10:
start_run=285
end_run=295
sequence=1
for j in range (start_run+i,end_run+i,sequence):
for name in glob.glob('/auto/data2/yturali/Runs/Run_'+str(j)+'/*/data/*_11_*.npy'):
#for name in glob.glob('/auto/data2/yturali/Runs/Run_'+str(j)+'/*/data/*.npy'):
print(name)
array = name.split("_")
auc = ((array[8]).split("."))[1]
auc_list.append(float("0."+str(auc)))
auc_arr = np.array(auc_list)
print(auc_list)
print()
mean_auc = np.mean(auc_arr)
auc_std = np.std(auc_arr)
dict_list= ["Mean AUC:"+str(mean_auc),"Standard Deviation:"+str(auc_std)]
mean_auc_list.append(mean_auc)
std_list.append(auc_std)
auc_list=[]
value_dict[name_list[x]]=dict_list
print(x)
x+=1
#for j in range (start_run,end_run,sequence):
# #for name in glob.glob('/auto/data2/yturali/Runs/Run_'+str(j)+'/*/data/*_11_*.npy'):
# for name in glob.glob('/auto/data2/yturali/Runs/Run_'+str(j)+'/*/data/*.npy'):
# print(name)
# array = name.split("_")
# auc = ((array[8]).split("."))[1]
# auc_list.append(float("0."+str(auc)))
# auc_arr = np.array(auc_list)
# print(auc_list)
# print()
# mean_auc = np.mean(auc_arr)
# auc_std = np.std(auc_arr)
# dict_list= ["Mean AUC:"+str(mean_auc),"Standard Deviation:"+str(auc_std)]
# mean_auc_list.append(mean_auc)
# std_list.append(auc_std)
# auc_list=[]
#value_dict[name_list[i]]=dict_list
mean_auc_arr=np.array([mean_auc_list])
std_arr= np.array([std_list])
print('**********************')
print(mean_auc_arr)
print('**********************')
print(std_arr)
optimal_choice = np.argmax(mean_auc_arr)
#for i in range (0,sequence):
# print(str(name_list[i]) + ":\n")
# for value in value_dict[name_list[i]]:
# print(value)
# print("\n")
#print()
#print("Optimal Pretrained Model and its Mean AUC, STD are {} with values respectively:\n {}".format(name_list[optimal_choice],value_dict[name_list[optimal_choice]]))
fig, ax =plt.subplots(1,1)
mean_auc_T= np.transpose(mean_auc_arr)
auc_std_T=np.transpose(std_arr)
#table_data=np.round_(np.concatenate((mean_auc_T,auc_std_T),axis=1),decimals=2)
raw_data=np.concatenate((mean_auc_T,auc_std_T),axis=1)
print(raw_data)
#raw_data[4],raw_data[10]=raw_data[10],raw_data[4]
table_data=np.round_(raw_data*100,decimals=2)
table_data_list=[]
print(table_data.shape)
for i in range (6):
table_data_list.append('{:.2f}'.format(table_data[i,0])+'% +-'+'{:.2f}'.format(table_data[i,1])+'%')
data = np.transpose(np.array([table_data_list]))
data = np.concatenate((np.transpose(np.array([name_list])),data),axis=1)
print(data.shape)
print(data)
dff = pd.DataFrame(data)
#column_labels = ['Mean AUC and STD']
column_labels = ['Model Name','Mean AUC and STD']
rows = name_list
ax.axis('tight')
ax.axis('off')
plt.title(analysis_name)
ccolors = plt.cm.BuPu(np.full(len(column_labels), 0.1))
fontsize = 10
tab1 = ax.table(cellText=data,colLabels=column_labels,loc="center",cellLoc='center',colColours=ccolors)
fontsize = 10
tab1.set_fontsize(fontsize)
tab1.scale(1.5, 1.5)
#tab1 = ax.table(cellText=data,colLabels=column_labels,loc="center")
tab1.auto_set_column_width(col=list(range(len(dff.columns))))
# Save the figure and show
plt.savefig('/auto/data2/yturali/Runs/Results/Date:{}_Run_{}_to_{}_Mean_AUC_with_STD_Table.png'.format(time_,start_run,end_run), bbox_inches='tight', dpi =160)
plt.show()