Skip to content

Instantly share code, notes, and snippets.

@nitin-bommi
Last active June 18, 2020 14:49
Show Gist options
  • Save nitin-bommi/ef8af7f856099c47f971073ffdc7c357 to your computer and use it in GitHub Desktop.
Save nitin-bommi/ef8af7f856099c47f971073ffdc7c357 to your computer and use it in GitHub Desktop.
roc curve
# To compute the ROC curve and the area under the curve.
from sklearn.metrics import roc_curve, roc_auc_score
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_train_2, y_scores)
def plot_roc_curve(fpr, tpr, label=None):
plt.plot(fpr, tpr, linewidth=2, label=label)
plt.plot([0,1], [0,1], 'k--')
plt.axis([0,1,0,1])
plt.xlabel("False Positive Rate", fontsize=16)
plt.ylabel("True Positive Rate", fontsize=16)
# plotting the curve
plt.figure(figsize=(8, 6))
plot_roc_curve(false_positive_rate, true_positive_rate)
# calculating th area under the curve
roc_auc_score(y_train_2, y_scores_forest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment