-
-
Save BinarySpoon/815304be837d8e76b289ede92229de9d to your computer and use it in GitHub Desktop.
This file contains 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
#6 Heatmaps --> | |
lr_cm = metrics.confusion_matrix(y_test, lr_predict) # cm = confusion matrix, so sklearn has a built in for that. | |
svc_cm = metrics.confusion_matrix(y_test, svc_predict) | |
rf_cm = metrics.confusion_matrix(y_test, rf_predict) | |
knn_cm = metrics.confusion_matrix(y_test, knn_predict) | |
# Logistic regression | |
plt.figure(figsize=(9,9)) | |
sns.heatmap(lr_cm, annot=True, fmt='.3f', linewidths=.5, square=True, cmap='Blues'); | |
plt.ylabel('Actual label'); | |
plt.xlabel('Predicted label'); | |
all_sample_title = 'Logistic Regression: {0}'.format(lr_score) | |
plt.title(all_sample_title, size=15); | |
# Support Vector Machines --> | |
plt.figure(figsize=(9,9)) | |
sns.heatmap(svc_cm, annot=True, fmt='.3f', linewidths=.5, square=True, cmap='Blues'); | |
plt.ylabel('Actual label'); | |
plt.xlabel('Predicted label'); | |
all_sample_title = 'Support Vector Machines: {0}'.format(svc_score) | |
plt.title(all_sample_title, size=15); | |
# Random Forest Classifier --> | |
plt.figure(figsize=(9,9)) | |
sns.heatmap(rf_cm, annot=True, fmt='.3f', linewidths=.5, square=True, cmap='Blues'); | |
plt.ylabel('Actual label'); | |
plt.xlabel('Predicted label'); | |
all_sample_title = 'Random Forest: {0}'.format(svc_score) | |
plt.title(all_sample_title, size=15); | |
# K-Nearest Neighbors --> | |
plt.figure(figsize=(9,9)) | |
sns.heatmap(knn_cm, annot=True, fmt='.3f', linewidths=.5, square=True, cmap='Blues'); | |
plt.ylabel('Actual label'); | |
plt.xlabel('Predicted label'); | |
all_sample_title = 'K-Nearest Neighbors: {0}'.format(svc_score) | |
plt.title(all_sample_title, size=15); | |
# Printout plots --> | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment