-
Notifications
You must be signed in to change notification settings - Fork 2
/
baseline_clinical.py
36 lines (28 loc) · 1.24 KB
/
baseline_clinical.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
import sys
from util import *
from algorithms import classifiers
from terminaltables import AsciiTable
data = load_data()
# Defining target, categorical and continuous columns
target = 'Premature'
categorical = ['Hypertension', 'Diabetes', 'Placental_position',
'Bleeding_first_trimester', 'Bleeding_second_trimester',
'Funneling', 'Smoker']
continuous = ['Rectime', 'Age', 'Parity', 'Abortions', 'Weight']
table_data = [['Algorithm', 'Sensitivity', 'Specificity', 'AUC']]
for name, algorithm in classifiers:
print('Fitting {}...'.format(name))
sys.stdout.flush()
results = fit_model(algorithm, data, continuous, categorical, target, oversample_correct=False, oversample_wrong=False)
table_data.append(
[
name,
'{}+-{}'.format(np.around(results['Sensitivity'][0], 4),
np.around(results['Sensitivity'][1], 2)),
'{}+-{}'.format(np.around(results['Specificity'][0], 4),
np.around(results['Specificity'][1], 2)),
'{}+-{}'.format(np.around(results['AUC'][0], 4),
np.around(results['AUC'][1], 2)),
])
table = AsciiTable(table_data, 'Baseline metrics')
print(table.table)