-
Notifications
You must be signed in to change notification settings - Fork 6
/
classifier_vs_normative.py
executable file
·51 lines (38 loc) · 2.16 KB
/
classifier_vs_normative.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
#!/usr/bin/env python3
""" Script to compare the performance between classifiers and normative."""
import argparse
from pathlib import Path
import pandas as pd
import numpy as np
PROJECT_ROOT = Path.cwd()
def main(dataset_name, disease_label):
hc_label = 1
bootstrap_dir = PROJECT_ROOT / 'outputs' / 'bootstrap_analysis'
comparison_dir = bootstrap_dir / dataset_name / ('{:02d}_vs_{:02d}'.format(hc_label, disease_label))
normative_auc_roc_df = pd.read_csv(comparison_dir / 'auc_rocs.csv')
normative_auc_roc_df = normative_auc_roc_df.rename(columns={'AUC-ROC': 'AUCS'})
classifier_dir = PROJECT_ROOT / 'outputs' / 'classifier_analysis'
classifier_dataset_dir = classifier_dir / dataset_name
classifier_dataset_analysis_dir = classifier_dataset_dir / '{:02d}_vs_{:02d}'.format(hc_label, disease_label)
classifier_results = pd.read_csv(classifier_dataset_analysis_dir / 'all_AUCs.csv')
print(np.percentile(normative_auc_roc_df - classifier_results, 2.5))
print(np.percentile(normative_auc_roc_df - classifier_results, 97.5))
results = pd.DataFrame(columns={'Measure', 'Value'})
results = results.append({'Measure': 'Lower',
'Value': np.percentile(normative_auc_roc_df - classifier_results, 2.5)},
ignore_index=True)
results = results.append({'Measure': 'Upper',
'Value': np.percentile(normative_auc_roc_df - classifier_results, 97.5)},
ignore_index=True)
results.to_csv(classifier_dataset_analysis_dir / 'normative_vs_classifier.csv', index=False)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-D', '--dataset_name',
dest='dataset_name',
help='Dataset name to perform comparison between normative and classifiers.')
parser.add_argument('-L', '--disease_label',
dest='disease_label',
help='Disease label to perform comparison between normative and classifiers.',
type=int)
args = parser.parse_args()
main(args.dataset_name, args.disease_label)