Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Voting records - party prediction\n",
- "## Neural Network for binary classification"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Import necessary libraries\n",
- "from keras.models import Sequential\n",
- "from keras.layers import Dense\n",
- "from keras import optimizers\n",
- "import numpy as np\n",
- "from sklearn.metrics import classification_report, confusion_matrix\n",
- "\n",
- "# set random seed for reproducibility\n",
- "np.random.seed(7)\n",
- "\n",
- "\n",
- "#\n",
- "# Add all your code here\n",
- "# Cut 'n paste is your friend :)\n",
- "#\n",
- "\n",
- "\n",
- "# I have included this code for you which will \n",
- "# create confusion matrix details\n",
- "rounded = [round(i[0]) for i in Y_predict]\n",
- "y_pred = np.array(rounded,dtype='int64')\n",
- "print('Confusion Matrix')\n",
- "print('================')\n",
- "CM = confusion_matrix(Y, y_pred)\n",
- "print('True negatives: ',CM[0,0])\n",
- "print('False negatives: ',CM[1,0])\n",
- "print('False positives: ',CM[0,1])\n",
- "print('True positives: ',CM[1,1])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.5"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement