Skip to content

Instantly share code, notes, and snippets.

@Kiwibp
Created June 13, 2018 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kiwibp/e2b8f186d18836f19415f87d0a292fe4 to your computer and use it in GitHub Desktop.
Save Kiwibp/e2b8f186d18836f19415f87d0a292fe4 to your computer and use it in GitHub Desktop.
# train the model on the training set
gboost.fit(X_train, y_train)
# make class predictions for the testing set
y_pred_class = gboost.predict(X_test)
# IMPORTANT: first argument is true values, second argument is predicted values
print(metrics.confusion_matrix(y_test, y_pred_class))
binary = np.array([[125, 14],
[ 22, 62]])
fig, ax = plot_confusion_matrix(conf_mat=binary)
plt.show();
# Determine the false positive and true positive rates
fpr, tpr, _ = roc_curve(y_test, gboost.predict_proba(X_test)[:,1])
# Calculate the AUC
roc_auc = auc(fpr, tpr)
print('ROC AUC: %0.2f' % roc_auc)
# Plot of a ROC curve for a specific class
plt.figure()
plt.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('ROC Curve')
plt.legend(loc="lower right")
plt.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment