Last active
July 24, 2017 14:28
-
-
Save Swarchal/7419291f5e75265fd74e2c3dce0b1acc to your computer and use it in GitHub Desktop.
confusion matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import confusion_matrix | |
import numpy as np | |
cm = confusion_matrix(y_test, predictions) | |
# normalise confusion matrix for diff sized groups | |
cm_norm = cm.astype("float") / cm.sum(axis=1)[:, np.newaxis] | |
# plot confusion matrix | |
plt.figure(figsize=(8,6)) | |
plt.imshow(cm_norm, interpolation='nearest', cmap=plt.cm.Blues) | |
plt.title("title") | |
plt.colorbar() | |
plt.tight_layout() | |
tick_marks = np.arange(len(set(feature_names))) | |
plt.xticks(tick_marks, set(feature_names), rotation = 90) | |
plt.yticks(tick_marks, set(feature_names)) | |
plt.ylabel('True MOA') | |
plt.xlabel('Predicted MOA') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment