Commit add8a9fa authored by Marco Chierici's avatar Marco Chierici
Browse files

Add PPV (precision)

parent a6cbfc92
......@@ -62,6 +62,9 @@ df_results = pd.DataFrame(
'spec_train',
'spec_train_min',
'spec_train_max',
'ppv_train',
'ppv_train_min',
'ppv_train_max',
'mcc_test',
'mcc_test_min',
'mcc_test_max',
......@@ -83,6 +86,7 @@ for k in range_combinations:
all_mccs = []
all_sens = []
all_spec = []
all_ppv = []
all_aucs = []
all_test_mccs = []
......@@ -164,6 +168,10 @@ for k in range_combinations:
best_spec = all_metrics.iloc[best_idxs, SPEC]
all_spec.extend(best_spec)
PPV = np.where(all_metrics.columns == 'ppv')[0][0]
best_ppv = all_metrics.iloc[best_idxs, PPV]
all_ppv.extend(best_ppv)
all_mccs = np.array(all_mccs)
MCC_CI = bs.bootstrap(all_mccs, stat_func=bs_stats.mean)
print(
......@@ -194,8 +202,10 @@ for k in range_combinations:
if TARGET != 'subtypes':
all_sens = np.array(all_sens)
all_spec = np.array(all_spec)
all_ppv = np.array(all_ppv)
SENS_CI = bs.bootstrap(all_sens, stat_func=bs_stats.mean)
SPEC_CI = bs.bootstrap(all_spec, stat_func=bs_stats.mean)
PPV_CI = bs.bootstrap(all_ppv, stat_func=bs_stats.mean)
print(
'SENS =',
round(np.mean(all_sens), 3),
......@@ -206,6 +216,11 @@ for k in range_combinations:
round(np.mean(all_spec), 3),
(round(SPEC_CI.lower_bound, 3), round(SPEC_CI.upper_bound, 3)),
)
print(
'PPV =',
round(np.mean(all_ppv), 3),
(round(PPV_CI.lower_bound, 3), round(PPV_CI.upper_bound, 3)),
)
row = OrderedDict(
{
......@@ -222,6 +237,9 @@ for k in range_combinations:
'spec_train': round(np.mean(all_spec), 3),
'spec_train_min': round(SPEC_CI.lower_bound, 3),
'spec_train_max': round(SPEC_CI.upper_bound, 3),
'ppv_train': round(np.mean(all_ppv), 3),
'ppv_train_min': round(PPV_CI.lower_bound, 3),
'ppv_train_max': round(PPV_CI.upper_bound, 3),
'mcc_test': round(np.mean(all_test_mccs), 3),
'mcc_test_min': round(MCC_TEST.lower_bound, 3),
'mcc_test_max': round(MCC_TEST.upper_bound, 3),
......@@ -246,6 +264,9 @@ for k in range_combinations:
'spec_train': np.nan,
'spec_train_min': np.nan,
'spec_train_max': np.nan,
'ppv_train': np.nan,
'ppv_train_min': np.nan,
'ppv_train_max': np.nan,
'mcc_test': round(np.mean(all_test_mccs), 3),
'mcc_test_min': round(MCC_TEST.lower_bound, 3),
'mcc_test_max': round(MCC_TEST.upper_bound, 3),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment