Confusion Matrix
from sklearn.metrics import plot_confusion_matrix
fig, ax = plt.subplots(1, 3, figsize=(15,3))
plot_confusion_matrix(dummy, X_test, y_test, display_labels=["not 9", "9"], cmap=plt.cm.Blues, ax=ax[0])
plot_confusion_matrix(tree, X_test, y_test, display_labels=["not 9", "9"], cmap=plt.cm.Blues, ax=ax[1])
plot_confusion_matrix(logit, X_test, y_test, display_labels=["not 9", "9"], cmap=plt.cm.Blues, ax=ax[2])
ax[0].set_title('dummy')
ax[1].set_title('tree')
ax[2].set_title('logit')
plt.show()
Recall, Precision & F1
print(classification_report(y_test, pred_logit, target_names=["not 9", "9"]))
PR curve
from sklearn.metrics import plot_precision_recall_curve
fig, ax = plt.subplots(1, 1, figsize=(8,6))
plot_precision_recall_curve(dummy, X_test, y_test, ax=ax)
plot_precision_recall_curve(tree, X_test, y_test, ax=ax)
plot_precision_recall_curve(logit, X_test, y_test, ax=ax)
ax.set_title('PR curve')
plt.show()
ROC-AUC
fpr, tpr, _ = roc_curve(y_test, dummy.predict_proba(X_test)[:,1])
print('dummy: ', auc(fpr, tpr))
fpr, tpr, _ = roc_curve(y_test, tree.predict_proba(X_test)[:,1])
print('tree: ', auc(fpr, tpr))
fpr, tpr, _ = roc_curve(y_test, logit.predict_proba(X_test)[:,1])
print('logit: ', auc(fpr, tpr))
fig, ax = plt.subplots(1, 1, figsize=(8,6))
plot_roc_curve(dummy, X_test, y_test, ax=ax)
plot_roc_curve(tree, X_test, y_test, ax=ax)
plot_roc_curve(logit, X_test, y_test, ax=ax)
ax.set_title('ROC curve')
plt.show()