-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathclassifier_vs_normative_generalization.py
More file actions
executable file
·53 lines (40 loc) · 2.47 KB
/
classifier_vs_normative_generalization.py
File metadata and controls
executable file
·53 lines (40 loc) · 2.47 KB
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
52
53
#!/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(training_dataset_name, testing_dataset_name, disease_label):
hc_label = 1
bootstrap_dir = PROJECT_ROOT / 'outputs' / 'bootstrap_analysis'
comparison_dir = bootstrap_dir / testing_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' / training_dataset_name
generalization_dir = classifier_dir / '{:02d}_vs_{:02d}'.format(hc_label, disease_label) / 'generalization'
classifier_results = pd.read_csv(generalization_dir / '{:}_aucs.csv'.format(testing_dataset_name))
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(generalization_dir / 'normative_vs_classifier_{}_{}.csv'.format(testing_dataset_name, disease_label), index=False)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-D', '--training_dataset_name',
dest='training_dataset_name',
help='Dataset name to perform comparison between normative and classifiers.')
parser.add_argument('-E', '--testing_dataset_name',
dest='testing_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.training_dataset_name, args.testing_dataset_name, args.disease_label)