-
Notifications
You must be signed in to change notification settings - Fork 1
/
likelihood_correlation.py
32 lines (28 loc) · 1.06 KB
/
likelihood_correlation.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
import pickle
import pandas as pd
from functools import reduce
datasets = [
'support',
'metabric',
'gbsg',
'flchain',
'kkbox'
]
if __name__ == '__main__':
d = 'sumo_net_30_results'
seed = 1337
df = []
corr_mats = []
for ds in datasets:
for fold_idx in [0,1,2,3,4]:
path = f'{d}/{ds}_seed={seed}_fold_idx={fold_idx}_objective=S_mean_survival_net_basic/hyperopt_database.p'
trials = pickle.load(open(path, "rb"))
for res in trials.results:
df.append([-res['test_loglikelihood_2'],res['test_conc'],-res['test_ibs'],-res['test_inll']])
df_res = pd.DataFrame(df, columns=['likelihood', 'concordance', 'ibs', 'ibl'])
cor_mat = df_res.corr(method='spearman')
corr_mats.append(cor_mat)
len_avg = len(corr_mats)
d = reduce(lambda x, y: x.add(y, fill_value=0), corr_mats)/len_avg
d.to_latex(f'correlation.tex')
# best_trial = sorted(trials.results, key=lambda x: x[selection_criteria], reverse=reverse)[0]