-
Notifications
You must be signed in to change notification settings - Fork 0
/
load.py
51 lines (38 loc) · 983 Bytes
/
load.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
import os
import numpy as np
def load_file(fn):
f=np.load(fn)
#p, auc
p=f['p']
pl=f['p0']
auc=f['auc']
if type(p.tolist()) is str:
raise Exception('no value here')
if np.any(np.isnan(p)) or np.any(np.isnan(pl)):
raise Exception('nan')
return p,pl,auc
def cut_task(fn):
fn=fn[fn.rfind('/')+1:]
fn=fn[:fn.rfind('.')]
return fn
def load_folder(fold):
fns=os.listdir("results/"+fold)
fns=[[cut_task(fn),os.path.join("results/"+fold,fn)] for fn in fns]
q=[]
for x,y in fns:
try:
a,b,c=load_file(y)
except Exception as e:
continue
q.append([x,a,b,c])
#q=[[x,*load_file(y)] for x,y in fns]
return q
def list_folders(equate=0):
lis=os.listdir("results")
lis.sort()
seed=np.random.randint(0,100000)
np.random.seed(equate)
np.random.shuffle(lis)
np.random.seed(seed)
return lis
#return os.listdir('results')