Created
November 30, 2017 01:20
-
-
Save 64lines/bb4c34e66f5f2bf08c22334684b7f199 to your computer and use it in GitHub Desktop.
[PYTHON][SKLEARN] Area under the ROC curve evaluating model performance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import necessary modules | |
from sklearn.metrics import roc_auc_score | |
from sklearn.model_selection import cross_val_score | |
# Compute predicted probabilities: y_pred_prob | |
y_pred_prob = logreg.predict_proba(X_test)[:,1] | |
# Compute and print AUC score | |
print("AUC: {}".format(roc_auc_score(y_test, y_pred_prob))) | |
# Compute cross-validated AUC scores: cv_auc | |
cv_auc = cross_val_score(logreg, X, y, cv=5, scoring='roc_auc') | |
# Print list of AUC scores | |
print("AUC scores computed using 5-fold cross-validation: {}".format(cv_auc)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment