-
Notifications
You must be signed in to change notification settings - Fork 1
/
extract_training_performances.py
66 lines (56 loc) · 3.18 KB
/
extract_training_performances.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 pandas as pd
def read_train_file(path, skipon_var, skipon_val, model):
setting = ''
dataset = ''
epoch = ''
results = []
with open(path, 'r') as file:
for line in file:
str_line = line.strip()
if eval(skipon_var) == skipon_val:
break
if any(s in str_line for s in ['original', 'rewired', 'partition', 'gold']):
setting = [s for s in ['original', 'rewired', 'partition', 'gold'] if s in str_line][0]
if any(ds in str_line for ds in
['guo_', 'huang_', 'du_', 'pan_', 'richoux_regular_', 'richoux_strict_', 'richoux_', 'dscript_', 'gold_']):
dataset = [ds for ds in ['guo', 'huang', 'du', 'pan', 'richoux_regular', 'richoux_strict', 'richoux', 'dscript', 'gold'] if
ds in str_line][0]
if dataset == 'dscript':
dataset = 'D-SCRIPT UNBAL.'
if 'both_' in str_line or '0_' in str_line:
if 'both_' in str_line:
dataset += ' INTER->'
else:
dataset += ' INTRA0->'
if '0_es' in str_line:
dataset += 'INTRA0'
else:
dataset += 'INTRA1'
if 'FC_' in str_line:
model = 'Richoux_FC'
elif 'LSTM_' in str_line:
model = 'Richoux_LSTM'
if str_line.startswith('Epoch'):
epoch = str_line.split(' ')[1].split(':')[0]
if line.strip().__contains__('val_loss'):
spl_line = str_line.split(' ')
train_loss = spl_line[7]
train_acc = spl_line[10]
val_loss = spl_line[13]
val_acc = spl_line[16]
results.append(
{'Setting': setting, 'Dataset': dataset, 'Model': model, 'Epoch': epoch, 'Loss': train_loss,
'Accuracy': train_acc, 'Split': 'Training'})
results.append(
{'Setting': setting, 'Dataset': dataset, 'Model': model, 'Epoch': epoch, 'Loss': val_loss,
'Accuracy': val_acc, 'Split': 'Validation'})
df = pd.DataFrame(results)
return df
df_richoux_orig = read_train_file('algorithms/DeepPPI/keras/es_deepPPI.out', skipon_var='str_line', skipon_val='rewired', model='')
df_richoux_rest = read_train_file('algorithms/DeepPPI/keras/es_gold_deepPPI.out', skipon_var='epoch', skipon_val='-1', model='')
df_deepFE = read_train_file('algorithms/DeepFE-PPI/deepFE_es.out', skipon_var='epoch', skipon_val='-1', model='DeepFE')
df_deepFE_gold = read_train_file('algorithms/DeepFE-PPI/deepFE_es_gold.out', skipon_var='epoch', skipon_val='-1', model='DeepFE')
df_pipr = read_train_file('algorithms/seq_ppi/binary/model/lasagna/es_PIPR.out', skipon_var='epoch', skipon_val='-1', model='PIPR')
df_pipr_rest = read_train_file('algorithms/seq_ppi/binary/model/lasagna/es_gold_PIPR.out', skipon_var='epoch', skipon_val='-1', model='PIPR')
df = pd.concat([df_richoux_orig, df_richoux_rest, df_deepFE, df_deepFE_gold, df_pipr, df_pipr_rest])
df.to_csv('early_stopping_df.csv', index=False)