Commit c703ac3d authored by Joaquin Torres's avatar Joaquin Torres

Metric generation done

parent 7027a221
...@@ -190,8 +190,8 @@ if __name__ == "__main__": ...@@ -190,8 +190,8 @@ if __name__ == "__main__":
# Metric generation through cv for tuned models3 # Metric generation through cv for tuned models3
# -------------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------------
scores_sheets = {} # To store score dfs as sheets in the same excel file scores_sheets = {} # To store score dfs as sheets in the same excel file
for i, group in enumerate(['pre']): for i, group in enumerate(['pre', 'post']):
for j, method in enumerate(['']): for j, method in enumerate(['', '', 'over_', 'under_']):
# Get train dataset based on group and method # Get train dataset based on group and method
X_train = data_dic['X_train_' + method + group] X_train = data_dic['X_train_' + method + group]
y_train = data_dic['y_train_' + method + group] y_train = data_dic['y_train_' + method + group]
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -149,6 +149,21 @@ def negative_recall_scorer(clf, X, y): ...@@ -149,6 +149,21 @@ def negative_recall_scorer(clf, X, y):
cm = confusion_matrix(y, y_pred) cm = confusion_matrix(y, y_pred)
TN_prop = cm[0,0]/(cm[0,1]+cm[0,0]) TN_prop = cm[0,0]/(cm[0,1]+cm[0,0])
return TN_prop return TN_prop
# Custom scorers for AUROC and AUPRC
def AUROC_scorer(clf, X, y):
if hasattr(clf, "decision_function"):
y_score = clf.decision_function(X)
else:
y_score = clf.predict_proba(X)[:, 1]
return roc_auc_score(y, y_score)
def AUPRC_scorer(clf, X, y):
if hasattr(clf, "decision_function"):
y_score = clf.decision_function(X)
else:
y_score = clf.predict_proba(X)[:, 1]
return average_precision_score(y, y_score)
# -------------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------------
if __name__ == "__main__": if __name__ == "__main__":
...@@ -168,8 +183,8 @@ if __name__ == "__main__": ...@@ -168,8 +183,8 @@ if __name__ == "__main__":
'FN':FN_scorer, 'FN':FN_scorer,
'FP':FP_scorer, 'FP':FP_scorer,
'TP':TP_scorer, 'TP':TP_scorer,
'AUROC': make_scorer(roc_auc_score), # AUROC requires decision function or probability outputs 'AUROC': AUROC_scorer,
'AUPRC': make_scorer(average_precision_score) # AUPRC requires probability outputs 'AUPRC': AUPRC_scorer
} }
method_names = { method_names = {
0: "ORIG", 0: "ORIG",
......
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