-
Notifications
You must be signed in to change notification settings - Fork 1
/
eval_MIMIC2.py
33 lines (31 loc) · 1.16 KB
/
eval_MIMIC2.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
from lib.data import Mimic2
import numpy as np
from lib.model import LR
from lib.train import Trainer, prepareData
from torch.utils.data import Dataset, DataLoader, TensorDataset
from lib.regularization import eye_loss, wridge, wlasso, lasso, ridge, owl
from sklearn.metrics import accuracy_score
from lib.utility import get_y_yhat, model_auc
import torch
from torch.autograd import Variable
from sklearn.model_selection import train_test_split
from main import random_risk_exp, expert_feature_only_exp, reg_exp
import glob
# from sklearn.externals import joblib
import joblib
from pandas import DataFrame
import sys
if len(sys.argv) == 2:
model_dir = sys.argv[1]
else:
model_dir = 'models'
print('looking at {}/'.format(model_dir))
raw_data = []
for fn in glob.glob('{}/test*.pkl'.format(model_dir)):
name = fn.split('/')[-1].split('.pkl')[0]
name, alpha = name.split('^')
if 'test' in name: name = name[4:]+'*'
auc, ap, s1, sp = joblib.load(fn)
raw_data.append([name, alpha, auc, ap, s1, sp])
df = DataFrame(data=raw_data, columns=['method name', 'alpha', 'auc', 'ap', 'min(recall, precision)', 'sparsity'])
print(df.sort_values(['auc'], ascending=False))