Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Created February 11, 2019 09:57
Show Gist options
  • Save nithyadurai87/7668ce262ed9070d89b158bb7f13c5cb to your computer and use it in GitHub Desktop.
Save nithyadurai87/7668ce262ed9070d89b158bb7f13c5cb to your computer and use it in GitHub Desktop.
from sklearn.metrics import precision_recall_fscore_support
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
y_true = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
y_pred = [0, 1, 0, 0, 0, 0, 0, 1, 1, 1]
print ('Accuracy:', accuracy_score(y_true, y_pred))
print (confusion_matrix(y_true, y_pred))
print (precision_recall_fscore_support(y_true, y_pred))
plt.matshow(confusion_matrix(y_true, y_pred))
plt.title('Confusion matrix')
plt.colorbar()
plt.ylabel('True label')
plt.xlabel('Predicted label')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment