Commit cf69c55e authored by Joaquin Torres's avatar Joaquin Torres

Generated first ROC curve to see behavior

parent 72e7890d
......@@ -175,8 +175,8 @@ if __name__ == "__main__":
# Metric generation through cv for tuned models3
# --------------------------------------------------------------------------------------------------------
scores_sheets = {} # To store score dfs as sheets in the same excel file
for i, group in enumerate(['pre', 'post']):
for j, method in enumerate(['', '', 'over_', 'under_']):
for i, group in enumerate(['pre']): # 'post'
for j, method in enumerate(['']): # '', 'over_', 'under_'
# print(f"{group}-{method_names[j]}")
# Get train dataset based on group and method
X_train = data_dic['X_train_' + method + group]
......@@ -191,6 +191,7 @@ if __name__ == "__main__":
axes = [axes]
# Metric generation for each model
for model_idx, (model_name, model) in enumerate(models.items()):
if model_name == 'DT':
print(f"{group}-{method_names[j]}-{model_name}")
# Retrieve cv scores for our metrics of interest
scores = cross_validate(model, X_train, y_train, scoring=scorings, cv=cv, return_train_score=True, n_jobs=10)
......@@ -220,19 +221,16 @@ if __name__ == "__main__":
mean_tpr[-1] = 1.0
mean_auc = auc(mean_fpr, mean_tpr) # Calculate the mean AUC
std_auc = np.std(aucs)
# Plot the mean ROC curve
axes[model_idx].plot(mean_fpr, mean_tpr, color='b',
label=r'Mean ROC (AUC = %0.2f $\pm$ %0.2f)' % (mean_auc, std_auc),
lw=2, alpha=.8)
# Plot the standard deviation of the TPRs
std_tpr = np.std(tprs, axis=0)
tprs_upper = np.minimum(mean_tpr + std_tpr, 1)
tprs_lower = np.maximum(mean_tpr - std_tpr, 0)
axes[model_idx].fill_between(mean_fpr, tprs_lower, tprs_upper, color='grey', alpha=.2,
label=r'$\pm$ 1 std. dev.')
# Set plot limits and title
axes[model_idx].set(xlim=[-0.05, 1.05], ylim=[-0.05, 1.05],
title=f"ROC Curve - {model_name} ({group}-{method_names[j]})")
......
This diff is collapsed.
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