You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ML-For-Beginners/2-Regression/4-Logistic/solution/notebook.ipynb

403 lines
4.9 MiB

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
4 years ago
"## Logistic Regression - Lesson 4\n",
"\n",
"Load up required libraries and dataset. Convert the data to a dataframe containing a subset of the data"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
4 years ago
"output_type": "execute_result",
"data": {
"text/plain": [
" City Name Type Package Variety Sub Variety Grade Date \\\n",
"0 BALTIMORE NaN 24 inch bins NaN NaN NaN 4/29/17 \n",
"1 BALTIMORE NaN 24 inch bins NaN NaN NaN 5/6/17 \n",
"2 BALTIMORE NaN 24 inch bins HOWDEN TYPE NaN NaN 9/24/16 \n",
"3 BALTIMORE NaN 24 inch bins HOWDEN TYPE NaN NaN 9/24/16 \n",
"4 BALTIMORE NaN 24 inch bins HOWDEN TYPE NaN NaN 11/5/16 \n",
"\n",
" Low Price High Price Mostly Low ... Unit of Sale Quality Condition \\\n",
"0 270.0 280.0 270.0 ... NaN NaN NaN \n",
"1 270.0 280.0 270.0 ... NaN NaN NaN \n",
"2 160.0 160.0 160.0 ... NaN NaN NaN \n",
"3 160.0 160.0 160.0 ... NaN NaN NaN \n",
"4 90.0 100.0 90.0 ... NaN NaN NaN \n",
"\n",
" Appearance Storage Crop Repack Trans Mode Unnamed: 24 Unnamed: 25 \n",
"0 NaN NaN NaN E NaN NaN NaN \n",
"1 NaN NaN NaN E NaN NaN NaN \n",
"2 NaN NaN NaN N NaN NaN NaN \n",
"3 NaN NaN NaN N NaN NaN NaN \n",
"4 NaN NaN NaN N NaN NaN NaN \n",
"\n",
"[5 rows x 26 columns]"
4 years ago
],
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>City Name</th>\n <th>Type</th>\n <th>Package</th>\n <th>Variety</th>\n <th>Sub Variety</th>\n <th>Grade</th>\n <th>Date</th>\n <th>Low Price</th>\n <th>High Price</th>\n <th>Mostly Low</th>\n <th>...</th>\n <th>Unit of Sale</th>\n <th>Quality</th>\n <th>Condition</th>\n <th>Appearance</th>\n <th>Storage</th>\n <th>Crop</th>\n <th>Repack</th>\n <th>Trans Mode</th>\n <th>Unnamed: 24</th>\n <th>Unnamed: 25</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>24 inch bins</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>4/29/17</td>\n <td>270.0</td>\n <td>280.0</td>\n <td>270.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>E</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>1</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>24 inch bins</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>5/6/17</td>\n <td>270.0</td>\n <td>280.0</td>\n <td>270.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>E</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>2</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>24 inch bins</td>\n <td>HOWDEN TYPE</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>9/24/16</td>\n <td>160.0</td>\n <td>160.0</td>\n <td>160.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>N</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>3</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>24 inch bins</td>\n <td>HOWDEN TYPE</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>9/24/16</td>\n <td>160.0</td>\n <td>160.0</td>\n <td>160.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>N</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>4</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>24 inch bins</td>\n <td>HOWDEN TYPE</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>11/5/16</td>\n <td>90.0</td>\n <td>100.0</td>\n <td>90.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>N</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n </tbody>\n</table>\n<p>5 rows × 26 columns</p>\n</div>"
},
"metadata": {},
4 years ago
"execution_count": 1
}
],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
4 years ago
"pumpkins = pd.read_csv('../../data/US-pumpkins.csv')\n",
"\n",
"pumpkins.head()\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.preprocessing import LabelEncoder\n",
4 years ago
"\n",
"new_columns = ['Color','Origin','Item Size','Variety','City Name','Package']\n",
"\n",
"new_pumpkins = pumpkins.drop([c for c in pumpkins.columns if c not in new_columns], axis=1)\n",
"\n",
"new_pumpkins.dropna(inplace=True)\n",
"\n",
"new_pumpkins = new_pumpkins.apply(LabelEncoder().fit_transform)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check the data shape, size, and quality"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
4 years ago
"output_type": "execute_result",
"data": {
"text/plain": [
"<bound method DataFrame.info of City Name Package Variety Origin Item Size Color\n",
4 years ago
"2 1 3 4 3 3 0\n",
"3 1 3 4 17 3 0\n",
"4 1 3 4 5 2 0\n",
"5 1 3 4 5 2 0\n",
"6 1 4 4 5 3 0\n",
"... ... ... ... ... ... ...\n",
4 years ago
"1694 12 3 5 4 6 1\n",
"1695 12 3 5 4 6 1\n",
"1696 12 3 5 4 6 1\n",
"1697 12 3 5 4 6 1\n",
"1698 12 3 5 4 6 1\n",
"\n",
4 years ago
"[991 rows x 6 columns]>"
]
},
"metadata": {},
4 years ago
"execution_count": 3
}
],
"source": [
"new_pumpkins.info"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
4 years ago
"Working with Item Size to Color, create a scatterplot using Seaborn"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
4 years ago
"output_type": "execute_result",
"data": {
"text/plain": [
4 years ago
"<seaborn.axisgrid.PairGrid at 0x7fa3b8ae2668>"
]
},
"metadata": {},
4 years ago
"execution_count": 4
},
{
4 years ago
"output_type": "display_data",
"data": {
4 years ago
"text/plain": "<Figure size 1080x1080 with 36 Axes>",
"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=\"1058.15625pt\" version=\"1.1\" viewBox=\"0 0 1054.56875 1058.15625\" width=\"1054.56875pt\" 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;white-space:pre;}\n </style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 1058.15625 \nL 1054.56875 1058.15625 \nL 1054.56875 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 43.78125 163.6 \nL 193.702083 163.6 \nL 193.702083 7.2 \nL 43.78125 7.2 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"PathCollection_1\">\n <defs>\n <path d=\"M 0 3 \nC 0.795609 3 1.55874 2.683901 2.12132 2.12132 \nC 2.683901 1.55874 3 0.795609 3 0 \nC 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \nC 1.55874 -2.683901 0.795609 -3 0 -3 \nC -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \nC -2.683901 -1.55874 -3 -0.795609 -3 0 \nC -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \nC -1.55874 2.683901 -0.795609 3 0 3 \nz\n\" id=\"mb4aa9031fa\" style=\"stroke:#ffffff;stroke-width:0.48;\"/>\n </defs>\n <g clip-path=\"url(#pf514e1a819)\">\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"fill:#1f77b4;stroke:#ffffff;stroke-width:0.48;\" x=\"64.453472\" xlink:href=\"#mb4aa9031fa\" y=\"142.142425\"/>\n <use style=\"f
"image/png": "iVBORw0KGgoAAAANSUhEUgAABB4AAAQiCAYAAAAMHj7lAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nOzdfXBcV3rf+d+BCLIhEA3NcEA0KI+X0maoFzQojgurStYvNbZjDWVpSLjKYdmV7G7stZXUZuNxaK/tSVSchKutWideru3NVmJ5/DJev4VljynOizgab/ya2JNgxhTRECVWdkI7I6JBDG12g1BfEFCf/QNAEyC6ge6+5/S9p/v7qUKJRN9+7nPPec69l0fd9xhrrQAAAAAAAHzoSzoBAAAAAADQvZh4AAAAAAAA3jDxAAAAAAAAvGHiAQAAAAAAeMPEAwAAAAAA8Ca4iYfjx49bSfzw4/rHOWqVH08/zlGr/Hj4cY465cfTj3PUKj+efpyjVvnx9FNXcBMPX/va15JOAWgKtYpQUKsIAXWKUFCrCAW1ik4KbuIBAAAAAACEg4kHAAAAAADgDRMPAAAAAADAGyYeAAAAAACAN0w8AAAAAAAAbzoy8WCM+UVjzE1jTGHT7/6FMeZNY8wVY8zvGGMe6kQuAAAAAACgc/Z0aD+/LOlfSvqVTb/7gqSPWWtXjTE/Keljkn68Q/mgy92uRLpWXNJ8eVmj2X06khvUQwOZpNPCfXz0E30PH+LWVaWyopliufb+iVxWAwP9HjNGJyV13uF8B9981Vi5EunNTXEfzw0q22O1G8L4DSFH+OfqHqYjEw/W2j80xhy+73evbfrrn0r67k7kgu53uxLptcKC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"source": [
"import seaborn as sns\n",
"\n",
"g = sns.PairGrid(new_pumpkins)\n",
"g.map(sns.scatterplot)\n"
]
},
{
4 years ago
"cell_type": "code",
"execution_count": 5,
4 years ago
"metadata": {},
"outputs": [
{
"output_type": "stream",
4 years ago
"name": "stderr",
"text": [
4 years ago
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/seaborn/categorical.py:1296: UserWarning: 80.6% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.\n warnings.warn(msg, UserWarning)\n/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/seaborn/categorical.py:1296: UserWarning: 37.2% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot.\n warnings.warn(msg, UserWarning)\n"
]
},
{
4 years ago
"output_type": "execute_result",
"data": {
"text/plain": [
4 years ago
"<matplotlib.axes._subplots.AxesSubplot at 0x7fa3580851d0>"
]
},
"metadata": {},
4 years ago
"execution_count": 5
},
{
4 years ago
"output_type": "display_data",
"data": {
4 years ago
"text/plain": "<Figure size 432x288 with 1 Axes>",
"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=\"262.19625pt\" version=\"1.1\" viewBox=\"0 0 376.240625 262.19625\" width=\"376.240625pt\" 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;white-space:pre;}\n </style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 262.19625 \nL 376.240625 262.19625 \nL 376.240625 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 34.240625 224.64 \nL 369.040625 224.64 \nL 369.040625 7.2 \nL 34.240625 7.2 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <defs>\n <path d=\"M 0 0 \nL 0 3.5 \n\" id=\"mcee3428d9b\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"117.940625\" xlink:href=\"#mcee3428d9b\" y=\"224.64\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- 0 -->\n <defs>\n <path d=\"M 31.78125 66.40625 \nQ 24.171875 66.40625 20.328125 58.90625 \nQ 16.5 51.421875 16.5 36.375 \nQ 16.5 21.390625 20.328125 13.890625 \nQ 24.171875 6.390625 31.78125 6.390625 \nQ 39.453125 6.390625 43.28125 13.890625 \nQ 47.125 21.390625 47.125 36.375 \nQ 47.125 51.421875 43.28125 58.90625 \nQ 39.453125 66.40625 31.78125 66.40625 \nz\nM 31.78125 74.21875 \nQ 44.046875 74.21875 50.515625 64.515625 \nQ 56.984375 54.828125 56.984375 36.375 \nQ 56.984375 17.96875 50.515625 8.265625 \nQ 44.046875 -1.421875 31.78125 -1.421875 \nQ 19.53125 -1.421875 13.0625 8.265625 \nQ 6.59375 17.96875 6.59375 36.375 \nQ 6.59375 54.828125 13.0625 64.515625 \nQ 19.53125 74.21875 31.78125 74.21875 \nz\n\" id=\"DejaVuSans-48\"/>\n </defs>\n <g transform=\"translate(114.759375 239.238437)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-48\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_2\">\n <g id=\"line2d_2\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"285.340625\" xlink:href=\"#mcee3428d9b\" y=\"224.64\"/>\n </g>\n </g>\n <g id=\"text_2\">\n <!-- 1 -->\n <defs>\n <path d=\"M 12.40625 8.296875 \nL 28.515625 8.296875 \nL 28.515625 63.921875 \nL 10.984375 60.40625 \nL 10.984375 69.390625 \nL 28.421875 72.90625 \nL 38.28125 72.90625 \nL 38.28125 8.296875 \nL 54.390625 8.296875 \nL 54.390625 0 \nL 12.40625 0 \nz\n\" id=\"DejaVuSans-49\"/>\n </defs>\n <g transform=\"translate(282.159375 239.238437)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-49\"/>\n </g>\n </g>\n </g>\n <g id=\"text_3\">\n <!-- Color -->\n <defs>\n <path d=\"M 64.40625 67.28125 \nL 64.40625 56.890625 \nQ 59.421875 61.53125 53.78125 63.8125 \nQ 48.140625 66.109375 41.796875 66.109375 \nQ 29.296875 66.109375 22.65625 58.46875 \nQ 16.015625 50.828125 16.015625 36.375 \nQ 16.015625 21.96875 22.65625 14.328125 \nQ 29.296875 6.6875 41.796875 6.6875 \nQ 48.140625 6.6875 53.78125 8.984375 \nQ 59.421875 11.28125 64.40625 15.921875 \nL 64.40625 5.609375 \nQ 59.234375 2.09375 53.4375 0.328125 \nQ 47.65625 -1.421875 41.21875 -1.421875 \nQ 24.65625 -1.421875 15.125 8.703125 \nQ 5.609375 18.84375 5.609375 36.375 \nQ 5.609375 53.953125 15.125 64.078125 \nQ 24.65625 74.21875 41.21875 74.21875 \nQ 47.75 74.21875 53.53125 72.484375 \nQ 59.328125 70.75 64.40625 67.28125 \nz\n\" id=\"DejaVuSans-67\"/>\n <path d=\"M 30.609375 48.390625 \nQ 23.390625 48.390625 19.1875 42.75 \nQ 14.984375 37.109375 14.984375 27.296875 \nQ 14.984375 17.484375 19.15625 11.84375 \nQ 23.34375 6.203125 30.609375 6.203125 \nQ 37.796875 6.203125 41.984375 11.859375 \nQ 46.1875 17.53125 46.1875 27.296875 \nQ 46.1875 37.015625 41.984375 42.703125 \nQ 37.796875 48.390625 30.60
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEGCAYAAABvtY4XAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAL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H7OAN7NuQIK776n5/DXgZ+7+cmP7HGzAi4h0Vk0FfCzX4PsD/zCz/cd5qqlwFxGRthWzgHf3dcD4WPUXEZGm6TdZRUQCSgEvIhJQCngRkYBSwIuIBJQCXkQkoBTwIiIBpYAXEQkoBbyISEAp4EVEAkoBLyISUAp4EZGAUsCLiASUAl5EJKAU8CIiAaWAFxEJKAW8iEhAKeBFRAJKAS8iElAKeBGRgFLAi4gElAJeRCSgFPAiIgGlgBcRCaiYB7yZJZrZx2b2YqyPJSIidZIOwTFuBT4FesbqAFl3zA3bvv74TNbvLiPvi32cP3YA3zn9SErKK7n35VUsWF/IxMx0bj93FOldk3l4/nqeX7yZAT3T+N6Xj2L04T15c+V2/vj2OqrdmXHyUM4bO5A1O/Zw78ur1DOOev761dVh58U7N4xhyJAhsToN40PeInj7LigpgInfgCnXwZ7t8HoObF0Cw06DM38CiSkw715YORf6HAln3wmHDYOlz8KC2ZCUBqd8D4afET89OyFz99g1NzsCeAz4BfB/3P2CpsZnZ2d7bm7uAR3j7c82MP1PK5oc8+OpR7M0r4g5S7bU1s4+uh9njurPj/6xrLbWt3sKj14zmYvvf4+qaq/5P8Dfv30iNz71EVuKSgPecwoX3//v8J43nMiNT8Znz2g23D21ydsDrbQIfjMWyorqal/9E+Q+AhvfratNmg7dB8A7d9fV+o6E8++Dxy+sqyWmwHVvwSPnH3zPqff
},
"metadata": {
"needs_background": "light"
4 years ago
}
}
],
4 years ago
"source": [
"sns.swarmplot(x=\"Color\", y=\"Item Size\", data=new_pumpkins)"
]
},
{
"cell_type": "code",
"execution_count": 6,
4 years ago
"metadata": {},
"outputs": [
{
4 years ago
"output_type": "execute_result",
"data": {
"text/plain": [
4 years ago
"<seaborn.axisgrid.FacetGrid at 0x7fa3e8a91320>"
]
},
"metadata": {},
4 years ago
"execution_count": 6
4 years ago
},
{
4 years ago
"output_type": "display_data",
"data": {
4 years ago
"text/plain": "<Figure size 360x360 with 1 Axes>",
"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=\"366.15625pt\" version=\"1.1\" viewBox=\"0 0 366.470312 366.15625\" width=\"366.470312pt\" 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;white-space:pre;}\n </style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 366.15625 \nL 366.470312 366.15625 \nL 366.470312 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 42.620313 328.6 \nL 359.270312 328.6 \nL 359.270312 7.2 \nL 42.620313 7.2 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"PolyCollection_1\">\n <defs>\n <path d=\"M 122.072034 -52.165341 \nL 121.493591 -52.165341 \nL 121.375819 -55.000167 \nL 121.227151 -57.834992 \nL 121.046341 -60.669818 \nL 120.834389 -63.504644 \nL 120.594591 -66.33947 \nL 120.331957 -69.174296 \nL 120.051876 -72.009121 \nL 119.758106 -74.843947 \nL 119.45037 -77.678773 \nL 119.122081 -80.513599 \nL 118.75887 -83.348424 \nL 118.338621 -86.18325 \nL 117.833506 -89.018076 \nL 117.214174 -91.852902 \nL 116.455645 -94.687728 \nL 115.543896 -97.522553 \nL 114.481643 -100.357379 \nL 113.291582 -103.192205 \nL 112.015627 -106.027031 \nL 110.709303 -108.861856 \nL 109.43161 -111.696682 \nL 108.231883 -114.531508 \nL 107.13636 -117.366334 \nL 106.137791 -120.20116 \nL 105.191355 -123.035985 \nL 104.219132 -125.870811 \nL 103.123658 -128.705637 \nL 101.808838 -131.540463 \nL 100.204437 -134.375288 \nL 98.288812 -137.210114 \nL 96.104251 -140.04494 \nL 93.760286 -142.879766 \nL 91.422659 -145.714592 \nL 89.288817 -148.549417 \nL 87.554104 -151.384243 \nL 86.375416 -154.219069 \nL 85.840226 -157.053895 \nL 85.948148 -159.88872 \nL 86.609674 -162.723546 \nL 87.662933 -165.558372 \nL 88.905156 -168.393198 \nL 90.132143 -171.228024 \nL 91.177109 -174.062849 \nL 91.940483 -176.897675 \nL 92.404383 -179.732501 \nL 92.629056 -182.567327 \nL 92.732757 -185.402152 \nL 92.860196 -188.236978 \nL 93.147082 -191.071804 \nL 93.688876 -193.90663 \nL 94.520493 -196.741455 \nL 95.610864 -199.576281 \nL 96.872649 -202.411107 \nL 98.183854 -205.245933 \nL 99.415544 -208.080759 \nL 100.458725 -210.915584 \nL 101.244092 -213.75041 \nL 101.750356 -216.585236 \nL 101.999858 -219.420062 \nL 102.043314 -222.254887 \nL 101.938159 -225.089713 \nL 101.72646 -227.924539 \nL 101.418401 -230.759365 \nL 100.985978 -233.594191 \nL 100.369006 -236.429016 \nL 99.492492 -239.263842 \nL 98.29144 -242.098668 \nL 96.737062 -244.933494 \nL 94.85756 -247.768319 \nL 92.747538 -250.603145 \nL 90.562422 -253.437971 \nL 88.497764 -256.272797 \nL 86.756927 -259.107623 \nL 85.513809 -261.942448 \nL 84.878843 -264.777274 \nL 84.876249 -267.6121 \nL 85.438219 -270.446926 \nL 86.417982 -273.281751 \nL 87.619355 -276.116577 \nL 88.836553 -278.951403 \nL 89.895643 -281.786229 \nL 90.688686 -284.621055 \nL 91.193334 -287.45588 \nL 91.474101 -290.290706 \nL 91.665642 -293.125532 \nL 91.942351 -295.960358 \nL 92.481351 -298.795183 \nL 93.426942 -301.630009 \nL 94.86371 -304.464835 \nL 96.80302 -307.299661 \nL 99.184309 -310.134487 \nL 101.889318 -312.969312 \nL 104.764869 -315.804138 \nL 107.648648 -318.638964 \nL 110.392687 -321.47379 \nL 112.880605 -324.308615 \nL 115.036708 -327.143441 \nL 116.827049 -329.978267 \nL 118.25412 -332.813093 \nL 125.311505 -332.813093 \nL 125.311505 -332.813093 \nL 126.738576 -329.978267 \nL 128.528917 -327.143441 \nL 130.68502 -324.308615 \nL 133.172938 -321.47379 \nL 135.916977 -318.638964 \nL 138.800756 -315.804138 \nL 141.676307 -312.969312 \nL 144.381316 -310.134487 \nL 146.762605 -307.299661 \nL 148.701915 -304.464835 \nL 150.138683 -301.630009 \nL 151.084274 -298.795183 \nL 151.623274 -295.960358 \nL 151.899983 -293.125532 \nL 152.091524 -290.290706 \nL 152.372291 -287.45588 \nL 152.876939 -
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAFuCAYAAAChovKPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nOzdd3xUVcL/8c+Znt4JJUCAQOhNrKgoYEGwu/Z1H3VFXQtgWVGxrFjW7q7rumtZ19+jz9rbiqKugoKKFOkdAiGN9D595vz+SOJaKAmZmXNn5rxfL15KEu79AuE7d8499xwhpUTTNE2LHibVATRN07Su0cWtaZoWZXRxa5qmRRld3JqmaVFGF7emaVqUsagO0BWnnnqqXLhwoeoYmqZpkSL29cGouuKuqalRHUHTNE25qCpuTdM0TRe3pmla1NHFrWmaFmV0cWuapkUZXdyapmlRRhe3pmlalNHFrWmaFmV0cWuapkUZXdyapmlRRhe3pmlalNHFrWmaFmV0cWuapkWZqFodUNO06NDc3ExRUdEPPxdCUFhYiN1uV5gqduji1jQt5B577DG+/PLLn3zsoosu4uqrr1aUKLbo4tY0LeQ2bVjPqEwv0/u5APi/Hcls3LBBcarYoce4NU0Lqfr6eqpr6xiZ6WN4pp/hmX6GpPnYvn0bwWBQdbyYoItb07SQ2rJlCwD5Kf4fPjYg1Y/L7aG4uFhVrJiirLiFEIVCiDU/+tEkhJit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j744APVcbSDWLFixQ+lPXdsAynd2IIs0nITg9w
},
"metadata": {
"needs_background": "light"
4 years ago
}
}
],
"source": [
4 years ago
"sns.catplot(x=\"Color\", y=\"Item Size\",\n",
" kind=\"violin\", data=new_pumpkins)"
]
},
{
"cell_type": "code",
"execution_count": 7,
4 years ago
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split\n",
"\n",
"Selected_features = ['Origin','Item Size','Variety','City Name','Package']\n",
"\n",
"X = new_pumpkins[Selected_features]\n",
"y = new_pumpkins['Color']\n",
"\n",
"\n",
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
4 years ago
{
"output_type": "stream",
4 years ago
"name": "stdout",
"text": [
" precision recall f1-score support\n",
"\n",
" 0 0.83 0.98 0.90 166\n",
" 1 0.00 0.00 0.00 33\n",
"\n",
" accuracy 0.81 199\n",
" macro avg 0.42 0.49 0.45 199\n",
"weighted avg 0.69 0.81 0.75 199\n",
"\n",
"Predicted labels: [0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0\n",
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0\n",
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 0 0 0 0 0 1 0 0 0 0 0 0 0 0]\n",
4 years ago
"Accuracy: 0.8140703517587939\n",
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/linear_model/logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.\n",
" FutureWarning)\n"
4 years ago
]
4 years ago
}
],
4 years ago
"source": [
4 years ago
"from sklearn.model_selection import train_test_split\n",
"from sklearn.metrics import accuracy_score, classification_report \n",
"from sklearn.linear_model import LogisticRegression\n",
"model = LogisticRegression()\n",
"model.fit(X_train, y_train)\n",
"predictions = model.predict(X_test)\n",
4 years ago
"\n",
"print(classification_report(y_test, predictions))\n",
"print('Predicted labels: ', predictions)\n",
"print('Accuracy: ', accuracy_score(y_test, predictions))\n"
4 years ago
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
4 years ago
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[162, 4],\n",
" [ 33, 0]])"
]
},
"metadata": {},
4 years ago
"execution_count": 9
}
],
"source": [
"from sklearn.metrics import confusion_matrix\n",
"confusion_matrix(y_test, predictions)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"output_type": "stream",
4 years ago
"name": "stderr",
"text": [
4 years ago
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.\n FutureWarning\n/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.\n FutureWarning\n"
]
},
{
4 years ago
"output_type": "execute_result",
"data": {
"text/plain": [
4 years ago
"<matplotlib.axes._subplots.AxesSubplot at 0x7fa3c8a0f710>"
]
},
"metadata": {},
4 years ago
"execution_count": 10
},
{
4 years ago
"output_type": "display_data",
"data": {
4 years ago
"text/plain": "<Figure size 432x288 with 1 Axes>",
"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=\"248.518125pt\" version=\"1.1\" viewBox=\"0 0 372.103125 248.518125\" width=\"372.103125pt\" 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;white-space:pre;}\n </style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 248.518125 \nL 372.103125 248.518125 \nL 372.103125 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 30.103125 224.64 \nL 364.903125 224.64 \nL 364.903125 7.2 \nL 30.103125 7.2 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"PolyCollection_1\">\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 61.82295 202.776198 \nL 61.82295 214.756364 \nL 69.157013 190.796033 \nL 76.491077 174.323306 \nL 76.491077 148.865455 \nL 76.491077 148.865455 \nL 69.157013 178.815868 \nL 61.82295 202.776198 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 92.99272 118.915041 \nL 92.99272 130.895207 \nL 92.99272 118.915041 \nL 92.99272 118.915041 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 124.16249 82.974545 \nL 124.16249 88.964628 \nL 124.16249 82.974545 \nL 124.16249 82.974545 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 142.497649 76.984463 \nL 142.497649 82.974545 \nL 146.16468 76.984463 \nL 146.16468 65.004298 \nL 146.16468 65.004298 \nL 142.497649 76.984463 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 175.500934 59.014215 \nL 175.500934 65.004298 \nL 175.500934 59.014215 \nL 175.500934 59.014215 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 184.668514 53.024132 \nL 184.668514 59.014215 \nL 184.668514 53.024132 \nL 184.668514 53.024132 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 234.173443 41.043967 \nL 234.173443 53.024132 \nL 234.173443 41.043967 \nL 234.173443 41.043967 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 314.848141 35.053884 \nL 314.848141 41.043967 \nL 314.848141 35.053884 \nL 314.848141 35.053884 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n <path clip-path=\"url(#pfd33e0a8e5)\" d=\"M 333.1833 23.073719 \nL 333.1833 35.053884 \nL 333.1833 23.073719 \nL 333.1833 23.073719 \nz\n\" style=\"fill:#ff7f0e;fill-opacity:0.2;stroke:#ff7f0e;stroke-opacity:0.2;\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <defs>\n <path d=\"M 0 0 \nL 0 3.5 \n\" id=\"m729210be6a\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"45.321307\" xlink:href=\"#m729210be6a\" y=\"224.64\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- 0.0 -->\n <defs>\n <path d=\"M 31.78125 66.40625 \nQ 24.171875 66.40625 20.328125 58.90625 \nQ 16.5 51.421875 16.5 36.375 \nQ 16.5 21.390625 20.328125 13.890625 \nQ 24.171875 6.390625 31.78125 6.390625 \nQ 39.453125 6.390625 43.28125 13.890625 \nQ 47.125 21.390625 47.125 36.375 \nQ 47.125 51.421875 43.28125 58.90625 \nQ 39.453125 66.40625 31.78125 66.40625 \nz\nM 31.78125 74.21875 \nQ 44.046875 74.21875 50.515625 64.515625 \nQ 56.984375 54.828125 56.984375 36.375 \nQ 56.984375 17.96875 50.515625 8.265625 \nQ 44.046875 -1.421875 31.
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3dd3xUVf7/8ddJJyEJJaGlEDoEAgqRLqKiIhZEdMXesazr96e7CooiigV1XddddV10LexaVmlGDKAgioJUkTQIJJCQkJBKep2Z8/vjht0sghmSSe6Uz/Px4MGUC/O5Jnl7Ofecz1Faa4QQQrg+L7MLEEII4RgS6EII4SYk0IUQwk1IoAshhJuQQBdCCDfhY9YHh4WF6ZiYGLM+XgghXNLu3buLtdbhp3rPtECPiYlh165dZn28EEK4JKVU9unekyEXIYRwExLoQgjhJiTQhRDCTUigCyGEm5BAF0IIN9FioCul3lVKFSqlUk7zvlJK/UUplaGUSlJKjXZ8mUIIIVpizxX6+8D0X3n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JpZa42bniNkQe6UR6FFjza5SNHOgoJJHlyfxc04ZFwztwXOzRtA7VP5n21Ek0EXb2azGFEGfZv02Gutgy5+hqpX3xSuOQuYmsNZD555w9o1Gk6roieDd9G2bt6fttQuHaLDY+Nu3mby+6SCd/X14bc5ZXDmqjzTT6mAS6KLtqgqhsRa69zeeWy2w4k7YvwYCW7nqzz8Y4u8wQjxq7KnHxmX2ilPYm1PGvBVJ7D9WyZWj+vDUFbF07yzNtMwggS7ariLPCGAwphCu+X9GmF/6Eoy7p/0+V2avmKq
},
"metadata": {
"needs_background": "light"
4 years ago
}
}
],
"source": [
4 years ago
"from sklearn.metrics import roc_curve, roc_auc_score\n",
"\n",
"y_scores = model.predict_proba(X_test)\n",
"# calculate ROC curve\n",
"fpr, tpr, thresholds = roc_curve(y_test, y_scores[:,1])\n",
"sns.lineplot([0, 1], [0, 1])\n",
"sns.lineplot(fpr, tpr)"
]
},
{
"cell_type": "code",
"execution_count": 11,
4 years ago
"metadata": {},
"outputs": [
{
"output_type": "stream",
4 years ago
"name": "stdout",
4 years ago
"text": [
4 years ago
"0.6997079225994889\n"
4 years ago
]
}
],
"source": [
"auc = roc_auc_score(y_test,y_scores[:,1])\n",
"print(auc)"
]
}
],
"metadata": {
"environment": {
"name": "tf2-gpu.2-4.m65",
"type": "gcloud",
"uri": "gcr.io/deeplearning-platform-release/tf2-gpu.2-4:m65"
},
"kernelspec": {
4 years ago
"name": "python37364bit8d3b438fb5fc4430a93ac2cb74d693a7",
"display_name": "Python 3.7.0 64-bit ('3.7')"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
4 years ago
"version": "3.7.0"
},
"metadata": {
"interpreter": {
"hash": "70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
4 years ago
}