-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresults_check_predictions.py
26 lines (17 loc) · 1.09 KB
/
results_check_predictions.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
"""Script to check the predicitons along different models"""
from pathlib import Path
import pandas as pd
import numpy as np
PROJECT_ROOT = Path.cwd()
# --------------------------------------------------------------------------
output_dir = PROJECT_ROOT / 'output' / 'experiments'
demographic_df = pd.read_csv(PROJECT_ROOT / 'data' / 'PAC2019_BrainAge_Training.csv')
predictions = pd.DataFrame(demographic_df[['subject_ID', 'age', 'site']])
predictions.set_index('subject_ID', inplace=True)
for prediction_file in output_dir.glob('*/cv/predictions_cv.csv'):
experiment_name = prediction_file.parents[1].stem
experiment_predictions = pd.read_csv(prediction_file, index_col='subject_ID')
experiment_predictions[experiment_name] = np.abs(experiment_predictions['age'] - experiment_predictions['predictions'])
predictions = pd.merge(predictions, experiment_predictions[experiment_name], left_index=True, right_index=True)
predictions['median_mae'] = predictions[predictions.columns.difference(['age', 'site'])].median(axis=1)
predictions = predictions.sort_values('median_mae', ascending=False)