Skip to content

Instantly share code, notes, and snippets.

@ImadDabbura
Created August 3, 2018 21:20
Show Gist options
  • Select an option

  • Save ImadDabbura/0786fbbeae838e6571bd977599d90c7f to your computer and use it in GitHub Desktop.

Select an option

Save ImadDabbura/0786fbbeae838e6571bd977599d90c7f to your computer and use it in GitHub Desktop.
# Plot confusion matrix
second_stack_probs = second_stack.predict_proba(first_stack.transform(X_test))
second_stack_preds = second_stack.predict(first_stack.transform(X_test))
conf_mat = confusion_matrix(y_test, second_stack_preds)
plt.figure(figsize=(16, 8))
plt.matshow(conf_mat, cmap=plt.cm.Reds, alpha=0.2)
for i in range(2):
for j in range(2):
plt.text(x=j, y=i, s=conf_mat[i, j], ha="center", va="center")
plt.title("Confusion matrix", y=1.1, fontdict={"fontsize": 20})
plt.xlabel("Predicted", fontdict={"fontsize": 14})
plt.ylabel("Actual", fontdict={"fontsize": 14});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment