-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestopt.py
51 lines (42 loc) · 1.15 KB
/
testopt.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
import numpy as np
from morpher import config
from morpher.jobs import Evaluate, Impute, Load, Train
from morpher.metrics import get_discrimination_metrics
target = "AKI"
train = Impute().execute(
Load().execute(source=config.FILE, filename="train"),
imputation_method=config.DEFAULT,
)
test = Impute().execute(
Load().execute(source=config.FILE, filename="test"),
imputation_method=config.DEFAULT,
)
param_grid_lr = {
"penalty": ["none", "l2"],
"C": np.logspace(0, 4, 10),
"solver": ["lbfgs"],
"max_iter": [10000],
}
hyperparams_rf = {"n_estimators": 300, "max_depth": 2}
models = {}
models.update(
Train().execute(
train,
target=target,
optimize="yes",
param_grid=param_grid_lr,
algorithms=[config.LOGISTIC_REGRESSION],
)
)
models.update(
Train().execute(
train,
target=target,
hyperparams=hyperparams_rf,
algorithms=[config.RANDOM_FOREST],
)
)
results = Evaluate().execute(test, target=target, models=models)
for algorithm in results:
print("Metrics for {}".format(algorithm))
print(get_discrimination_metrics(**results[algorithm]))