-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path26-1 Confusion matrix example
1 lines (1 loc) · 1.19 KB
/
26-1 Confusion matrix example
1
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"26-1 Confusion matrix example ","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyNs5yWD3h05aRIbZk8NZ9bY"},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"code","metadata":{"id":"hnwNGFRNe1RI"},"source":["# Confusion matrix example\n","# author: Gressling, T\n","# license: MIT License # code: github.com/gressling/examples\n","# activity: single example # index: 26-1 "],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"wCSusmeWe7-H"},"source":["from sklearn.metrics import confusion_matrix\n","\n","def plot_confusion_matrix(cm, classes, title, cmap=plt.cm.Blues):\n"," ...\n"," thresh = cm.max() / 2.\n"," for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):\n"," plt.text(j, i, cm[i, j],\n"," horizontalalignment=\"center\",\n"," color=\"white\" if cm[i, j] > thresh else “black\")"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"Dti1dv5nfBhm"},"source":["matrix = confusion_matrix(y_CV, y_pred)\n","plot_confusion_matrix(matrix, classes=[0, 1], title='Confusion matrix')\n","plt.show()\n"],"execution_count":null,"outputs":[]}]}