Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "## Voting records - party prediction\n",
  8. "## Neural Network for binary classification"
  9. ]
  10. },
  11. {
  12. "cell_type": "code",
  13. "execution_count": null,
  14. "metadata": {},
  15. "outputs": [],
  16. "source": [
  17. "# Import necessary libraries\n",
  18. "from keras.models import Sequential\n",
  19. "from keras.layers import Dense\n",
  20. "from keras import optimizers\n",
  21. "import numpy as np\n",
  22. "from sklearn.metrics import classification_report, confusion_matrix\n",
  23. "\n",
  24. "# set random seed for reproducibility\n",
  25. "np.random.seed(7)\n",
  26. "\n",
  27. "\n",
  28. "#\n",
  29. "# Add all your code here\n",
  30. "# Cut 'n paste is your friend :)\n",
  31. "#\n",
  32. "\n",
  33. "\n",
  34. "# I have included this code for you which will \n",
  35. "# create confusion matrix details\n",
  36. "rounded = [round(i[0]) for i in Y_predict]\n",
  37. "y_pred = np.array(rounded,dtype='int64')\n",
  38. "print('Confusion Matrix')\n",
  39. "print('================')\n",
  40. "CM = confusion_matrix(Y, y_pred)\n",
  41. "print('True negatives: ',CM[0,0])\n",
  42. "print('False negatives: ',CM[1,0])\n",
  43. "print('False positives: ',CM[0,1])\n",
  44. "print('True positives: ',CM[1,1])"
  45. ]
  46. },
  47. {
  48. "cell_type": "code",
  49. "execution_count": null,
  50. "metadata": {},
  51. "outputs": [],
  52. "source": []
  53. }
  54. ],
  55. "metadata": {
  56. "kernelspec": {
  57. "display_name": "Python 3",
  58. "language": "python",
  59. "name": "python3"
  60. },
  61. "language_info": {
  62. "codemirror_mode": {
  63. "name": "ipython",
  64. "version": 3
  65. },
  66. "file_extension": ".py",
  67. "mimetype": "text/x-python",
  68. "name": "python",
  69. "nbconvert_exporter": "python",
  70. "pygments_lexer": "ipython3",
  71. "version": "3.6.5"
  72. }
  73. },
  74. "nbformat": 4,
  75. "nbformat_minor": 2
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement