Skip to content

Instantly share code, notes, and snippets.

@davidzhaodz
Created January 9, 2021 12:15
Show Gist options
  • Save davidzhaodz/393e238f165f350e7add807e907e9947 to your computer and use it in GitHub Desktop.
Save davidzhaodz/393e238f165f350e7add807e907e9947 to your computer and use it in GitHub Desktop.
# Performance Metrics
y_pred_rf = rf.predict_proba(X_test)[:, 1]
y_pred = rf.predict(X_test)
fpr_rf, tpr_rf, _ = roc_curve(y_test, y_pred_rf)
print(classification_report(y_test, y_pred))
print("Confusion Matrix")
print(confusion_matrix(y_test, y_pred))
print('')
print("Accuracy")
print(accuracy_score(y_test, y_pred))
#plotting ROC curve
plt.figure(1)
plt.plot([0, 1], [0, 1], 'k--')
plt.plot(fpr_rf, tpr_rf, label='RF')
plt.xlabel('False positive rate')
plt.ylabel('True positive rate')
plt.title('ROC curve')
plt.legend(loc='best')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment