{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Logistic Regression\n",
    "\n",
    "## Introduction\n",
    "\n",
    "In example, we will build a logistic regression model to\n",
    "predict whether a student gets admitted into a university.\n",
    "\n",
    "Suppose that you are the administrator of a university department and\n",
    "you want to determine each applicant’s chance of admission based on their\n",
    "results on two exams. You have historical data from previous applicants\n",
    "that you can use as a training set for logistic regression. For each training\n",
    "example, you have the applicant’s scores on two exams and the admissions\n",
    "decision. Your task is to build a classification model that estimates an applicant’s\n",
    "probability of admission based the scores from those two exams.\n",
    "\n",
    "## Visualizing the data\n",
    "\n",
    "Before starting to implement any learning algorithm, it is always good to\n",
    "visualize the data if possible.\n",
    "\n",
    "The file 'data/ex2data1.txt' contains the dataset for our Logistic regression problem.\n",
    "\n",
    "Here we will load the data and display it on a 2-dimensional plot, where the axes are the two exam scores, and the positive and\n",
    "negative examples are shown with different markers."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# initial imports\n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "%matplotlib notebook\n",
    "import seaborn as sns\n",
    "\n",
    "# setting graph properties\n",
    "plt.rcParams['figure.dpi'] = 300  # setting figure dpi for better quality graphs\n",
    "plt.rcParams['figure.figsize'] = [10,8]\n",
    "sns.set(context=\"notebook\", style=\"white\")  # graph styling using seaborn\n",
    "%config InlineBackend.figure_format = 'svg'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# imports from my models designed for these examples\n",
    "from models.data_preprocessing import add_bias_unit, map_feature, feature_normalize\n",
    "from models.logistic_regression import cost_function, predict, gradient_descent, gradient_function, sigmoid\n",
    "from models.plotter import plot_decision_boundary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading data ...\n"
     ]
    }
   ],
   "source": [
    "print('Loading data ...')\n",
    "data = np.loadtxt('data/ex2data1.txt', delimiter=',')\n",
    "X = data[:, :-1]  # (100, 2)\n",
    "y = data[:, -1, np.newaxis]  # (100, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Plotting data with + indicating (y = 1) examples and o indicating (y = 0) examples.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x7f4e28e02630>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"267.599687pt\" version=\"1.1\" viewBox=\"0 0 395.31 267.599687\" width=\"395.31pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 267.599687 \n",
       "L 395.31 267.599687 \n",
       "L 395.31 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 53.31 224.64 \n",
       "L 388.11 224.64 \n",
       "L 388.11 7.2 \n",
       "L 53.31 7.2 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 30 -->\n",
       "      <defs>\n",
       "       <path d=\"M 40.578125 39.3125 \n",
       "Q 47.65625 37.796875 51.625 33 \n",
       "Q 55.609375 28.21875 55.609375 21.1875 \n",
       "Q 55.609375 10.40625 48.1875 4.484375 \n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \n",
       "Q 12.796875 0.390625 7.625 2.203125 \n",
       "L 7.625 11.71875 \n",
       "Q 11.71875 9.328125 16.59375 8.109375 \n",
       "Q 21.484375 6.890625 26.8125 6.890625 \n",
       "Q 36.078125 6.890625 40.9375 10.546875 \n",
       "Q 45.796875 14.203125 45.796875 21.1875 \n",
       "Q 45.796875 27.640625 41.28125 31.265625 \n",
       "Q 36.765625 34.90625 28.71875 34.90625 \n",
       "L 20.21875 34.90625 \n",
       "L 20.21875 43.015625 \n",
       "L 29.109375 43.015625 \n",
       "Q 36.375 43.015625 40.234375 45.921875 \n",
       "Q 44.09375 48.828125 44.09375 54.296875 \n",
       "Q 44.09375 59.90625 40.109375 62.90625 \n",
       "Q 36.140625 65.921875 28.71875 65.921875 \n",
       "Q 24.65625 65.921875 20.015625 65.03125 \n",
       "Q 15.375 64.15625 9.8125 62.3125 \n",
       "L 9.8125 71.09375 \n",
       "Q 15.4375 72.65625 20.34375 73.4375 \n",
       "Q 25.25 74.21875 29.59375 74.21875 \n",
       "Q 40.828125 74.21875 47.359375 69.109375 \n",
       "Q 53.90625 64.015625 53.90625 55.328125 \n",
       "Q 53.90625 49.265625 50.4375 45.09375 \n",
       "Q 46.96875 40.921875 40.578125 39.3125 \n",
       "z\n",
       "\" id=\"DejaVuSans-51\"/>\n",
       "       <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-48\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(63.387692 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 40 -->\n",
       "      <defs>\n",
       "       <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-52\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(106.70273 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 50 -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.796875 72.90625 \n",
       "L 49.515625 72.90625 \n",
       "L 49.515625 64.59375 \n",
       "L 19.828125 64.59375 \n",
       "L 19.828125 46.734375 \n",
       "Q 21.96875 47.46875 24.109375 47.828125 \n",
       "Q 26.265625 48.1875 28.421875 48.1875 \n",
       "Q 40.625 48.1875 47.75 41.5 \n",
       "Q 54.890625 34.8125 54.890625 23.390625 \n",
       "Q 54.890625 11.625 47.5625 5.09375 \n",
       "Q 40.234375 -1.421875 26.90625 -1.421875 \n",
       "Q 22.3125 -1.421875 17.546875 -0.640625 \n",
       "Q 12.796875 0.140625 7.71875 1.703125 \n",
       "L 7.71875 11.625 \n",
       "Q 12.109375 9.234375 16.796875 8.0625 \n",
       "Q 21.484375 6.890625 26.703125 6.890625 \n",
       "Q 35.15625 6.890625 40.078125 11.328125 \n",
       "Q 45.015625 15.765625 45.015625 23.390625 \n",
       "Q 45.015625 31 40.078125 35.4375 \n",
       "Q 35.15625 39.890625 26.703125 39.890625 \n",
       "Q 22.75 39.890625 18.8125 39.015625 \n",
       "Q 14.890625 38.140625 10.796875 36.28125 \n",
       "z\n",
       "\" id=\"DejaVuSans-53\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(150.017769 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 60 -->\n",
       "      <defs>\n",
       "       <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-54\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(193.332807 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-54\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 70 -->\n",
       "      <defs>\n",
       "       <path d=\"M 8.203125 72.90625 \n",
       "L 55.078125 72.90625 \n",
       "L 55.078125 68.703125 \n",
       "L 28.609375 0 \n",
       "L 18.3125 0 \n",
       "L 43.21875 64.59375 \n",
       "L 8.203125 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-55\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(236.647846 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-55\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 80 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 34.625 \n",
       "Q 24.75 34.625 20.71875 30.859375 \n",
       "Q 16.703125 27.09375 16.703125 20.515625 \n",
       "Q 16.703125 13.921875 20.71875 10.15625 \n",
       "Q 24.75 6.390625 31.78125 6.390625 \n",
       "Q 38.8125 6.390625 42.859375 10.171875 \n",
       "Q 46.921875 13.96875 46.921875 20.515625 \n",
       "Q 46.921875 27.09375 42.890625 30.859375 \n",
       "Q 38.875 34.625 31.78125 34.625 \n",
       "z\n",
       "M 21.921875 38.8125 \n",
       "Q 15.578125 40.375 12.03125 44.71875 \n",
       "Q 8.5 49.078125 8.5 55.328125 \n",
       "Q 8.5 64.0625 14.71875 69.140625 \n",
       "Q 20.953125 74.21875 31.78125 74.21875 \n",
       "Q 42.671875 74.21875 48.875 69.140625 \n",
       "Q 55.078125 64.0625 55.078125 55.328125 \n",
       "Q 55.078125 49.078125 51.53125 44.71875 \n",
       "Q 48 40.375 41.703125 38.8125 \n",
       "Q 48.828125 37.15625 52.796875 32.3125 \n",
       "Q 56.78125 27.484375 56.78125 20.515625 \n",
       "Q 56.78125 9.90625 50.3125 4.234375 \n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.25 4.234375 \n",
       "Q 6.78125 9.90625 6.78125 20.515625 \n",
       "Q 6.78125 27.484375 10.78125 32.3125 \n",
       "Q 14.796875 37.15625 21.921875 38.8125 \n",
       "z\n",
       "M 18.3125 54.390625 \n",
       "Q 18.3125 48.734375 21.84375 45.5625 \n",
       "Q 25.390625 42.390625 31.78125 42.390625 \n",
       "Q 38.140625 42.390625 41.71875 45.5625 \n",
       "Q 45.3125 48.734375 45.3125 54.390625 \n",
       "Q 45.3125 60.0625 41.71875 63.234375 \n",
       "Q 38.140625 66.40625 31.78125 66.40625 \n",
       "Q 25.390625 66.40625 21.84375 63.234375 \n",
       "Q 18.3125 60.0625 18.3125 54.390625 \n",
       "z\n",
       "\" id=\"DejaVuSans-56\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(279.962884 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-56\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 90 -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.984375 1.515625 \n",
       "L 10.984375 10.5 \n",
       "Q 14.703125 8.734375 18.5 7.8125 \n",
       "Q 22.3125 6.890625 25.984375 6.890625 \n",
       "Q 35.75 6.890625 40.890625 13.453125 \n",
       "Q 46.046875 20.015625 46.78125 33.40625 \n",
       "Q 43.953125 29.203125 39.59375 26.953125 \n",
       "Q 35.25 24.703125 29.984375 24.703125 \n",
       "Q 19.046875 24.703125 12.671875 31.3125 \n",
       "Q 6.296875 37.9375 6.296875 49.421875 \n",
       "Q 6.296875 60.640625 12.9375 67.421875 \n",
       "Q 19.578125 74.21875 30.609375 74.21875 \n",
       "Q 43.265625 74.21875 49.921875 64.515625 \n",
       "Q 56.59375 54.828125 56.59375 36.375 \n",
       "Q 56.59375 19.140625 48.40625 8.859375 \n",
       "Q 40.234375 -1.421875 26.421875 -1.421875 \n",
       "Q 22.703125 -1.421875 18.890625 -0.6875 \n",
       "Q 15.09375 0.046875 10.984375 1.515625 \n",
       "z\n",
       "M 30.609375 32.421875 \n",
       "Q 37.25 32.421875 41.125 36.953125 \n",
       "Q 45.015625 41.5 45.015625 49.421875 \n",
       "Q 45.015625 57.28125 41.125 61.84375 \n",
       "Q 37.25 66.40625 30.609375 66.40625 \n",
       "Q 23.96875 66.40625 20.09375 61.84375 \n",
       "Q 16.21875 57.28125 16.21875 49.421875 \n",
       "Q 16.21875 41.5 20.09375 36.953125 \n",
       "Q 23.96875 32.421875 30.609375 32.421875 \n",
       "z\n",
       "\" id=\"DejaVuSans-57\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(323.277923 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-57\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 100 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-49\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(363.093587 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_9\">\n",
       "     <!-- Exam 1 score -->\n",
       "     <defs>\n",
       "      <path d=\"M 9.8125 72.90625 \n",
       "L 55.90625 72.90625 \n",
       "L 55.90625 64.59375 \n",
       "L 19.671875 64.59375 \n",
       "L 19.671875 43.015625 \n",
       "L 54.390625 43.015625 \n",
       "L 54.390625 34.71875 \n",
       "L 19.671875 34.71875 \n",
       "L 19.671875 8.296875 \n",
       "L 56.78125 8.296875 \n",
       "L 56.78125 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-69\"/>\n",
       "      <path d=\"M 54.890625 54.6875 \n",
       "L 35.109375 28.078125 \n",
       "L 55.90625 0 \n",
       "L 45.3125 0 \n",
       "L 29.390625 21.484375 \n",
       "L 13.484375 0 \n",
       "L 2.875 0 \n",
       "L 24.125 28.609375 \n",
       "L 4.6875 54.6875 \n",
       "L 15.28125 54.6875 \n",
       "L 29.78125 35.203125 \n",
       "L 44.28125 54.6875 \n",
       "z\n",
       "\" id=\"DejaVuSans-120\"/>\n",
       "      <path d=\"M 34.28125 27.484375 \n",
       "Q 23.390625 27.484375 19.1875 25 \n",
       "Q 14.984375 22.515625 14.984375 16.5 \n",
       "Q 14.984375 11.71875 18.140625 8.90625 \n",
       "Q 21.296875 6.109375 26.703125 6.109375 \n",
       "Q 34.1875 6.109375 38.703125 11.40625 \n",
       "Q 43.21875 16.703125 43.21875 25.484375 \n",
       "L 43.21875 27.484375 \n",
       "z\n",
       "M 52.203125 31.203125 \n",
       "L 52.203125 0 \n",
       "L 43.21875 0 \n",
       "L 43.21875 8.296875 \n",
       "Q 40.140625 3.328125 35.546875 0.953125 \n",
       "Q 30.953125 -1.421875 24.3125 -1.421875 \n",
       "Q 15.921875 -1.421875 10.953125 3.296875 \n",
       "Q 6 8.015625 6 15.921875 \n",
       "Q 6 25.140625 12.171875 29.828125 \n",
       "Q 18.359375 34.515625 30.609375 34.515625 \n",
       "L 43.21875 34.515625 \n",
       "L 43.21875 35.40625 \n",
       "Q 43.21875 41.609375 39.140625 45 \n",
       "Q 35.0625 48.390625 27.6875 48.390625 \n",
       "Q 23 48.390625 18.546875 47.265625 \n",
       "Q 14.109375 46.140625 10.015625 43.890625 \n",
       "L 10.015625 52.203125 \n",
       "Q 14.9375 54.109375 19.578125 55.046875 \n",
       "Q 24.21875 56 28.609375 56 \n",
       "Q 40.484375 56 46.34375 49.84375 \n",
       "Q 52.203125 43.703125 52.203125 31.203125 \n",
       "z\n",
       "\" id=\"DejaVuSans-97\"/>\n",
       "      <path d=\"M 52 44.1875 \n",
       "Q 55.375 50.25 60.0625 53.125 \n",
       "Q 64.75 56 71.09375 56 \n",
       "Q 79.640625 56 84.28125 50.015625 \n",
       "Q 88.921875 44.046875 88.921875 33.015625 \n",
       "L 88.921875 0 \n",
       "L 79.890625 0 \n",
       "L 79.890625 32.71875 \n",
       "Q 79.890625 40.578125 77.09375 44.375 \n",
       "Q 74.3125 48.1875 68.609375 48.1875 \n",
       "Q 61.625 48.1875 57.5625 43.546875 \n",
       "Q 53.515625 38.921875 53.515625 30.90625 \n",
       "L 53.515625 0 \n",
       "L 44.484375 0 \n",
       "L 44.484375 32.71875 \n",
       "Q 44.484375 40.625 41.703125 44.40625 \n",
       "Q 38.921875 48.1875 33.109375 48.1875 \n",
       "Q 26.21875 48.1875 22.15625 43.53125 \n",
       "Q 18.109375 38.875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.1875 51.21875 25.484375 53.609375 \n",
       "Q 29.78125 56 35.6875 56 \n",
       "Q 41.65625 56 45.828125 52.96875 \n",
       "Q 50 49.953125 52 44.1875 \n",
       "z\n",
       "\" id=\"DejaVuSans-109\"/>\n",
       "      <path id=\"DejaVuSans-32\"/>\n",
       "      <path d=\"M 44.28125 53.078125 \n",
       "L 44.28125 44.578125 \n",
       "Q 40.484375 46.53125 36.375 47.5 \n",
       "Q 32.28125 48.484375 27.875 48.484375 \n",
       "Q 21.1875 48.484375 17.84375 46.4375 \n",
       "Q 14.5 44.390625 14.5 40.28125 \n",
       "Q 14.5 37.15625 16.890625 35.375 \n",
       "Q 19.28125 33.59375 26.515625 31.984375 \n",
       "L 29.59375 31.296875 \n",
       "Q 39.15625 29.25 43.1875 25.515625 \n",
       "Q 47.21875 21.78125 47.21875 15.09375 \n",
       "Q 47.21875 7.46875 41.1875 3.015625 \n",
       "Q 35.15625 -1.421875 24.609375 -1.421875 \n",
       "Q 20.21875 -1.421875 15.453125 -0.5625 \n",
       "Q 10.6875 0.296875 5.421875 2 \n",
       "L 5.421875 11.28125 \n",
       "Q 10.40625 8.6875 15.234375 7.390625 \n",
       "Q 20.0625 6.109375 24.8125 6.109375 \n",
       "Q 31.15625 6.109375 34.5625 8.28125 \n",
       "Q 37.984375 10.453125 37.984375 14.40625 \n",
       "Q 37.984375 18.0625 35.515625 20.015625 \n",
       "Q 33.0625 21.96875 24.703125 23.78125 \n",
       "L 21.578125 24.515625 \n",
       "Q 13.234375 26.265625 9.515625 29.90625 \n",
       "Q 5.8125 33.546875 5.8125 39.890625 \n",
       "Q 5.8125 47.609375 11.28125 51.796875 \n",
       "Q 16.75 56 26.8125 56 \n",
       "Q 31.78125 56 36.171875 55.265625 \n",
       "Q 40.578125 54.546875 44.28125 53.078125 \n",
       "z\n",
       "\" id=\"DejaVuSans-115\"/>\n",
       "      <path d=\"M 48.78125 52.59375 \n",
       "L 48.78125 44.1875 \n",
       "Q 44.96875 46.296875 41.140625 47.34375 \n",
       "Q 37.3125 48.390625 33.40625 48.390625 \n",
       "Q 24.65625 48.390625 19.8125 42.84375 \n",
       "Q 14.984375 37.3125 14.984375 27.296875 \n",
       "Q 14.984375 17.28125 19.8125 11.734375 \n",
       "Q 24.65625 6.203125 33.40625 6.203125 \n",
       "Q 37.3125 6.203125 41.140625 7.25 \n",
       "Q 44.96875 8.296875 48.78125 10.40625 \n",
       "L 48.78125 2.09375 \n",
       "Q 45.015625 0.34375 40.984375 -0.53125 \n",
       "Q 36.96875 -1.421875 32.421875 -1.421875 \n",
       "Q 20.0625 -1.421875 12.78125 6.34375 \n",
       "Q 5.515625 14.109375 5.515625 27.296875 \n",
       "Q 5.515625 40.671875 12.859375 48.328125 \n",
       "Q 20.21875 56 33.015625 56 \n",
       "Q 37.15625 56 41.109375 55.140625 \n",
       "Q 45.0625 54.296875 48.78125 52.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-99\"/>\n",
       "      <path d=\"M 30.609375 48.390625 \n",
       "Q 23.390625 48.390625 19.1875 42.75 \n",
       "Q 14.984375 37.109375 14.984375 27.296875 \n",
       "Q 14.984375 17.484375 19.15625 11.84375 \n",
       "Q 23.34375 6.203125 30.609375 6.203125 \n",
       "Q 37.796875 6.203125 41.984375 11.859375 \n",
       "Q 46.1875 17.53125 46.1875 27.296875 \n",
       "Q 46.1875 37.015625 41.984375 42.703125 \n",
       "Q 37.796875 48.390625 30.609375 48.390625 \n",
       "z\n",
       "M 30.609375 56 \n",
       "Q 42.328125 56 49.015625 48.375 \n",
       "Q 55.71875 40.765625 55.71875 27.296875 \n",
       "Q 55.71875 13.875 49.015625 6.21875 \n",
       "Q 42.328125 -1.421875 30.609375 -1.421875 \n",
       "Q 18.84375 -1.421875 12.171875 6.21875 \n",
       "Q 5.515625 13.875 5.515625 27.296875 \n",
       "Q 5.515625 40.765625 12.171875 48.375 \n",
       "Q 18.84375 56 30.609375 56 \n",
       "z\n",
       "\" id=\"DejaVuSans-111\"/>\n",
       "      <path d=\"M 41.109375 46.296875 \n",
       "Q 39.59375 47.171875 37.8125 47.578125 \n",
       "Q 36.03125 48 33.890625 48 \n",
       "Q 26.265625 48 22.1875 43.046875 \n",
       "Q 18.109375 38.09375 18.109375 28.8125 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 20.953125 51.171875 25.484375 53.578125 \n",
       "Q 30.03125 56 36.53125 56 \n",
       "Q 37.453125 56 38.578125 55.875 \n",
       "Q 39.703125 55.765625 41.0625 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-114\"/>\n",
       "      <path d=\"M 56.203125 29.59375 \n",
       "L 56.203125 25.203125 \n",
       "L 14.890625 25.203125 \n",
       "Q 15.484375 15.921875 20.484375 11.0625 \n",
       "Q 25.484375 6.203125 34.421875 6.203125 \n",
       "Q 39.59375 6.203125 44.453125 7.46875 \n",
       "Q 49.3125 8.734375 54.109375 11.28125 \n",
       "L 54.109375 2.78125 \n",
       "Q 49.265625 0.734375 44.1875 -0.34375 \n",
       "Q 39.109375 -1.421875 33.890625 -1.421875 \n",
       "Q 20.796875 -1.421875 13.15625 6.1875 \n",
       "Q 5.515625 13.8125 5.515625 26.8125 \n",
       "Q 5.515625 40.234375 12.765625 48.109375 \n",
       "Q 20.015625 56 32.328125 56 \n",
       "Q 43.359375 56 49.78125 48.890625 \n",
       "Q 56.203125 41.796875 56.203125 29.59375 \n",
       "z\n",
       "M 47.21875 32.234375 \n",
       "Q 47.125 39.59375 43.09375 43.984375 \n",
       "Q 39.0625 48.390625 32.421875 48.390625 \n",
       "Q 24.90625 48.390625 20.390625 44.140625 \n",
       "Q 15.875 39.890625 15.1875 32.171875 \n",
       "z\n",
       "\" id=\"DejaVuSans-101\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(179.9625 257.904062)scale(0.12 -0.12)\">\n",
       "      <use xlink:href=\"#DejaVuSans-69\"/>\n",
       "      <use x=\"63.183594\" xlink:href=\"#DejaVuSans-120\"/>\n",
       "      <use x=\"122.363281\" xlink:href=\"#DejaVuSans-97\"/>\n",
       "      <use x=\"183.642578\" xlink:href=\"#DejaVuSans-109\"/>\n",
       "      <use x=\"281.054688\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      <use x=\"312.841797\" xlink:href=\"#DejaVuSans-49\"/>\n",
       "      <use x=\"376.464844\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      <use x=\"408.251953\" xlink:href=\"#DejaVuSans-115\"/>\n",
       "      <use x=\"460.351562\" xlink:href=\"#DejaVuSans-99\"/>\n",
       "      <use x=\"515.332031\" xlink:href=\"#DejaVuSans-111\"/>\n",
       "      <use x=\"576.513672\" xlink:href=\"#DejaVuSans-114\"/>\n",
       "      <use x=\"617.595703\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 30 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(29.8125 218.696381)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 40 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(29.8125 190.311924)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 50 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(29.8125 161.927468)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 60 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(29.8125 133.543011)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-54\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 70 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(29.8125 105.158555)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-55\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 80 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(29.8125 76.774098)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-56\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"text_16\">\n",
       "      <!-- 90 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(29.8125 48.389642)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-57\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_8\">\n",
       "     <g id=\"text_17\">\n",
       "      <!-- 100 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(22.81375 20.005185)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_18\">\n",
       "     <!-- Exam 2 score -->\n",
       "     <defs>\n",
       "      <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-50\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(16.318125 156.6675)rotate(-90)scale(0.12 -0.12)\">\n",
       "      <use xlink:href=\"#DejaVuSans-69\"/>\n",
       "      <use x=\"63.183594\" xlink:href=\"#DejaVuSans-120\"/>\n",
       "      <use x=\"122.363281\" xlink:href=\"#DejaVuSans-97\"/>\n",
       "      <use x=\"183.642578\" xlink:href=\"#DejaVuSans-109\"/>\n",
       "      <use x=\"281.054688\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      <use x=\"312.841797\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      <use x=\"376.464844\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      <use x=\"408.251953\" xlink:href=\"#DejaVuSans-115\"/>\n",
       "      <use x=\"460.351562\" xlink:href=\"#DejaVuSans-99\"/>\n",
       "      <use x=\"515.332031\" xlink:href=\"#DejaVuSans-111\"/>\n",
       "      <use x=\"576.513672\" xlink:href=\"#DejaVuSans-114\"/>\n",
       "      <use x=\"617.595703\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\">\n",
       "    <defs>\n",
       "     <path d=\"M -3.535534 0 \n",
       "L 3.535534 0 \n",
       "M 0 3.535534 \n",
       "L 0 -3.535534 \n",
       "\" id=\"m88d39fb814\" style=\"stroke:#000000;stroke-width:1.5;\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p00aa67d2f8)\">\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"201.122487\" xlink:href=\"#m88d39fb814\" y=\"54.688475\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"282.771927\" xlink:href=\"#m88d39fb814\" y=\"85.809692\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"205.125079\" xlink:href=\"#m88d39fb814\" y=\"25.728172\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"265.411301\" xlink:href=\"#m88d39fb814\" y=\"167.529572\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"270.063514\" xlink:href=\"#m88d39fb814\" y=\"51.532074\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"306.162411\" xlink:href=\"#m88d39fb814\" y=\"176.103439\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"296.954645\" xlink:href=\"#m88d39fb814\" y=\"82.580714\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"240.89431\" xlink:href=\"#m88d39fb814\" y=\"22.301413\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"174.217147\" xlink:href=\"#m88d39fb814\" y=\"46.460395\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"239.618921\" xlink:href=\"#m88d39fb814\" y=\"149.969653\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"246.511927\" xlink:href=\"#m88d39fb814\" y=\"35.901979\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"273.875225\" xlink:href=\"#m88d39fb814\" y=\"164.628823\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"328.876626\" xlink:href=\"#m88d39fb814\" y=\"112.902686\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"277.969829\" xlink:href=\"#m88d39fb814\" y=\"103.896314\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"210.168462\" xlink:href=\"#m88d39fb814\" y=\"101.108683\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"287.785403\" xlink:href=\"#m88d39fb814\" y=\"172.446852\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"206.305955\" xlink:href=\"#m88d39fb814\" y=\"93.009379\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"310.371331\" xlink:href=\"#m88d39fb814\" y=\"137.731654\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"165.876198\" xlink:href=\"#m88d39fb814\" y=\"102.58921\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"218.424201\" xlink:href=\"#m88d39fb814\" y=\"70.017477\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"303.864868\" xlink:href=\"#m88d39fb814\" y=\"139.843281\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"349.523138\" xlink:href=\"#m88d39fb814\" y=\"113.556789\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"274.803254\" xlink:href=\"#m88d39fb814\" y=\"99.678838\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"363.939385\" xlink:href=\"#m88d39fb814\" y=\"53.498399\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"209.311041\" xlink:href=\"#m88d39fb814\" y=\"24.997562\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"337.055366\" xlink:href=\"#m88d39fb814\" y=\"47.911004\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"286.722613\" xlink:href=\"#m88d39fb814\" y=\"89.162626\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"370.440659\" xlink:href=\"#m88d39fb814\" y=\"126.528175\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"332.644767\" xlink:href=\"#m88d39fb814\" y=\"176.508745\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"363.393766\" xlink:href=\"#m88d39fb814\" y=\"104.210778\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"262.049819\" xlink:href=\"#m88d39fb814\" y=\"101.477359\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"251.427978\" xlink:href=\"#m88d39fb814\" y=\"76.984437\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"267.017708\" xlink:href=\"#m88d39fb814\" y=\"56.24569\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"115.683364\" xlink:href=\"#m88d39fb814\" y=\"22.822286\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"288.17261\" xlink:href=\"#m88d39fb814\" y=\"38.204177\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"229.554995\" xlink:href=\"#m88d39fb814\" y=\"126.549853\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"217.827889\" xlink:href=\"#m88d39fb814\" y=\"78.181904\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"253.810445\" xlink:href=\"#m88d39fb814\" y=\"26.533817\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"202.314891\" xlink:href=\"#m88d39fb814\" y=\"92.19443\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"195.311155\" xlink:href=\"#m88d39fb814\" y=\"84.350527\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"372.846077\" xlink:href=\"#m88d39fb814\" y=\"94.254421\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"145.16669\" xlink:href=\"#m88d39fb814\" y=\"48.536675\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"159.00104\" xlink:href=\"#m88d39fb814\" y=\"84.488444\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"325.572211\" xlink:href=\"#m88d39fb814\" y=\"101.536349\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"351.217357\" xlink:href=\"#m88d39fb814\" y=\"169.969803\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"232.034949\" xlink:href=\"#m88d39fb814\" y=\"110.66035\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"188.371003\" xlink:href=\"#m88d39fb814\" y=\"130.742555\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"288.55024\" xlink:href=\"#m88d39fb814\" y=\"41.485173\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"237.012992\" xlink:href=\"#m88d39fb814\" y=\"56.715821\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"267.373283\" xlink:href=\"#m88d39fb814\" y=\"43.00547\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"281.05097\" xlink:href=\"#m88d39fb814\" y=\"25.34214\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"348.011284\" xlink:href=\"#m88d39fb814\" y=\"80.658683\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"332.219573\" xlink:href=\"#m88d39fb814\" y=\"51.28166\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"263.10671\" xlink:href=\"#m88d39fb814\" y=\"58.8423\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"329.608784\" xlink:href=\"#m88d39fb814\" y=\"170.923587\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"302.074956\" xlink:href=\"#m88d39fb814\" y=\"162.345798\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"123.498046\" xlink:href=\"#m88d39fb814\" y=\"52.431063\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"370.62467\" xlink:href=\"#m88d39fb814\" y=\"104.455348\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"180.146826\" xlink:href=\"#m88d39fb814\" y=\"115.364833\"/>\n",
       "     <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"264.333395\" xlink:href=\"#m88d39fb814\" y=\"45.545102\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_2\">\n",
       "    <defs>\n",
       "     <path d=\"M 0 2.5 \n",
       "C 0.663008 2.5 1.29895 2.236584 1.767767 1.767767 \n",
       "C 2.236584 1.29895 2.5 0.663008 2.5 0 \n",
       "C 2.5 -0.663008 2.236584 -1.29895 1.767767 -1.767767 \n",
       "C 1.29895 -2.236584 0.663008 -2.5 0 -2.5 \n",
       "C -0.663008 -2.5 -1.29895 -2.236584 -1.767767 -1.767767 \n",
       "C -2.236584 -1.29895 -2.5 -0.663008 -2.5 0 \n",
       "C -2.5 0.663008 -2.236584 1.29895 -1.767767 1.767767 \n",
       "C -1.29895 2.236584 -0.663008 2.5 0 2.5 \n",
       "z\n",
       "\" id=\"mb4796374c8\" style=\"stroke:#1a1a1a;\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p00aa67d2f8)\">\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"90.413841\" xlink:href=\"#mb4796374c8\" y=\"78.20176\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"71.628331\" xlink:href=\"#mb4796374c8\" y=\"175.077045\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"95.714515\" xlink:href=\"#mb4796374c8\" y=\"92.741683\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"135.719716\" xlink:href=\"#mb4796374c8\" y=\"139.819649\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"355.666021\" xlink:href=\"#mb4796374c8\" y=\"191.170236\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"265.363277\" xlink:href=\"#mb4796374c8\" y=\"212.80491\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"111.701795\" xlink:href=\"#mb4796374c8\" y=\"83.844255\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"234.753393\" xlink:href=\"#mb4796374c8\" y=\"167.176014\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"232.263523\" xlink:href=\"#mb4796374c8\" y=\"178.076031\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"159.332956\" xlink:href=\"#mb4796374c8\" y=\"160.996044\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"88.631\" xlink:href=\"#mb4796374c8\" y=\"174.184266\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"343.76666\" xlink:href=\"#mb4796374c8\" y=\"189.537016\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"208.259102\" xlink:href=\"#mb4796374c8\" y=\"157.021379\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"108.442185\" xlink:href=\"#mb4796374c8\" y=\"115.183902\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"166.147241\" xlink:href=\"#mb4796374c8\" y=\"120.486281\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"114.727587\" xlink:href=\"#mb4796374c8\" y=\"97.664825\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"177.093496\" xlink:href=\"#mb4796374c8\" y=\"151.464332\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"87.346446\" xlink:href=\"#mb4796374c8\" y=\"19.03509\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"264.391264\" xlink:href=\"#mb4796374c8\" y=\"181.66673\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"88.507895\" xlink:href=\"#mb4796374c8\" y=\"86.11243\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"163.720475\" xlink:href=\"#mb4796374c8\" y=\"166.671576\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"297.2219\" xlink:href=\"#mb4796374c8\" y=\"184.3779\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"161.55486\" xlink:href=\"#mb4796374c8\" y=\"169.605362\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"209.959086\" xlink:href=\"#mb4796374c8\" y=\"151.898314\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"89.984391\" xlink:href=\"#mb4796374c8\" y=\"128.238874\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"158.257478\" xlink:href=\"#mb4796374c8\" y=\"158.303133\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"155.22621\" xlink:href=\"#mb4796374c8\" y=\"129.906153\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"81.549594\" xlink:href=\"#mb4796374c8\" y=\"28.319328\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"93.28326\" xlink:href=\"#mb4796374c8\" y=\"166.205436\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"184.104953\" xlink:href=\"#mb4796374c8\" y=\"188.229054\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"70.641232\" xlink:href=\"#mb4796374c8\" y=\"158.903649\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"133.922074\" xlink:href=\"#mb4796374c8\" y=\"111.055652\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"228.750097\" xlink:href=\"#mb4796374c8\" y=\"183.032923\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"152.999323\" xlink:href=\"#mb4796374c8\" y=\"152.402933\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"82.180404\" xlink:href=\"#mb4796374c8\" y=\"176.745553\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"202.304801\" xlink:href=\"#mb4796374c8\" y=\"179.0128\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"296.606428\" xlink:href=\"#mb4796374c8\" y=\"178.412556\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"122.69132\" xlink:href=\"#mb4796374c8\" y=\"75.87397\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"167.186907\" xlink:href=\"#mb4796374c8\" y=\"127.179672\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"180.762521\" xlink:href=\"#mb4796374c8\" y=\"198.705101\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 53.31 224.64 \n",
       "L 53.31 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 388.11 224.64 \n",
       "L 388.11 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 53.31 224.64 \n",
       "L 388.11 224.64 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 53.31 7.2 \n",
       "L 388.11 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 61.01 219.14 \n",
       "L 169.631563 219.14 \n",
       "Q 171.831563 219.14 171.831563 216.94 \n",
       "L 171.831563 185.748125 \n",
       "Q 171.831563 183.548125 169.631563 183.548125 \n",
       "L 61.01 183.548125 \n",
       "Q 58.81 183.548125 58.81 185.748125 \n",
       "L 58.81 216.94 \n",
       "Q 58.81 219.14 61.01 219.14 \n",
       "z\n",
       "\" style=\"fill:#ffffff;opacity:0.8;stroke:#cccccc;stroke-linejoin:miter;\"/>\n",
       "    </g>\n",
       "    <g id=\"PathCollection_3\">\n",
       "     <g>\n",
       "      <use style=\"stroke:#000000;stroke-width:1.5;\" x=\"74.21\" xlink:href=\"#m88d39fb814\" y=\"193.418906\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_19\">\n",
       "     <!-- Admitted -->\n",
       "     <defs>\n",
       "      <path d=\"M 34.1875 63.1875 \n",
       "L 20.796875 26.90625 \n",
       "L 47.609375 26.90625 \n",
       "z\n",
       "M 28.609375 72.90625 \n",
       "L 39.796875 72.90625 \n",
       "L 67.578125 0 \n",
       "L 57.328125 0 \n",
       "L 50.6875 18.703125 \n",
       "L 17.828125 18.703125 \n",
       "L 11.1875 0 \n",
       "L 0.78125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-65\"/>\n",
       "      <path d=\"M 45.40625 46.390625 \n",
       "L 45.40625 75.984375 \n",
       "L 54.390625 75.984375 \n",
       "L 54.390625 0 \n",
       "L 45.40625 0 \n",
       "L 45.40625 8.203125 \n",
       "Q 42.578125 3.328125 38.25 0.953125 \n",
       "Q 33.9375 -1.421875 27.875 -1.421875 \n",
       "Q 17.96875 -1.421875 11.734375 6.484375 \n",
       "Q 5.515625 14.40625 5.515625 27.296875 \n",
       "Q 5.515625 40.1875 11.734375 48.09375 \n",
       "Q 17.96875 56 27.875 56 \n",
       "Q 33.9375 56 38.25 53.625 \n",
       "Q 42.578125 51.265625 45.40625 46.390625 \n",
       "z\n",
       "M 14.796875 27.296875 \n",
       "Q 14.796875 17.390625 18.875 11.75 \n",
       "Q 22.953125 6.109375 30.078125 6.109375 \n",
       "Q 37.203125 6.109375 41.296875 11.75 \n",
       "Q 45.40625 17.390625 45.40625 27.296875 \n",
       "Q 45.40625 37.203125 41.296875 42.84375 \n",
       "Q 37.203125 48.484375 30.078125 48.484375 \n",
       "Q 22.953125 48.484375 18.875 42.84375 \n",
       "Q 14.796875 37.203125 14.796875 27.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-100\"/>\n",
       "      <path d=\"M 9.421875 54.6875 \n",
       "L 18.40625 54.6875 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 64.59375 \n",
       "L 9.421875 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-105\"/>\n",
       "      <path d=\"M 18.3125 70.21875 \n",
       "L 18.3125 54.6875 \n",
       "L 36.8125 54.6875 \n",
       "L 36.8125 47.703125 \n",
       "L 18.3125 47.703125 \n",
       "L 18.3125 18.015625 \n",
       "Q 18.3125 11.328125 20.140625 9.421875 \n",
       "Q 21.96875 7.515625 27.59375 7.515625 \n",
       "L 36.8125 7.515625 \n",
       "L 36.8125 0 \n",
       "L 27.59375 0 \n",
       "Q 17.1875 0 13.234375 3.875 \n",
       "Q 9.28125 7.765625 9.28125 18.015625 \n",
       "L 9.28125 47.703125 \n",
       "L 2.6875 47.703125 \n",
       "L 2.6875 54.6875 \n",
       "L 9.28125 54.6875 \n",
       "L 9.28125 70.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-116\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(94.01 196.306406)scale(0.11 -0.11)\">\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"68.392578\" xlink:href=\"#DejaVuSans-100\"/>\n",
       "      <use x=\"131.869141\" xlink:href=\"#DejaVuSans-109\"/>\n",
       "      <use x=\"229.28125\" xlink:href=\"#DejaVuSans-105\"/>\n",
       "      <use x=\"257.064453\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"296.273438\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"335.482422\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "      <use x=\"397.005859\" xlink:href=\"#DejaVuSans-100\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"PathCollection_4\">\n",
       "     <g>\n",
       "      <use style=\"fill:#fffe7a;stroke:#1a1a1a;\" x=\"74.21\" xlink:href=\"#mb4796374c8\" y=\"209.564844\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_20\">\n",
       "     <!-- Not Admitted -->\n",
       "     <defs>\n",
       "      <path d=\"M 9.8125 72.90625 \n",
       "L 23.09375 72.90625 \n",
       "L 55.421875 11.921875 \n",
       "L 55.421875 72.90625 \n",
       "L 64.984375 72.90625 \n",
       "L 64.984375 0 \n",
       "L 51.703125 0 \n",
       "L 19.390625 60.984375 \n",
       "L 19.390625 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-78\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(94.01 212.452344)scale(0.11 -0.11)\">\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\n",
       "      <use x=\"74.804688\" xlink:href=\"#DejaVuSans-111\"/>\n",
       "      <use x=\"135.986328\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"175.195312\" xlink:href=\"#DejaVuSans-32\"/>\n",
       "      <use x=\"206.982422\" xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use x=\"275.375\" xlink:href=\"#DejaVuSans-100\"/>\n",
       "      <use x=\"338.851562\" xlink:href=\"#DejaVuSans-109\"/>\n",
       "      <use x=\"436.263672\" xlink:href=\"#DejaVuSans-105\"/>\n",
       "      <use x=\"464.046875\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"503.255859\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"542.464844\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "      <use x=\"603.988281\" xlink:href=\"#DejaVuSans-100\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p00aa67d2f8\">\n",
       "   <rect height=\"217.44\" width=\"334.8\" x=\"53.31\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "print('Plotting data with + indicating (y = 1) examples and o indicating (y = 0) examples.')\n",
    "\"\"\"\n",
    "Example plotting for multiple markers\n",
    "x = np.array([1,2,3,4,5,6])\n",
    "y = np.array([1,3,4,5,6,7])\n",
    "m = np.array(['o','+','+','o','x','+'])\n",
    "\n",
    "unique_markers = set(m)  # or yo can use: np.unique(m)\n",
    "\n",
    "for um in unique_markers:\n",
    "    mask = m == um \n",
    "    # mask is now an array of booleans that van be used for indexing  \n",
    "    plt.scatter(x[mask], y[mask], marker=um)\n",
    "\"\"\"\n",
    "fig, ax = plt.subplots()\n",
    "y_slim = y.ravel()\n",
    "# plotting y=1 values\n",
    "ax.scatter(x=X[y_slim == 1, 0], y=X[y_slim == 1, 1], marker='+', c='black', s=50, label='Admitted')\n",
    "# plotting y=0 values\n",
    "# X[y_slim == 0, 0] is logical indexing with rows with y=0 only\n",
    "ax.scatter(x=X[y_slim == 0, 0], y=X[y_slim == 0, 1], marker='o', c='xkcd:light yellow', s=25, label='Not Admitted', edgecolor='k')\n",
    "\n",
    "# labels\n",
    "ax.set_xlabel('Exam 1 score')\n",
    "ax.set_ylabel('Exam 2 score')\n",
    "\n",
    "# Specified in plot order\n",
    "ax.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Implementation\n",
    "\n",
    "### Sigmoid function\n",
    "\n",
    "The logistic regression hypothesis is defined as:\n",
    "\n",
    "$$\n",
    "h_{\\theta}\\left( x \\right) = g\\left( \\theta^{T}x \\right)\n",
    "$$\n",
    "\n",
    "where function g is the sigmoid function. The sigmoid function is defined as:\n",
    "\n",
    "$$\n",
    "g\\left( z \\right) = \\frac{1}{1+\\epsilon^{-z}}\n",
    "$$\n",
    "\n",
    "We have implemented the above function in \"sigmoid()\" function so it can be called by the rest of your program. Lets try testing a few\n",
    "values by calling sigmoid(x) below.\n",
    "\n",
    "For large positive values of x, the sigmoid should be close to 1, while for large negative values, the sigmoid should be close to 0. Evaluating sigmoid(0) should give you exactly 0.5. Our code should also work with vectors and matrices. For a matrix, our function should perform the sigmoid function on every element."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sigmoid(99) = 1.000000\n",
      "Sigmoid(0) = 0.500000\n",
      "Sigmoid(-99) = 0.000000\n"
     ]
    }
   ],
   "source": [
    "print(\"Sigmoid(99) = {:.6f}\".format(sigmoid(99)))\n",
    "print(\"Sigmoid(0) = {:.6f}\".format(sigmoid(0)))\n",
    "print(\"Sigmoid(-99) = {:.6f}\".format(sigmoid(-99)))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cost Function and Gradient\n",
    "\n",
    "The cost function for logistic regression is:\n",
    "\n",
    "$$\n",
    "J(\\theta) = \\frac{1}{m}\\sum_{i=1}^{m}\\left[ -y^{(i)} \\log\\left( h_{\\theta} \\left( x^{(i)} \\right) \\right) - \\left( 1 - y^{(i)} \\right) \\log \\left( 1 - h_{\\theta} \\left( x^{(i)} \\right) \\right) \\right]\n",
    "$$\n",
    "\n",
    "and the gradient of cost is a vector of the sma elength as $\\theta$ where $j^{th}$ element (for j = 0,1,...,n) is defined as follows:\n",
    "\n",
    "$$\n",
    "\\frac{\\delta J(\\theta)}{\\delta \\theta_{j}} = \\frac{1}{m} \\sum_{i=1}^{m} \\left( h_{\\theta} \\left( x^{(i)} \\right) - y^{(i)} \\right)x_{j}^{(i)}\n",
    "$$\n",
    "\n",
    "Note that while this gradient looks identical to the linear regression gradient, the formula is actually different because linear and logistic regression have different definitions of hθ(x)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost at initial theta (zeros): [[0.69314718]]\n",
      "Expected cost (approx): 0.693\n",
      "Gradient at initial theta (zeros): \n",
      "[ -0.1        -12.00921659 -11.26284221]\n",
      "Expected gradients (approx):[ -0.1000 -12.0092 -11.2628]\n"
     ]
    }
   ],
   "source": [
    "# initial sizes\n",
    "m, n = X.shape\n",
    "\n",
    "# adding bias unit\n",
    "X = add_bias_unit(X)\n",
    "\n",
    "# Initialize fitting parameters\n",
    "initial_theta = np.zeros([n + 1, 1])\n",
    "\n",
    "# Compute and display initial cost and gradient\n",
    "cost = cost_function(initial_theta, X, y, regularized=False)\n",
    "grad = gradient_function(initial_theta, X, y, regularized=False)\n",
    "print('Cost at initial theta (zeros): {}'.format(cost))\n",
    "print('Expected cost (approx): 0.693')\n",
    "print('Gradient at initial theta (zeros): ')\n",
    "print(grad)\n",
    "print('Expected gradients (approx):[ -0.1000 -12.0092 -11.2628]')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Learning  parameters using scipy.minimize\n",
    "\n",
    "In earlier examples, we found the optimal parameters of a linear regression model by implementing gradent descent. I also wrote a cost function and calculated its gradient, then took a gradient descent step accordingly.\n",
    "\n",
    "This time, instead of taking gradient descent steps, we will use an function called minimize from scipy.optimize module.\n",
    "\n",
    "The scipy's minimize() function provides a common interface to unconstrained and constrained minimization algorithms for multivariate scalar functions in scipy.optimize.\n",
    "\n",
    "For logistic regression, we need to optimize the cost function J(θ) with parameters θ. Concretely, we are going to use minimize to find the best parameters θ for the logistic regression cost function, given a fixed dataset (of X and y values).\n",
    "You will pass to minimize() the following inputs:\n",
    "- Our predefined cost_function which returns cost while taking X and theta as arguments.\n",
    "- A gradient_function which returns the derivatives of the $\\theta$ values passed to it.\n",
    "- The initial values of the parameters we are trying to optimize.\n",
    "- A function that, when given the training set and a particular θ, computes the logistic regression cost and gradient with respect to θ for the dataset (X, y)\n",
    "- A callbak function which is called after each iteration and the $\\theta$ value obtained after each iteration is passed to it, we are using this callback function to store theta values for each iteration.\n",
    "\n",
    "The minimize() function returns a OptimizeResult object which contains final theta values, function end status, final cost etc.\n",
    "more info about the minimize function can be refered to the documentation <a href=\"https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html\">here</a>."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost at theta found by Gradient descent: 0.2034977015895344\n",
      "Expected cost (approx): 0.203\n",
      "theta: [-25.16135699   0.2062319    0.2014718 ]\n",
      "Expected theta (approx): [-25.161 0.206 0.201]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/mayank/PycharmProjects/machine_learning_implementations_with_numpy/models/logistic_regression.py:70: RuntimeWarning: divide by zero encountered in log\n",
      "  J = (-(y.T @ np.log(h)) - ((1-y.T) @ np.log(1-h)))/m\n",
      "/home/mayank/PycharmProjects/machine_learning_implementations_with_numpy/models/logistic_regression.py:70: RuntimeWarning: invalid value encountered in matmul\n",
      "  J = (-(y.T @ np.log(h)) - ((1-y.T) @ np.log(1-h)))/m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(<Figure size 432x288 with 1 Axes>,\n",
       " <matplotlib.axes._subplots.AxesSubplot at 0x7f4e28ce9588>)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"267.599687pt\" version=\"1.1\" viewBox=\"0 0 397.585866 267.599687\" width=\"397.585866pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 267.599687 \n",
       "L 397.585866 267.599687 \n",
       "L 397.585866 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 53.31 224.64 \n",
       "L 388.11 224.64 \n",
       "L 388.11 7.2 \n",
       "L 53.31 7.2 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 0 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-48\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(65.028807 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 10 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-49\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(114.005921 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 20 -->\n",
       "      <defs>\n",
       "       <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-50\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(166.48241 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 30 -->\n",
       "      <defs>\n",
       "       <path d=\"M 40.578125 39.3125 \n",
       "Q 47.65625 37.796875 51.625 33 \n",
       "Q 55.609375 28.21875 55.609375 21.1875 \n",
       "Q 55.609375 10.40625 48.1875 4.484375 \n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \n",
       "Q 12.796875 0.390625 7.625 2.203125 \n",
       "L 7.625 11.71875 \n",
       "Q 11.71875 9.328125 16.59375 8.109375 \n",
       "Q 21.484375 6.890625 26.8125 6.890625 \n",
       "Q 36.078125 6.890625 40.9375 10.546875 \n",
       "Q 45.796875 14.203125 45.796875 21.1875 \n",
       "Q 45.796875 27.640625 41.28125 31.265625 \n",
       "Q 36.765625 34.90625 28.71875 34.90625 \n",
       "L 20.21875 34.90625 \n",
       "L 20.21875 43.015625 \n",
       "L 29.109375 43.015625 \n",
       "Q 36.375 43.015625 40.234375 45.921875 \n",
       "Q 44.09375 48.828125 44.09375 54.296875 \n",
       "Q 44.09375 59.90625 40.109375 62.90625 \n",
       "Q 36.140625 65.921875 28.71875 65.921875 \n",
       "Q 24.65625 65.921875 20.015625 65.03125 \n",
       "Q 15.375 64.15625 9.8125 62.3125 \n",
       "L 9.8125 71.09375 \n",
       "Q 15.4375 72.65625 20.34375 73.4375 \n",
       "Q 25.25 74.21875 29.59375 74.21875 \n",
       "Q 40.828125 74.21875 47.359375 69.109375 \n",
       "Q 53.90625 64.015625 53.90625 55.328125 \n",
       "Q 53.90625 49.265625 50.4375 45.09375 \n",
       "Q 46.96875 40.921875 40.578125 39.3125 \n",
       "z\n",
       "\" id=\"DejaVuSans-51\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(218.958899 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 40 -->\n",
       "      <defs>\n",
       "       <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-52\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(271.435388 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 50 -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.796875 72.90625 \n",
       "L 49.515625 72.90625 \n",
       "L 49.515625 64.59375 \n",
       "L 19.828125 64.59375 \n",
       "L 19.828125 46.734375 \n",
       "Q 21.96875 47.46875 24.109375 47.828125 \n",
       "Q 26.265625 48.1875 28.421875 48.1875 \n",
       "Q 40.625 48.1875 47.75 41.5 \n",
       "Q 54.890625 34.8125 54.890625 23.390625 \n",
       "Q 54.890625 11.625 47.5625 5.09375 \n",
       "Q 40.234375 -1.421875 26.90625 -1.421875 \n",
       "Q 22.3125 -1.421875 17.546875 -0.640625 \n",
       "Q 12.796875 0.140625 7.71875 1.703125 \n",
       "L 7.71875 11.625 \n",
       "Q 12.109375 9.234375 16.796875 8.0625 \n",
       "Q 21.484375 6.890625 26.703125 6.890625 \n",
       "Q 35.15625 6.890625 40.078125 11.328125 \n",
       "Q 45.015625 15.765625 45.015625 23.390625 \n",
       "Q 45.015625 31 40.078125 35.4375 \n",
       "Q 35.15625 39.890625 26.703125 39.890625 \n",
       "Q 22.75 39.890625 18.8125 39.015625 \n",
       "Q 14.890625 38.140625 10.796875 36.28125 \n",
       "z\n",
       "\" id=\"DejaVuSans-53\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(323.911877 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 60 -->\n",
       "      <defs>\n",
       "       <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-54\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(376.388366 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-54\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_8\">\n",
       "     <!-- Iterations -->\n",
       "     <defs>\n",
       "      <path d=\"M 9.8125 72.90625 \n",
       "L 19.671875 72.90625 \n",
       "L 19.671875 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-73\"/>\n",
       "      <path d=\"M 18.3125 70.21875 \n",
       "L 18.3125 54.6875 \n",
       "L 36.8125 54.6875 \n",
       "L 36.8125 47.703125 \n",
       "L 18.3125 47.703125 \n",
       "L 18.3125 18.015625 \n",
       "Q 18.3125 11.328125 20.140625 9.421875 \n",
       "Q 21.96875 7.515625 27.59375 7.515625 \n",
       "L 36.8125 7.515625 \n",
       "L 36.8125 0 \n",
       "L 27.59375 0 \n",
       "Q 17.1875 0 13.234375 3.875 \n",
       "Q 9.28125 7.765625 9.28125 18.015625 \n",
       "L 9.28125 47.703125 \n",
       "L 2.6875 47.703125 \n",
       "L 2.6875 54.6875 \n",
       "L 9.28125 54.6875 \n",
       "L 9.28125 70.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-116\"/>\n",
       "      <path d=\"M 56.203125 29.59375 \n",
       "L 56.203125 25.203125 \n",
       "L 14.890625 25.203125 \n",
       "Q 15.484375 15.921875 20.484375 11.0625 \n",
       "Q 25.484375 6.203125 34.421875 6.203125 \n",
       "Q 39.59375 6.203125 44.453125 7.46875 \n",
       "Q 49.3125 8.734375 54.109375 11.28125 \n",
       "L 54.109375 2.78125 \n",
       "Q 49.265625 0.734375 44.1875 -0.34375 \n",
       "Q 39.109375 -1.421875 33.890625 -1.421875 \n",
       "Q 20.796875 -1.421875 13.15625 6.1875 \n",
       "Q 5.515625 13.8125 5.515625 26.8125 \n",
       "Q 5.515625 40.234375 12.765625 48.109375 \n",
       "Q 20.015625 56 32.328125 56 \n",
       "Q 43.359375 56 49.78125 48.890625 \n",
       "Q 56.203125 41.796875 56.203125 29.59375 \n",
       "z\n",
       "M 47.21875 32.234375 \n",
       "Q 47.125 39.59375 43.09375 43.984375 \n",
       "Q 39.0625 48.390625 32.421875 48.390625 \n",
       "Q 24.90625 48.390625 20.390625 44.140625 \n",
       "Q 15.875 39.890625 15.1875 32.171875 \n",
       "z\n",
       "\" id=\"DejaVuSans-101\"/>\n",
       "      <path d=\"M 41.109375 46.296875 \n",
       "Q 39.59375 47.171875 37.8125 47.578125 \n",
       "Q 36.03125 48 33.890625 48 \n",
       "Q 26.265625 48 22.1875 43.046875 \n",
       "Q 18.109375 38.09375 18.109375 28.8125 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 20.953125 51.171875 25.484375 53.578125 \n",
       "Q 30.03125 56 36.53125 56 \n",
       "Q 37.453125 56 38.578125 55.875 \n",
       "Q 39.703125 55.765625 41.0625 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-114\"/>\n",
       "      <path d=\"M 34.28125 27.484375 \n",
       "Q 23.390625 27.484375 19.1875 25 \n",
       "Q 14.984375 22.515625 14.984375 16.5 \n",
       "Q 14.984375 11.71875 18.140625 8.90625 \n",
       "Q 21.296875 6.109375 26.703125 6.109375 \n",
       "Q 34.1875 6.109375 38.703125 11.40625 \n",
       "Q 43.21875 16.703125 43.21875 25.484375 \n",
       "L 43.21875 27.484375 \n",
       "z\n",
       "M 52.203125 31.203125 \n",
       "L 52.203125 0 \n",
       "L 43.21875 0 \n",
       "L 43.21875 8.296875 \n",
       "Q 40.140625 3.328125 35.546875 0.953125 \n",
       "Q 30.953125 -1.421875 24.3125 -1.421875 \n",
       "Q 15.921875 -1.421875 10.953125 3.296875 \n",
       "Q 6 8.015625 6 15.921875 \n",
       "Q 6 25.140625 12.171875 29.828125 \n",
       "Q 18.359375 34.515625 30.609375 34.515625 \n",
       "L 43.21875 34.515625 \n",
       "L 43.21875 35.40625 \n",
       "Q 43.21875 41.609375 39.140625 45 \n",
       "Q 35.0625 48.390625 27.6875 48.390625 \n",
       "Q 23 48.390625 18.546875 47.265625 \n",
       "Q 14.109375 46.140625 10.015625 43.890625 \n",
       "L 10.015625 52.203125 \n",
       "Q 14.9375 54.109375 19.578125 55.046875 \n",
       "Q 24.21875 56 28.609375 56 \n",
       "Q 40.484375 56 46.34375 49.84375 \n",
       "Q 52.203125 43.703125 52.203125 31.203125 \n",
       "z\n",
       "\" id=\"DejaVuSans-97\"/>\n",
       "      <path d=\"M 9.421875 54.6875 \n",
       "L 18.40625 54.6875 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 64.59375 \n",
       "L 9.421875 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-105\"/>\n",
       "      <path d=\"M 30.609375 48.390625 \n",
       "Q 23.390625 48.390625 19.1875 42.75 \n",
       "Q 14.984375 37.109375 14.984375 27.296875 \n",
       "Q 14.984375 17.484375 19.15625 11.84375 \n",
       "Q 23.34375 6.203125 30.609375 6.203125 \n",
       "Q 37.796875 6.203125 41.984375 11.859375 \n",
       "Q 46.1875 17.53125 46.1875 27.296875 \n",
       "Q 46.1875 37.015625 41.984375 42.703125 \n",
       "Q 37.796875 48.390625 30.609375 48.390625 \n",
       "z\n",
       "M 30.609375 56 \n",
       "Q 42.328125 56 49.015625 48.375 \n",
       "Q 55.71875 40.765625 55.71875 27.296875 \n",
       "Q 55.71875 13.875 49.015625 6.21875 \n",
       "Q 42.328125 -1.421875 30.609375 -1.421875 \n",
       "Q 18.84375 -1.421875 12.171875 6.21875 \n",
       "Q 5.515625 13.875 5.515625 27.296875 \n",
       "Q 5.515625 40.765625 12.171875 48.375 \n",
       "Q 18.84375 56 30.609375 56 \n",
       "z\n",
       "\" id=\"DejaVuSans-111\"/>\n",
       "      <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-110\"/>\n",
       "      <path d=\"M 44.28125 53.078125 \n",
       "L 44.28125 44.578125 \n",
       "Q 40.484375 46.53125 36.375 47.5 \n",
       "Q 32.28125 48.484375 27.875 48.484375 \n",
       "Q 21.1875 48.484375 17.84375 46.4375 \n",
       "Q 14.5 44.390625 14.5 40.28125 \n",
       "Q 14.5 37.15625 16.890625 35.375 \n",
       "Q 19.28125 33.59375 26.515625 31.984375 \n",
       "L 29.59375 31.296875 \n",
       "Q 39.15625 29.25 43.1875 25.515625 \n",
       "Q 47.21875 21.78125 47.21875 15.09375 \n",
       "Q 47.21875 7.46875 41.1875 3.015625 \n",
       "Q 35.15625 -1.421875 24.609375 -1.421875 \n",
       "Q 20.21875 -1.421875 15.453125 -0.5625 \n",
       "Q 10.6875 0.296875 5.421875 2 \n",
       "L 5.421875 11.28125 \n",
       "Q 10.40625 8.6875 15.234375 7.390625 \n",
       "Q 20.0625 6.109375 24.8125 6.109375 \n",
       "Q 31.15625 6.109375 34.5625 8.28125 \n",
       "Q 37.984375 10.453125 37.984375 14.40625 \n",
       "Q 37.984375 18.0625 35.515625 20.015625 \n",
       "Q 33.0625 21.96875 24.703125 23.78125 \n",
       "L 21.578125 24.515625 \n",
       "Q 13.234375 26.265625 9.515625 29.90625 \n",
       "Q 5.8125 33.546875 5.8125 39.890625 \n",
       "Q 5.8125 47.609375 11.28125 51.796875 \n",
       "Q 16.75 56 26.8125 56 \n",
       "Q 31.78125 56 36.171875 55.265625 \n",
       "Q 40.578125 54.546875 44.28125 53.078125 \n",
       "z\n",
       "\" id=\"DejaVuSans-115\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(192.134062 257.904062)scale(0.12 -0.12)\">\n",
       "      <use xlink:href=\"#DejaVuSans-73\"/>\n",
       "      <use x=\"29.492188\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"68.701172\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "      <use x=\"130.224609\" xlink:href=\"#DejaVuSans-114\"/>\n",
       "      <use x=\"171.337891\" xlink:href=\"#DejaVuSans-97\"/>\n",
       "      <use x=\"232.617188\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"271.826172\" xlink:href=\"#DejaVuSans-105\"/>\n",
       "      <use x=\"299.609375\" xlink:href=\"#DejaVuSans-111\"/>\n",
       "      <use x=\"360.791016\" xlink:href=\"#DejaVuSans-110\"/>\n",
       "      <use x=\"424.169922\" xlink:href=\"#DejaVuSans-115\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 0 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(36.81125 218.935736)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 100 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(22.81375 192.051878)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 200 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(22.81375 165.16802)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 300 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(22.81375 138.284161)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 400 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(22.81375 111.400303)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 500 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(22.81375 84.516445)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 600 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(22.81375 57.632586)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-54\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_8\">\n",
       "     <g id=\"text_16\">\n",
       "      <!-- 700 -->\n",
       "      <defs>\n",
       "       <path d=\"M 8.203125 72.90625 \n",
       "L 55.078125 72.90625 \n",
       "L 55.078125 68.703125 \n",
       "L 28.609375 0 \n",
       "L 18.3125 0 \n",
       "L 43.21875 64.59375 \n",
       "L 8.203125 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-55\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(22.81375 30.748728)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-55\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_17\">\n",
       "     <!-- Cost -->\n",
       "     <defs>\n",
       "      <path d=\"M 64.40625 67.28125 \n",
       "L 64.40625 56.890625 \n",
       "Q 59.421875 61.53125 53.78125 63.8125 \n",
       "Q 48.140625 66.109375 41.796875 66.109375 \n",
       "Q 29.296875 66.109375 22.65625 58.46875 \n",
       "Q 16.015625 50.828125 16.015625 36.375 \n",
       "Q 16.015625 21.96875 22.65625 14.328125 \n",
       "Q 29.296875 6.6875 41.796875 6.6875 \n",
       "Q 48.140625 6.6875 53.78125 8.984375 \n",
       "Q 59.421875 11.28125 64.40625 15.921875 \n",
       "L 64.40625 5.609375 \n",
       "Q 59.234375 2.09375 53.4375 0.328125 \n",
       "Q 47.65625 -1.421875 41.21875 -1.421875 \n",
       "Q 24.65625 -1.421875 15.125 8.703125 \n",
       "Q 5.609375 18.84375 5.609375 36.375 \n",
       "Q 5.609375 53.953125 15.125 64.078125 \n",
       "Q 24.65625 74.21875 41.21875 74.21875 \n",
       "Q 47.75 74.21875 53.53125 72.484375 \n",
       "Q 59.328125 70.75 64.40625 67.28125 \n",
       "z\n",
       "\" id=\"DejaVuSans-67\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(16.318125 129.25875)rotate(-90)scale(0.12 -0.12)\">\n",
       "      <use xlink:href=\"#DejaVuSans-67\"/>\n",
       "      <use x=\"69.824219\" xlink:href=\"#DejaVuSans-111\"/>\n",
       "      <use x=\"131.005859\" xlink:href=\"#DejaVuSans-115\"/>\n",
       "      <use x=\"183.105469\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_1\">\n",
       "    <path clip-path=\"url(#p43a3f8ad97)\" d=\"M 68.528182 44.534186 \n",
       "L 73.775831 44.535878 \n",
       "L 79.02348 44.615851 \n",
       "L 84.271129 45.19464 \n",
       "L 89.518777 45.194646 \n",
       "L 94.766426 45.194646 \n",
       "L 100.014075 45.19542 \n",
       "L 105.261724 45.195683 \n",
       "L 110.509373 45.202407 \n",
       "L 115.757022 45.203738 \n",
       "L 121.004671 45.203754 \n",
       "L 126.25232 45.203756 \n",
       "L 131.499969 45.203877 \n",
       "L 136.747618 45.20392 \n",
       "L 141.995266 45.260633 \n",
       "L 147.242915 45.279841 \n",
       "L 152.490564 45.515677 \n",
       "L 157.738213 45.804018 \n",
       "L 162.985862 46.090301 \n",
       "L 168.233511 46.146866 \n",
       "L 173.48116 46.179139 \n",
       "L 178.728809 46.18231 \n",
       "L 183.976458 46.183288 \n",
       "L 189.224107 46.18335 \n",
       "L 194.471755 46.183485 \n",
       "L 199.719404 46.183486 \n",
       "L 204.967053 46.183497 \n",
       "L 210.214702 46.1835 \n",
       "L 215.462351 45.415417 \n",
       "L 220.71 17.397111 \n",
       "L 225.957649 17.396719 \n",
       "L 231.205298 17.396531 \n",
       "L 236.452947 17.396358 \n",
       "L 241.700596 17.39634 \n",
       "L 246.948245 17.396218 \n",
       "L 252.195893 17.39613 \n",
       "L 257.443542 17.231254 \n",
       "L 262.691191 17.090989 \n",
       "L 267.93884 17.084296 \n",
       "L 273.186489 17.084241 \n",
       "L 278.434138 17.084092 \n",
       "L 283.681787 17.083977 \n",
       "L 288.929436 17.083956 \n",
       "L 294.177085 17.083727 \n",
       "L 299.424734 17.083708 \n",
       "L 304.672382 17.083636 \n",
       "L 309.920031 46.12885 \n",
       "L 315.16768 167.229238 \n",
       "L 320.415329 176.015017 \n",
       "L 325.662978 207.130717 \n",
       "L 330.910627 210.08314 \n",
       "L 336.158276 214.463757 \n",
       "L 341.405925 214.658074 \n",
       "L 346.653574 214.747621 \n",
       "L 351.901223 214.748277 \n",
       "L 357.148871 214.752446 \n",
       "L 362.39652 214.753746 \n",
       "L 367.644169 214.756047 \n",
       "L 372.891818 214.756364 \n",
       "\" style=\"fill:none;stroke:#4c72b0;stroke-linecap:round;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 53.31 224.64 \n",
       "L 53.31 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 388.11 224.64 \n",
       "L 388.11 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 53.31 224.64 \n",
       "L 388.11 224.64 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 53.31 7.2 \n",
       "L 388.11 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p43a3f8ad97\">\n",
       "   <rect height=\"217.44\" width=\"334.8\" x=\"53.31\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"251.985937pt\" version=\"1.1\" viewBox=\"0 0 379.652337 251.985937\" width=\"379.652337pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 251.985937 \n",
       "L 379.652337 251.985937 \n",
       "L 379.652337 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 30.6975 224.64 \n",
       "L 365.4975 224.64 \n",
       "L 365.4975 7.2 \n",
       "L 30.6975 7.2 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 30 -->\n",
       "      <defs>\n",
       "       <path d=\"M 40.578125 39.3125 \n",
       "Q 47.65625 37.796875 51.625 33 \n",
       "Q 55.609375 28.21875 55.609375 21.1875 \n",
       "Q 55.609375 10.40625 48.1875 4.484375 \n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \n",
       "Q 12.796875 0.390625 7.625 2.203125 \n",
       "L 7.625 11.71875 \n",
       "Q 11.71875 9.328125 16.59375 8.109375 \n",
       "Q 21.484375 6.890625 26.8125 6.890625 \n",
       "Q 36.078125 6.890625 40.9375 10.546875 \n",
       "Q 45.796875 14.203125 45.796875 21.1875 \n",
       "Q 45.796875 27.640625 41.28125 31.265625 \n",
       "Q 36.765625 34.90625 28.71875 34.90625 \n",
       "L 20.21875 34.90625 \n",
       "L 20.21875 43.015625 \n",
       "L 29.109375 43.015625 \n",
       "Q 36.375 43.015625 40.234375 45.921875 \n",
       "Q 44.09375 48.828125 44.09375 54.296875 \n",
       "Q 44.09375 59.90625 40.109375 62.90625 \n",
       "Q 36.140625 65.921875 28.71875 65.921875 \n",
       "Q 24.65625 65.921875 20.015625 65.03125 \n",
       "Q 15.375 64.15625 9.8125 62.3125 \n",
       "L 9.8125 71.09375 \n",
       "Q 15.4375 72.65625 20.34375 73.4375 \n",
       "Q 25.25 74.21875 29.59375 74.21875 \n",
       "Q 40.828125 74.21875 47.359375 69.109375 \n",
       "Q 53.90625 64.015625 53.90625 55.328125 \n",
       "Q 53.90625 49.265625 50.4375 45.09375 \n",
       "Q 46.96875 40.921875 40.578125 39.3125 \n",
       "z\n",
       "\" id=\"DejaVuSans-51\"/>\n",
       "       <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-48\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(28.093537 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 40 -->\n",
       "      <defs>\n",
       "       <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-52\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(74.788098 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 50 -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.796875 72.90625 \n",
       "L 49.515625 72.90625 \n",
       "L 49.515625 64.59375 \n",
       "L 19.828125 64.59375 \n",
       "L 19.828125 46.734375 \n",
       "Q 21.96875 47.46875 24.109375 47.828125 \n",
       "Q 26.265625 48.1875 28.421875 48.1875 \n",
       "Q 40.625 48.1875 47.75 41.5 \n",
       "Q 54.890625 34.8125 54.890625 23.390625 \n",
       "Q 54.890625 11.625 47.5625 5.09375 \n",
       "Q 40.234375 -1.421875 26.90625 -1.421875 \n",
       "Q 22.3125 -1.421875 17.546875 -0.640625 \n",
       "Q 12.796875 0.140625 7.71875 1.703125 \n",
       "L 7.71875 11.625 \n",
       "Q 12.109375 9.234375 16.796875 8.0625 \n",
       "Q 21.484375 6.890625 26.703125 6.890625 \n",
       "Q 35.15625 6.890625 40.078125 11.328125 \n",
       "Q 45.015625 15.765625 45.015625 23.390625 \n",
       "Q 45.015625 31 40.078125 35.4375 \n",
       "Q 35.15625 39.890625 26.703125 39.890625 \n",
       "Q 22.75 39.890625 18.8125 39.015625 \n",
       "Q 14.890625 38.140625 10.796875 36.28125 \n",
       "z\n",
       "\" id=\"DejaVuSans-53\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(121.482659 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 60 -->\n",
       "      <defs>\n",
       "       <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-54\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(168.177219 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-54\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 70 -->\n",
       "      <defs>\n",
       "       <path d=\"M 8.203125 72.90625 \n",
       "L 55.078125 72.90625 \n",
       "L 55.078125 68.703125 \n",
       "L 28.609375 0 \n",
       "L 18.3125 0 \n",
       "L 43.21875 64.59375 \n",
       "L 8.203125 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-55\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(214.87178 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-55\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 80 -->\n",
       "      <defs>\n",
       "       <path d=\"M 31.78125 34.625 \n",
       "Q 24.75 34.625 20.71875 30.859375 \n",
       "Q 16.703125 27.09375 16.703125 20.515625 \n",
       "Q 16.703125 13.921875 20.71875 10.15625 \n",
       "Q 24.75 6.390625 31.78125 6.390625 \n",
       "Q 38.8125 6.390625 42.859375 10.171875 \n",
       "Q 46.921875 13.96875 46.921875 20.515625 \n",
       "Q 46.921875 27.09375 42.890625 30.859375 \n",
       "Q 38.875 34.625 31.78125 34.625 \n",
       "z\n",
       "M 21.921875 38.8125 \n",
       "Q 15.578125 40.375 12.03125 44.71875 \n",
       "Q 8.5 49.078125 8.5 55.328125 \n",
       "Q 8.5 64.0625 14.71875 69.140625 \n",
       "Q 20.953125 74.21875 31.78125 74.21875 \n",
       "Q 42.671875 74.21875 48.875 69.140625 \n",
       "Q 55.078125 64.0625 55.078125 55.328125 \n",
       "Q 55.078125 49.078125 51.53125 44.71875 \n",
       "Q 48 40.375 41.703125 38.8125 \n",
       "Q 48.828125 37.15625 52.796875 32.3125 \n",
       "Q 56.78125 27.484375 56.78125 20.515625 \n",
       "Q 56.78125 9.90625 50.3125 4.234375 \n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.25 4.234375 \n",
       "Q 6.78125 9.90625 6.78125 20.515625 \n",
       "Q 6.78125 27.484375 10.78125 32.3125 \n",
       "Q 14.796875 37.15625 21.921875 38.8125 \n",
       "z\n",
       "M 18.3125 54.390625 \n",
       "Q 18.3125 48.734375 21.84375 45.5625 \n",
       "Q 25.390625 42.390625 31.78125 42.390625 \n",
       "Q 38.140625 42.390625 41.71875 45.5625 \n",
       "Q 45.3125 48.734375 45.3125 54.390625 \n",
       "Q 45.3125 60.0625 41.71875 63.234375 \n",
       "Q 38.140625 66.40625 31.78125 66.40625 \n",
       "Q 25.390625 66.40625 21.84375 63.234375 \n",
       "Q 18.3125 60.0625 18.3125 54.390625 \n",
       "z\n",
       "\" id=\"DejaVuSans-56\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(261.566341 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-56\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 90 -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.984375 1.515625 \n",
       "L 10.984375 10.5 \n",
       "Q 14.703125 8.734375 18.5 7.8125 \n",
       "Q 22.3125 6.890625 25.984375 6.890625 \n",
       "Q 35.75 6.890625 40.890625 13.453125 \n",
       "Q 46.046875 20.015625 46.78125 33.40625 \n",
       "Q 43.953125 29.203125 39.59375 26.953125 \n",
       "Q 35.25 24.703125 29.984375 24.703125 \n",
       "Q 19.046875 24.703125 12.671875 31.3125 \n",
       "Q 6.296875 37.9375 6.296875 49.421875 \n",
       "Q 6.296875 60.640625 12.9375 67.421875 \n",
       "Q 19.578125 74.21875 30.609375 74.21875 \n",
       "Q 43.265625 74.21875 49.921875 64.515625 \n",
       "Q 56.59375 54.828125 56.59375 36.375 \n",
       "Q 56.59375 19.140625 48.40625 8.859375 \n",
       "Q 40.234375 -1.421875 26.421875 -1.421875 \n",
       "Q 22.703125 -1.421875 18.890625 -0.6875 \n",
       "Q 15.09375 0.046875 10.984375 1.515625 \n",
       "z\n",
       "M 30.609375 32.421875 \n",
       "Q 37.25 32.421875 41.125 36.953125 \n",
       "Q 45.015625 41.5 45.015625 49.421875 \n",
       "Q 45.015625 57.28125 41.125 61.84375 \n",
       "Q 37.25 66.40625 30.609375 66.40625 \n",
       "Q 23.96875 66.40625 20.09375 61.84375 \n",
       "Q 16.21875 57.28125 16.21875 49.421875 \n",
       "Q 16.21875 41.5 20.09375 36.953125 \n",
       "Q 23.96875 32.421875 30.609375 32.421875 \n",
       "z\n",
       "\" id=\"DejaVuSans-57\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(308.260901 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-57\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 100 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-49\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(351.456087 242.498281)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 30 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 227.590274)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 40 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 196.615915)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 50 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 165.641556)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 60 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 134.667197)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-54\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 70 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 103.692838)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-55\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 80 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 72.718479)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-56\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 90 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 41.74412)scale(0.11 -0.11)\">\n",
       "       <use xlink:href=\"#DejaVuSans-57\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\">\n",
       "    <defs>\n",
       "     <path d=\"M -3 0 \n",
       "L 3 0 \n",
       "M 0 3 \n",
       "L 0 -3 \n",
       "\" id=\"me236a21a04\" style=\"stroke:#c44e52;stroke-width:1.5;\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p1f1bb4c6fd)\">\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"176.028609\" xlink:href=\"#me236a21a04\" y=\"48.999003\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"264.048494\" xlink:href=\"#me236a21a04\" y=\"82.959834\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"180.343491\" xlink:href=\"#me236a21a04\" y=\"17.396255\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"245.333359\" xlink:href=\"#me236a21a04\" y=\"172.136138\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"250.348546\" xlink:href=\"#me236a21a04\" y=\"45.554599\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"289.263949\" xlink:href=\"#me236a21a04\" y=\"181.492315\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"279.337775\" xlink:href=\"#me236a21a04\" y=\"79.436232\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"218.903505\" xlink:href=\"#me236a21a04\" y=\"13.656826\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"147.024062\" xlink:href=\"#me236a21a04\" y=\"40.020162\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"217.528608\" xlink:href=\"#me236a21a04\" y=\"152.973986\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"224.95942\" xlink:href=\"#me236a21a04\" y=\"28.498357\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"254.457654\" xlink:href=\"#me236a21a04\" y=\"168.970713\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"313.75037\" xlink:href=\"#me236a21a04\" y=\"112.524892\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"258.871727\" xlink:href=\"#me236a21a04\" y=\"102.696746\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"185.780368\" xlink:href=\"#me236a21a04\" y=\"99.654761\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"269.453131\" xlink:href=\"#me236a21a04\" y=\"177.502088\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"181.616501\" xlink:href=\"#me236a21a04\" y=\"90.816446\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"293.801256\" xlink:href=\"#me236a21a04\" y=\"139.619347\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"138.032336\" xlink:href=\"#me236a21a04\" y=\"101.270377\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"194.680235\" xlink:href=\"#me236a21a04\" y=\"65.726679\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"286.787146\" xlink:href=\"#me236a21a04\" y=\"141.923647\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"336.007762\" xlink:href=\"#me236a21a04\" y=\"113.238679\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"255.45809\" xlink:href=\"#me236a21a04\" y=\"98.094452\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"351.548793\" xlink:href=\"#me236a21a04\" y=\"47.70034\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"184.85605\" xlink:href=\"#me236a21a04\" y=\"16.598981\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"322.567231\" xlink:href=\"#me236a21a04\" y=\"41.60313\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"268.30742\" xlink:href=\"#me236a21a04\" y=\"86.618702\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"358.557308\" xlink:href=\"#me236a21a04\" y=\"127.393622\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"317.812509\" xlink:href=\"#me236a21a04\" y=\"181.934603\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"350.960603\" xlink:href=\"#me236a21a04\" y=\"103.039903\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"241.709608\" xlink:href=\"#me236a21a04\" y=\"100.057077\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"230.259031\" xlink:href=\"#me236a21a04\" y=\"73.32933\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"247.065101\" xlink:href=\"#me236a21a04\" y=\"50.698304\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"83.923362\" xlink:href=\"#me236a21a04\" y=\"14.225225\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"269.870549\" xlink:href=\"#me236a21a04\" y=\"31.010617\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"206.679475\" xlink:href=\"#me236a21a04\" y=\"127.417277\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"194.037398\" xlink:href=\"#me236a21a04\" y=\"74.636059\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"232.827382\" xlink:href=\"#me236a21a04\" y=\"18.275409\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"177.314047\" xlink:href=\"#me236a21a04\" y=\"89.927139\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"169.763865\" xlink:href=\"#me236a21a04\" y=\"81.367529\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"361.150401\" xlink:href=\"#me236a21a04\" y=\"92.175091\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"115.707033\" xlink:href=\"#me236a21a04\" y=\"42.28589\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"130.620766\" xlink:href=\"#me236a21a04\" y=\"81.51803\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"310.188138\" xlink:href=\"#me236a21a04\" y=\"100.121449\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"337.834168\" xlink:href=\"#me236a21a04\" y=\"174.799024\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"209.35292\" xlink:href=\"#me236a21a04\" y=\"110.077957\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"162.28223\" xlink:href=\"#me236a21a04\" y=\"131.992537\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"270.277642\" xlink:href=\"#me236a21a04\" y=\"34.590983\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"214.71936\" xlink:href=\"#me236a21a04\" y=\"51.211331\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"247.448419\" xlink:href=\"#me236a21a04\" y=\"36.249997\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"262.193265\" xlink:href=\"#me236a21a04\" y=\"16.975\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"334.377951\" xlink:href=\"#me236a21a04\" y=\"77.338828\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"317.35414\" xlink:href=\"#me236a21a04\" y=\"45.281337\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"242.84896\" xlink:href=\"#me236a21a04\" y=\"53.531838\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"314.539652\" xlink:href=\"#me236a21a04\" y=\"175.839834\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"284.857583\" xlink:href=\"#me236a21a04\" y=\"166.479376\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"92.34776\" xlink:href=\"#me236a21a04\" y=\"46.535616\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"358.755676\" xlink:href=\"#me236a21a04\" y=\"103.306788\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"153.416386\" xlink:href=\"#me236a21a04\" y=\"115.211695\"/>\n",
       "     <use style=\"fill:#c44e52;stroke:#c44e52;stroke-width:1.5;\" x=\"244.171352\" xlink:href=\"#me236a21a04\" y=\"39.021354\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_2\">\n",
       "    <defs>\n",
       "     <path d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" id=\"med336ec8fa\" style=\"stroke:#000000;\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#p1f1bb4c6fd)\">\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"56.682263\" xlink:href=\"#med336ec8fa\" y=\"74.657726\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"36.431071\" xlink:href=\"#med336ec8fa\" y=\"180.372269\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"62.396506\" xlink:href=\"#med336ec8fa\" y=\"90.524325\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"105.522989\" xlink:href=\"#med336ec8fa\" y=\"141.897859\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"342.629925\" xlink:href=\"#med336ec8fa\" y=\"197.933862\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"245.281587\" xlink:href=\"#med336ec8fa\" y=\"221.542564\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"79.631143\" xlink:href=\"#med336ec8fa\" y=\"80.815063\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"212.283462\" xlink:href=\"#med336ec8fa\" y=\"171.750319\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"209.599328\" xlink:href=\"#med336ec8fa\" y=\"183.644894\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"130.978579\" xlink:href=\"#med336ec8fa\" y=\"165.006466\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"54.760321\" xlink:href=\"#med336ec8fa\" y=\"179.398029\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"329.802153\" xlink:href=\"#med336ec8fa\" y=\"196.151621\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"183.722036\" xlink:href=\"#med336ec8fa\" y=\"160.669138\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"76.117212\" xlink:href=\"#med336ec8fa\" y=\"115.014255\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"138.324527\" xlink:href=\"#med336ec8fa\" y=\"120.800442\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"82.893013\" xlink:href=\"#med336ec8fa\" y=\"95.896673\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"150.12483\" xlink:href=\"#med336ec8fa\" y=\"154.605046\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"53.375543\" xlink:href=\"#med336ec8fa\" y=\"10.092471\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"244.233736\" xlink:href=\"#med336ec8fa\" y=\"187.563222\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"54.627611\" xlink:href=\"#med336ec8fa\" y=\"83.290194\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"135.70842\" xlink:href=\"#med336ec8fa\" y=\"171.199855\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"279.625882\" xlink:href=\"#med336ec8fa\" y=\"190.521769\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"133.373839\" xlink:href=\"#med336ec8fa\" y=\"174.40133\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"185.554656\" xlink:href=\"#med336ec8fa\" y=\"155.078625\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"56.219306\" xlink:href=\"#med336ec8fa\" y=\"129.260411\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"129.81919\" xlink:href=\"#med336ec8fa\" y=\"162.067844\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"126.551416\" xlink:href=\"#med336ec8fa\" y=\"131.079818\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"47.12641\" xlink:href=\"#med336ec8fa\" y=\"20.223837\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"59.775559\" xlink:href=\"#med336ec8fa\" y=\"170.691182\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"157.683335\" xlink:href=\"#med336ec8fa\" y=\"194.724316\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"35.366956\" xlink:href=\"#med336ec8fa\" y=\"162.723153\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"103.585091\" xlink:href=\"#med336ec8fa\" y=\"110.509328\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"205.811778\" xlink:href=\"#med336ec8fa\" y=\"189.054071\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"124.150783\" xlink:href=\"#med336ec8fa\" y=\"155.629287\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"47.806436\" xlink:href=\"#med336ec8fa\" y=\"182.193018\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"177.303169\" xlink:href=\"#med336ec8fa\" y=\"184.667137\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"278.962389\" xlink:href=\"#med336ec8fa\" y=\"184.012125\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"91.478092\" xlink:href=\"#med336ec8fa\" y=\"72.11754\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"139.44531\" xlink:href=\"#med336ec8fa\" y=\"128.104563\"/>\n",
       "     <use style=\"fill:#fffe7a;stroke:#000000;\" x=\"154.080119\" xlink:href=\"#med336ec8fa\" y=\"206.156236\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"LineCollection_1\"/>\n",
       "   <g id=\"LineCollection_2\">\n",
       "    <path clip-path=\"url(#p1f1bb4c6fd)\" d=\"M 30.6975 21.636873 \n",
       "L 329.665777 224.64 \n",
       "L 329.665777 224.64 \n",
       "\" style=\"fill:none;stroke:#0000ff;\"/>\n",
       "   </g>\n",
       "   <g id=\"LineCollection_3\"/>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 30.6975 224.64 \n",
       "L 30.6975 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 365.4975 224.64 \n",
       "L 365.4975 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 30.6975 224.64 \n",
       "L 365.4975 224.64 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 30.6975 7.2 \n",
       "L 365.4975 7.2 \n",
       "\" style=\"fill:none;stroke:#262626;stroke-linecap:square;stroke-linejoin:miter;stroke-width:1.25;\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p1f1bb4c6fd\">\n",
       "   <rect height=\"217.44\" width=\"334.8\" x=\"30.6975\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# =========== Performing gradient descent================\n",
    "X_norm, mu, sigma = feature_normalize(X[:, 1:])\n",
    "X_norm = add_bias_unit(X_norm)\n",
    "\n",
    "from scipy.optimize import minimize\n",
    "\n",
    "theta_history = []  # list to store the thetas after each iteration\n",
    "\n",
    "# defining callback function\n",
    "def log_theta(intermediate_theta, *args):\n",
    "    theta_history.append(intermediate_theta)  # append method does inplace insertion\n",
    "\n",
    "initial_theta = np.zeros(n+1)\n",
    "op_result = minimize(fun=cost_function, x0=initial_theta, jac=gradient_function, args=(X, y, 0.01, False), method='cg', callback=log_theta)\n",
    "\n",
    "print('Cost at theta found by Gradient descent: {}'.format(op_result.fun))\n",
    "print('Expected cost (approx): 0.203')\n",
    "print('theta: {}'.format(op_result.x))\n",
    "print('Expected theta (approx): [-25.161 0.206 0.201]')\n",
    "\n",
    "# converting theta_history(list) into J_history(cost history array)\n",
    "J_history = (np.array(theta_history[::-1]) @ op_result.x)\n",
    "\n",
    "# plot J_history vs iteration\n",
    "fig1, ax1 = plt.subplots()\n",
    "ax1.plot(range(J_history.size), J_history)\n",
    "ax1.set_xlabel('Iterations')\n",
    "ax1.set_ylabel('Cost')\n",
    "\n",
    "theta = op_result.x[:,np.newaxis]  # (n, 1)\n",
    "\n",
    "# plotting decision boundry to visualize the result\n",
    "plot_decision_boundary(theta, X, y, sigmoid, 0.1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Evaluating logistic regression\n",
    "After learning the parameters, you can use the model to predict whether a particular student will be admitted. For a student with an Exam 1 score  of 45 and an Exam 2 score of 85, you should expect to see an admission probability of 0.776.\n",
    "\n",
    "Another way to evaluate the quality of the parameters we have found\n",
    "is to see how well the learned model predicts on our training set. In this method a predict function is defined which will produce “1” or “0” predictions given a dataset and a learned parameter\n",
    "vector θ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For a student with scores 45 and 85, we predict an admission probability of 0.776291\n",
      "Expected value: 0.775 +/- 0.002\n",
      "Train Accuracy: 89.0\n",
      "Expected accuracy (approx): 89.0\n",
      "\n"
     ]
    }
   ],
   "source": [
    "prob = sigmoid(np.array([1, 45, 85]) @ theta)\n",
    "print('For a student with scores 45 and 85, we predict an admission probability of {:.6f}'.format(prob[0]))\n",
    "print('Expected value: 0.775 +/- 0.002')\n",
    "\n",
    "# Compute accuracy on our training set\n",
    "p = predict(X,theta)\n",
    "\n",
    "print('Train Accuracy: {}'.format(np.mean(p == y) * 100))\n",
    "print('Expected accuracy (approx): 89.0\\n')"
   ]
  }
 ],
 "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.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}