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.

988 lines
358 KiB

2 years ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
"<a href='http://www.pieriandata.com'><img src='../Pierian_Data_Logo.png'/></a>\n",
"___\n",
"<center><em>Copyright by Pierian Data Inc.</em></center>\n",
"<center><em>For more information, visit us at <a href='http://www.pieriandata.com'>www.pieriandata.com</a></em></center>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Multi-Class Logistic Regression\n",
"\n",
"Students often ask how to perform non binary classification with Logistic Regression. Fortunately, the process with scikit-learn is pretty much the same as with binary classification. To expand our understanding, we'll go through a simple data set, as well as seeing how to use LogisiticRegression with a manual GridSearchCV (instead of LogisticRegressionCV). Make sure to watch the video to understand the One-vs-all process that is occuring \"under the hood\"."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"\n",
"We will work with the classic Iris Data Set. The Iris flower data set or Fisher's Iris data set is a multivariate data set introduced by the British statistician, eugenicist, and biologist Ronald Fisher in his 1936 paper The use of multiple measurements in taxonomic problems as an example of linear discriminant analysis.\n",
"\n",
"Full Details: https://en.wikipedia.org/wiki/Iris_flower_data_set"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('../DATA/iris.csv')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"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>sepal_length</th>\n",
" <th>sepal_width</th>\n",
" <th>petal_length</th>\n",
" <th>petal_width</th>\n",
" <th>species</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4.9</td>\n",
" <td>3.0</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4.6</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5.0</td>\n",
" <td>3.6</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sepal_length sepal_width petal_length petal_width species\n",
"0 5.1 3.5 1.4 0.2 setosa\n",
"1 4.9 3.0 1.4 0.2 setosa\n",
"2 4.7 3.2 1.3 0.2 setosa\n",
"3 4.6 3.1 1.5 0.2 setosa\n",
"4 5.0 3.6 1.4 0.2 setosa"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exploratory Data Analysis and Visualization\n",
"\n",
"Feel free to explore the data further on your own."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 150 entries, 0 to 149\n",
"Data columns (total 5 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 sepal_length 150 non-null float64\n",
" 1 sepal_width 150 non-null float64\n",
" 2 petal_length 150 non-null float64\n",
" 3 petal_width 150 non-null float64\n",
" 4 species 150 non-null object \n",
"dtypes: float64(4), object(1)\n",
"memory usage: 6.0+ KB\n"
]
}
],
"source": [
"df.info()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"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>sepal_length</th>\n",
" <th>sepal_width</th>\n",
" <th>petal_length</th>\n",
" <th>petal_width</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>150.000000</td>\n",
" <td>150.000000</td>\n",
" <td>150.000000</td>\n",
" <td>150.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mean</th>\n",
" <td>5.843333</td>\n",
" <td>3.054000</td>\n",
" <td>3.758667</td>\n",
" <td>1.198667</td>\n",
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
" <td>0.828066</td>\n",
" <td>0.433594</td>\n",
" <td>1.764420</td>\n",
" <td>0.763161</td>\n",
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
" <td>4.300000</td>\n",
" <td>2.000000</td>\n",
" <td>1.000000</td>\n",
" <td>0.100000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
" <td>5.100000</td>\n",
" <td>2.800000</td>\n",
" <td>1.600000</td>\n",
" <td>0.300000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
" <td>5.800000</td>\n",
" <td>3.000000</td>\n",
" <td>4.350000</td>\n",
" <td>1.300000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
" <td>6.400000</td>\n",
" <td>3.300000</td>\n",
" <td>5.100000</td>\n",
" <td>1.800000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
" <td>7.900000</td>\n",
" <td>4.400000</td>\n",
" <td>6.900000</td>\n",
" <td>2.500000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sepal_length sepal_width petal_length petal_width\n",
"count 150.000000 150.000000 150.000000 150.000000\n",
"mean 5.843333 3.054000 3.758667 1.198667\n",
"std 0.828066 0.433594 1.764420 0.763161\n",
"min 4.300000 2.000000 1.000000 0.100000\n",
"25% 5.100000 2.800000 1.600000 0.300000\n",
"50% 5.800000 3.000000 4.350000 1.300000\n",
"75% 6.400000 3.300000 5.100000 1.800000\n",
"max 7.900000 4.400000 6.900000 2.500000"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.describe()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"setosa 50\n",
"versicolor 50\n",
"virginica 50\n",
"Name: species, dtype: int64"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['species'].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='species', ylabel='count'>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEGCAYAAABiq/5QAAAAOXRFWHRTb2Z0d2FyZ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tsbuOSpCkaLfir6oPA55c1nwpsbMMbgdPGWr8kaWXTPsZ/ZFVtA2j3R+xqwiRnJdmSZMuOHTumVqAk7evutV/uVtWGqlqoqoW5ublZlyNJ+4xpB/9tSdYBtPvtU16/JHVv2sF/KbC+Da8HLpny+iWpe2Oezvl24CPAw5P8R5IXA+cCT09yM/D0Ni5JmqL9x1pwVT13Fw+dNNY6JUn37F775a4kaRwGvyR1xuCXpM4Y/JLUGYNfkjpj8EtSZwx+SeqMwS9JnTH4JakzBr8kdcbgl6TOGPyS1BmDX5I6Y/BLUmcMfknqjMEvSZ0x+CWpMwa/JHXG4Jekzhj8ktQZg1+SOmPwS1JnDH5J6ozBL0mdMfglqTMGvyR1xuCXpM4Y/JLUGYNfkjpj8EtSZwx+SeqMwS9JnTH4JakzMwn+JKck+Zck/5bk7FnUIEm9mnrwJ1kDvAn4EeA44LlJjpt2HZLUq1ns8Z8A/FtVfbKqvgn8FXDqDOqQpC6lqqa7wuR04JSq+uk2/nzgB6rqpcumOws4q40+HPiXqRY6XYcDt8+6CO0Rt93qtq9vv++qqrnljfvPoJCs0LbTu09VbQA2jF/O7CXZUlULs65D/39uu9Wt1+03i0M9/wE8eMn40cBnZ1CHJHVpFsF/JXBskockuQ/wHODSGdQhSV2a+qGeqrojyUuB9wJrgLdV1fXTruNepotDWvsot93q1uX2m/qXu5Kk2fLKXUnqjMEvSZ0x+KcsyQuTHDXrOrTnkvx2kpP3YL6nJLlsjJp6leSoJO/cg/n+LskD72GaPdrOq4HH+KcsyRXAL1fVllnXol1
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.countplot(df['species'])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='sepal_length', ylabel='sepal_width'>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iV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D1J5qFzsqnRj0OrrlWDrsHgGvP0Clw8fWMjudcywUZJjItalU10r6CAQDVLor2Va7jTxzHgXWAvIseQmdwxvwUuWpYlvNNjrZOpFvySfHnJNwX1qaQ1ABQVEU5TChJpUVRVGUuKjZt8OQxxdgb62btxbtwKjXccmYnnTOMidUWtLp8VNa4+bNH7dTkGFiytE96JxtRoiG9f/ldR6+XLePVbtquGBkd/p1yiRHDecoStpSQ0aHoe0VDiY+9k04PXWW2cAXv52Q0DzC2tJazvnnAgJB7fenKNPMxzcdF17/X2H3cPW/F7NsR3X4NX+bMoTJI4rRq5rGipISashIiRAMSl75bltErYI6j58PV5TGfQ6n18+T8zaFgwFAmd3Dop8b1kXXuHwRwQDgya82U+lU6SUUJV2pgHAYEjGyOsRqa/b1xP7Faekc2vMd745UUQ4XKiAcZnQ6wZXjSyLW7mdbDJwzLHrzTHOsJgM3ntIXfaN8QZ2yzIwuyQ8/zrEZObpX5NK6Gaf0Iz/DfBC9VxSlLak5hMOQ1x9gf62HmYt3YjLomDyymE4JTiq7fH721nh4Z9EOCjJNnDe8O52ymkwq2z3M37CfVbtruWB4N3oXZqhJZUVJIbUPQVEURQHUpLKiKIoSJ7UPIYk8vgBVTi8b9tbRLddKYZaZvBQMkdjdPqqcPjaX2TmyKJNcm5Esld9HOcTYvXZqPDVsrdlKn5w+5Jhz2iTh2+FEBYQkWre3joufXxhe0vmrsT257fT+7Zpbx+MP8Nmavdz6n5XhtocnD+H84d0xG/Xt1g9FaUsev4evdnz
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x='sepal_length',y='sepal_width',data=df,hue='species')"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='petal_length', ylabel='petal_width'>"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBOR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8y/5P5FbUCfsj8gXcueIebV9xMpjMTgA1ZG/jwog+59rNrK9JJb8nZQlFZEb8c+UsspprrbZfrclYeXMmD3z9Y0bb68Greu+g9ukR2CTo2x53D3I/mVnzTX3d0Hc9Nf44J3ScEHZfnzuPmL25mR94OALbmbuVQ8SHum3hfs8yDNESZv4zXt7/O4s3GXqQtOVtYc2QNb856k2RH0y1OkWGiVvLiiy9y+PDh1u6GEPVS5CnijR1vBLWNShnF0t1LKwIBgEazbPcyUrukVrQ5zA6OOo+G1BV4Z/c7dRrKKfQU8taOt4Lair3F7M7fHXLsN+nfhAz5vLbjtZAhFqfXWREIjvl438cVqTbagkJPIe/+FJzw+ajzaJNv9Ou0weC9DRmc/OeV9LvnI07+80re21C3Ahk1CZfCet26dZx++umcdNJJzJgxg8zMTJYuXcratWu58sorGT16NC6Xiy+++IIxY8YwcuRIrr32WjweY9v9Pffcw7Bhw0hNTeW3v/0tAB988AETJ05kzJgxnH322Rw9erTRfReiLiwRFlIcwUniisqKwk70dovqFjR/4C33hl0NlGRPqlPOIUuEhSRHUkh7uCGdcEtdu0d1xxwRPBhiibBgUsFDTHG2uDZV8tKkTGE/Y1PvueiUweC9DRnc+24aGQUuNJBR4OLed9MaHRA++eQTevTowaZNm9iyZQvnnHMOt956K0uXLmXdunVce+213HfffVx66aWMGzeO1157jY0bN6KUYt6
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x='petal_length',y='petal_width',data=df,hue='species')"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.PairGrid at 0x2a1a26a4908>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAykAAALbCAYAAAD+R8/MAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNp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WrKQIYxaJeS8ImYWMSSEdiNwJyUDW4EZAu8tDj9sX1dwLoDjXzsF2yZUijE38Me+DqcytxKIsYpcsCGlAxqSQCsL9TxyWyHIn+U+EkSBKygjY32YqH6V50QdhSY5DVlKEMUukmPdLFy7lF2t/wTlPn8OilYuoaa2RhyJBSBEyJoVk4/c/WbRyUUCmOj2dkv9ESDipzJMy5qhrM5WPaD4pAMW5Dt7f3YrWGqVUqromCCkhPOa9RVn4xdpfsLp2NXDILnnFBSsk5KQgpAAZk0KyieR/svgfi3n8wscl/4mQUERJGQF1/pWU3OgrKcU5Dtw+g3aXh6IcWfYUxh7BMe/ruuoCD0N+xC5ZEFKLjEkhmUTzP+n19lKZVxnlKEGIH1FSRkBdmwu7VVHotEetU9yvmNR39ImSIox5/PbwwTewhVULA/bw0d6uGdqgpbdl2G/gRnq8IIxGwuW+KKuItr62wAqKBQsWZWFh1cIQRUV8BYTBGGo+dVgdLKxayMXTL6bQUUi7u51na55NuUzJvD/2ESVlBOxvc1GalzWoGVdxrqnA1Hf0MnNifqq6JghpwW8P7zcFWFi1kMVzFnPti9dGjZ0/0vj6Ep9fGI9EkvulC5eyfONyVteupjK3kjsW3MFjWx5j8Rwz4r+/XHwFhGjEMp8WZRWxeM5iblt9W4jsFWUVZVQ/hdGPXMkRcKC9d1BTLwh
"text/plain": [
"<Figure size 804.75x720 with 20 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.pairplot(df,hue='species')"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:>"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAD9CAYAAABqQtoLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXB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ekVHHvJ/6U43+zcPUmHu/XLZSHERAFwsMYflMbBo7/HI9H6db0cqqXL8MnP/0OwI3XXMm9na/iiXdn0uu5d1CFf3W/hlLFCvPbph1M/3UtNcqX4aaRUwC47/rmXFOnSigPKWeB/Z5NY2CTqm4BEJEPgW6Ab7JRoLh432CLAUlAni4IiZ6h79sZtZWkqn+JSHegP1ATuENVF4hIQaCmqq52rtmsU9UBInI18Lqq1hWRL4ApqvqZc42lj6pWFpFWwFBVvS6buvsAcao6RETeB35T1dHOunqqutzZ3xFVHeMsXwVcB0QBbwDN8CaPpcBEVR3jtHJeUtUfnW22OfXsc7rfxqhqq5zOi7VsvG5t+ECoQ3CNdz+5PdQhuIYm7w91CK5SuN2A3H74zSDlm1f9fr8p0uX+f+B9nz5pgtMrA4CI9AI6qeo9zvwdwFWqOsSnTHFgKt5LFMWBm1X167wcgz+f4OsCo0XEA5wABuLNcK+KSElnH68Aq53yB0TkF5wBAs6yF/F2o/0f8MNZxvpPYLyIrHDqnAcMyK6wqi4WkanA78AfeK/TnOzwngTEZxogYIwx7pSLUWa+3f3ZyCrxZU5mHfEO9moDVMN72eQnVU3OvKG//OlGmwnMzGJVi2w2+UxVR2TaxwK8raGTHneWzyGHLjVVnYQ3MaCq+4CbsyjzVKb5Oj6zY1T1KREpgjc5/ccp8xnwmU+5yj7bLwF
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.heatmap(df.corr(),annot=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Easily discover new plot types with a google search! Searching for \"3d matplotlib scatter plot\" quickly takes you to: https://matplotlib.org/3.1.1/gallery/mplot3d/scatter3d.html"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['setosa', 'versicolor', 'virginica'], dtype=object)"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['species'].unique()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPMAAADzCAYAAABT9iA/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAACEe0lEQVR4nO29d3hjZ5n+/3nPUbVc5F6meTy990khDUIIJCEzQAi9LiyhLIH98qPs7pcFttBZYOnsfmFhdymZJJBGgAChpE0m08cztse9V7moS+e8vz/kc0aWJVuyJc9kovu6cmVsS+cclfu8z/s893M/QkpJHnnk8fyHcrEvII888sgO8mTOI4/LBHky55HHZYI8mfPI4zJBnsx55HGZIE/mPPK4TGCZ5+/5ulUeeeQeIhsHya/MeeRxmSBP5jzyuEyQJ3MeeVwmyJM5jzwuE+TJnEcelwnyZM4jj8sEeTLnkcdlgjyZ88jjMkGezHnkcZkgT+Y88rhMkCdzHnlcJsiTOY88LhPkyZxHHpcJ8mTOI4/LBHkyXyToun6xLyGPywzz9TPnkWVIKYlGo/j9foQQWCwWrFYrqqqiKPl7ax4Lh5jHNztvTpBFSCkJh8Pouk4kEkFKSfz7rygKVqsVi8WSJ/cLC1kxJ8iTeYkQjUaJRCIACCHMfxswiC2lpL29nbq6OgoKCsxV22KxIERWPvM8Lj1k5YPNh9k5hpSS8fFxIpEIxcXFCCFM0saTUwhh/hwMBoHYvtr4N4CqqjNW7jy584hHnsw5hBFOj46OomkaJSUlAIRCIdra2igsLKS0tBS73Z70+fFhtpQyT+485kSezDmAlBJN08xQWlVVotEoAKOjo5w9e5bly5cTDAZpbGwkEolQUlKC2+2mtLTUXL3jEb9yG+fIkzuPeOT3zFmGlJJIJIKmaSYB+/v78fv9aJrGxMQEW7duRVEUk2y6rjM5OYnH48Hj8eD1eikvL6eqqgq3243Vak3rvAbBjePmyf28QT4BdqlB13XC4bC5HzbI09X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mfaGVi0MuEt4CiovOUlpaiaVra588E2SaFEWlIKVm7dq0pPe3p6cHr9S5YV67rOoFAgJaWFtavX39ZkvsFQ+ZktWNFUdA0je7ubrq7u9m2bRtFRUVzHmeuD91Ici1btowVK1bMUEcthQgkJvgop7CwnJplzKgJezweJicnzRJYunZEc2EhYXY6iA+vHQ4HtbW11NbWIqUkEAgwPj6+IF25oih4vV4zugoEAjMy6c93cr8gyJzKzscQgRQXF3PFFVfMmSmeD/39/bS3t89ofTSQ6xbIVIivCYdCIaqqqsxcgVE2Mvfb82TKkyFXZE51XCEEBQUFFBQUpNSVFxYWmgm1uXTl8eXH+JXbePzz0YXlsibzXLXj8fFxOjo6KCsrY+vWrQs+h1FKikQi7Nu3L6VI4mLJM+NhkDu+bOTxeNLKlCfDUqzMcyETXXlpaSkOhyPlcRLJHb8dg+eHC8tlS+a5JJkdHR0MDg6yatWqRZ3DCKvr6upYuXLlgvfZi318JseNh8VimZVZHhsbm5EpN8Jyl8s16/lLvTLPh1S6co/HQ1NTk1nKGhgYmNOvPBW5411lLkVyX5ZkTmyiN97oUCjEqVOnKCoqYv/+/QwNDWXkzRUPI6zesmWLaW6fCsnIOdeHv3g5pwSmiJmrFk/XneeHzWabYWpgZMo7Ojrw+XymlLWsrAyn05mzaCPdlXk+xOvKV61ahaZpPPvss6ZfeTQapbi4OC1deWJCLdFiKX7PfbHIfVmROTGsjn9DR0dHOXfuHOvXrzdXokwFIBALqwOBAAMDAynD6kQkI2cgEEBKmTL0WzBkFDX6AKp2AgBd3UDUcseCiJfY92yEsC0tLQSDQfPLHwq
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"from mpl_toolkits.mplot3d import Axes3D \n",
"fig = plt.figure()\n",
"ax = fig.add_subplot(111, projection='3d')\n",
"colors = df['species'].map({'setosa':0, 'versicolor':1, 'virginica':2})\n",
"ax.scatter(df['sepal_width'],df['petal_width'],df['petal_length'],c=colors);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Train | Test Split and Scaling"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"X = df.drop('species',axis=1)\n",
"y = df['species']"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split\n",
"from sklearn.preprocessing import StandardScaler"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=101)"
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {},
"outputs": [],
"source": [
"scaler = StandardScaler()"
]
},
{
"cell_type": "code",
"execution_count": 79,
"metadata": {},
"outputs": [],
"source": [
"scaled_X_train = scaler.fit_transform(X_train)\n",
"scaled_X_test = scaler.transform(X_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Multi-Class Logistic Regression Model"
]
},
{
"cell_type": "code",
"execution_count": 80,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.linear_model import LogisticRegression"
]
},
{
"cell_type": "code",
"execution_count": 81,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import GridSearchCV"
]
},
{
"cell_type": "code",
"execution_count": 96,
"metadata": {},
"outputs": [],
"source": [
"# Depending on warnings you may need to adjust max iterations allowed \n",
"# Or experiment with different solvers\n",
"log_model = LogisticRegression(solver='saga',multi_class=\"ovr\",max_iter=5000)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### GridSearch for Best Hyper-Parameters\n",
"\n",
"Main parameter choices are regularization penalty choice and regularization C value."
]
},
{
"cell_type": "code",
"execution_count": 97,
"metadata": {},
"outputs": [],
"source": [
"# Penalty Type\n",
"penalty = ['l1', 'l2']\n",
"\n",
"# Use logarithmically spaced C values (recommended in official docs)\n",
"C = np.logspace(0, 4, 10)"
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [],
"source": [
"grid_model = GridSearchCV(log_model,param_grid={'C':C,'penalty':penalty})"
]
},
{
"cell_type": "code",
"execution_count": 99,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"GridSearchCV(estimator=LogisticRegression(max_iter=5000, multi_class='ovr',\n",
" solver='saga'),\n",
" param_grid={'C': array([1.00000000e+00, 2.78255940e+00, 7.74263683e+00, 2.15443469e+01,\n",
" 5.99484250e+01, 1.66810054e+02, 4.64158883e+02, 1.29154967e+03,\n",
" 3.59381366e+03, 1.00000000e+04]),\n",
" 'penalty': ['l1', 'l2']})"
]
},
"execution_count": 99,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"grid_model.fit(scaled_X_train,y_train)"
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'C': 7.742636826811269, 'penalty': 'l1'}"
]
},
"execution_count": 100,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"grid_model.best_params_"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model Performance on Classification Tasks"
]
},
{
"cell_type": "code",
"execution_count": 101,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import accuracy_score,confusion_matrix,classification_report,plot_confusion_matrix"
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [],
"source": [
"y_pred = grid_model.predict(scaled_X_test)"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9736842105263158"
]
},
"execution_count": 103,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"accuracy_score(y_test,y_pred)"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[10, 0, 0],\n",
" [ 0, 17, 0],\n",
" [ 0, 1, 10]], dtype=int64)"
]
},
"execution_count": 104,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"confusion_matrix(y_test,y_pred)"
]
},
{
"cell_type": "code",
"execution_count": 108,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<sklearn.metrics._plot.confusion_matrix.ConfusionMatrixDisplay at 0x2a1a83ac0c8>"
]
},
"execution_count": 108,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVwAAAEGCAYAAAApAy29AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAjE0lEQVR4nO3deZwdVZ338c83nYSQfSUkASYgEI2sEpA4wIRFQUcHHRjRB3xAnUFWHR5xHhmdEXEGcdQZlYgYEKMPArKogCAJ+zKyJCEBElaHQISEJSEQlkDS3b/njzoNN00v93bfrltdfN+vV724VffUqXOLm1+fe+osigjMzKzvDWh0AczM3ikccM3McuKAa2aWEwdcM7OcOOCameVkYKML0B81jRgWAyeMbnQxCmuz5esbXQTr517nVTbEG+pNHgfvPyzWvNBSVdpF978xLyIO6c31quGA2wMDJ4xm8r+d2OhiFNb2Ry1udBGsn7s7bux1HmteaOGeedtUlbZp0mPje33BKjjgmlkpBdBKa6OLsQkHXDMrpSDYGNU1KeTFAdfMSss1XDOzHARBS8GmLnDANbPSasUB18yszwXQ4oBrZpYP13DNzHIQwMaCteF6aK+ZlVIQtFS5dUfSBZKek7S03fGTJT0iaZmk/+guH9dwzaycAlrqV8GdC8wGftl2QNL+wKHALhHxhqQtusvEAdfMSikbaVanvCJukzS13eHjgbMi4o2U5rnu8nGTgpmVlGipcgPGS1pYsR1bxQV2BPaVdLekWyXt2d0JruGaWSllD82qnnBsdUTMqPESA4ExwN7AnsClkraLLhaKdMA1s1LK+uH2aobH7jwF/CYF2HsktQLjgec7O8FNCmZWWq2hqrYe+h1wAICkHYHBwOquTnAN18xKqZ41XEkXA7PI2nqfAr4BXABckLqKbQCO7qo5ARxw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pZIOre7fFzDNbPSqtfkNRHx6Q4O/6zWfBxwzayUIoo30swB18xKSrR4mXQzs3xU0z6bJwfcHths+Xq2P2pxo4tRWPNWLml0EQrv4Mm7NboIpef5cM3M8hJZO26ROOCaWWl5iR0zsxyEH5qZmeXHTQpmZjlxLwUzsxxEOOCameXG3cLMzHLiNlwzsxwEotW9FMzM8lGwCq4DrpmVlB+amZnlqGBVXAdcMyutflPDlXQ2Xfx9iIgv9kmJzMzqIIDW1voEXEkXkC0W+VxE7JSOjSVbGn0q8ATwyYhY21U+XT3CWwgs6mIzMyuuAELVbd2bCxzS7thXgRsjYgfgxrTfpU5ruBHxi8p9ScMi4tVqSmZmVgT16ocbEbdJmtru8KHArPT6F8AtZKv4dqrbTmqSZkp6EHgo7e8q6Zway2tmlr+ocoPxkhZWbMdWkfvEiFgFkP67RXcnVPPQ7AfAwcBVKeP7JO1XxXlmZg1U3RLoyeqImNGXpYEqargAEfHndoda+qAsZmb1VX0NtyeelTQJIP33ue5OqCbg/lnSB4CQNFjSqaTmBTOzwgqIVlW19dBVwNHp9dHAld2dUE3APQ44EZgCPA3slvbNzApOVW7d5CJdDNwJTJP0lKTPA2cBH5T0GPDBtN+lbttwI2I1cGS3JTIzK5r69VL4dCdvHVhLPtX0UthO0tWSnpf0nKQrJW1Xy0XMzBqib9twa1ZNk8JFwKXAJGAycBlwcV8Wysys1+o78KEuqgm4ioj/FxHNabuQwk0JYWb2dtkyO91veelqLoWx6eXNkr4KXEIWaI8ArsmhbGZmvVOnuRTqpauHZovIAmxbib9Q8V4A3+qrQpmZ1YMK9lu8q7kUts2zIGZmdZXzA7FqVDUfrqSdgOnAkLZjEfHLviqUmVnv5ftArBrdBlxJ3yCbEWc6cC3wYeAOwAHXzIqtYDXcanopHE7WufeZiPgssCu
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plot_confusion_matrix(grid_model,scaled_X_test,y_test)"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<sklearn.metrics._plot.confusion_matrix.ConfusionMatrixDisplay at 0x2a1a843ac48>"
]
},
"execution_count": 109,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAEKCAYAAAAsDo9wAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAk5UlEQVR4nO3deZgV1Z3/8fenmx1ZZFEBQTAiRkUxtguOMbgkajKRZOKIo0k0m2J0MuOYzCQz80uIjiY+MZO4E+IoycQEt0xEJYKJ+0QUFGQRQQYF2ZTNhR26v78/qlov1+7bl+Z21+3r5/U89Xir6tSpU+Xl2+eeOueUIgIzM2t9VVkXwMzsw8oB2MwsIw7AZmYZcQA2M8uIA7CZWUYcgM3MMuIAbGbWBEm3S3pT0rxG9kvSDZIWS5oj6WPF5OsAbGbWtInAGQX2nwkMTZeLgFuLydQB2MysCRHxJLC+QJLRwK8jMR3oKalfU/m2K1UBP0z69KqOwQPbZ12MsrVoTpesi2Bt3FY2sT22aU/yOP3krrFufW1RaZ+fs20+sDVn04SImLAbpxsAvJ6zvjzdtqrQQQ7AzTB4YHuemzow62KUrdP7j8i6CNbGPRt/3uM81q2v5bmpg4pKW93vla0RUbMHp2voj0WT8zw4AJtZRQqgjrrWOt1yILdWtj+wsqmD3AZsZhUpCHZEbVFLCUwGvpz2hjgeeDsiCjY/gGvAZlbBSlUDlvQ7YBTQR9Jy4AdAe4CIGA9MAT4NLAY2A18pJl8HYDOrSEFQW6LpdiPi75rYH8Clu5uvA7CZVay6pp+DZcoB2MwqUgC1DsBmZtlwDdjMLAMB7CjzV645AJtZRQrCTRBmZpkIqC3v+OsAbGaVKRkJV94cgM2sQonaBqdoKB8OwGZWkZKHcA7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background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Scaled so highest value=1\n",
"plot_confusion_matrix(grid_model,scaled_X_test,y_test,normalize='true')"
]
},
{
"cell_type": "code",
"execution_count": 110,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" precision recall f1-score support\n",
"\n",
" setosa 1.00 1.00 1.00 10\n",
" versicolor 0.94 1.00 0.97 17\n",
" virginica 1.00 0.91 0.95 11\n",
"\n",
" accuracy 0.97 38\n",
" macro avg 0.98 0.97 0.97 38\n",
"weighted avg 0.98 0.97 0.97 38\n",
"\n"
]
}
],
"source": [
"print(classification_report(y_test,y_pred))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Evaluating Curves and AUC\n",
"\n",
"**Make sure to watch the video on this! We need to manually create the plots for a Multi-Class situation. Fortunately, Scikit-learn's documentation already has plenty of examples on this.**\n",
"\n",
"Source: https://scikit-learn.org/stable/auto_examples/model_selection/plot_roc.html"
]
},
{
"cell_type": "code",
"execution_count": 116,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import roc_curve, auc"
]
},
{
"cell_type": "code",
"execution_count": 122,
"metadata": {},
"outputs": [],
"source": [
"def plot_multiclass_roc(clf, X_test, y_test, n_classes, figsize=(5,5)):\n",
" y_score = clf.decision_function(X_test)\n",
"\n",
" # structures\n",
" fpr = dict()\n",
" tpr = dict()\n",
" roc_auc = dict()\n",
"\n",
" # calculate dummies once\n",
" y_test_dummies = pd.get_dummies(y_test, drop_first=False).values\n",
" for i in range(n_classes):\n",
" fpr[i], tpr[i], _ = roc_curve(y_test_dummies[:, i], y_score[:, i])\n",
" roc_auc[i] = auc(fpr[i], tpr[i])\n",
"\n",
" # roc for each class\n",
" fig, ax = plt.subplots(figsize=figsize)\n",
" ax.plot([0, 1], [0, 1], 'k--')\n",
" ax.set_xlim([0.0, 1.0])\n",
" ax.set_ylim([0.0, 1.05])\n",
" ax.set_xlabel('False Positive Rate')\n",
" ax.set_ylabel('True Positive Rate')\n",
" ax.set_title('Receiver operating characteristic example')\n",
" for i in range(n_classes):\n",
" ax.plot(fpr[i], tpr[i], label='ROC curve (area = %0.2f) for label %i' % (roc_auc[i], i))\n",
" ax.legend(loc=\"best\")\n",
" ax.grid(alpha=.4)\n",
" sns.despine()\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 123,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA7gAAAJcCAYAAADTmwh7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAACFwklEQVR4nOzdeZxN9ePH8dfHkF2WRJJU9j27pIWiTVQkiqJdiKTSol0bLdL6rahoEUn7otKiRZQ1MSoh2si+jjm/P2aa3yTLKOPM8no+HvNo7r3nnvs+557RvOfzOeeGKIqQJEmSJCm7yxN3AEmSJEmS9gQLriRJkiQpR7DgSpIkSZJyBAuuJEmSJClHsOBKkiRJknIEC64kSZIkKUew4EqSdiiEMCeEcEzcOeIWQng0hHDDXn7NkSGE2/bma2aWEMLZIYR3/+Vzc+wxGEKIQgiV4s4hSTlJ8HNwJSl7CCEsBMoAW4G1wNtAryiK1saZK6cJIZwHXBBF0ZEx5xgJLImi6PqYc9wEVIqi6Jy98FojyQLbvLeEECKgchRFC+LOIkk5hSO4kpS9tI2iqAhQDzgcGBhvnN0XQsibG187Tu5zSVJuYcGVpGwoiqJfgHdIKboAhBCahhA+CyGsDCHMSD+tM4RQMoQwIoSwNITwZwjhlXSPnRJCmJ76vM9CCHXSPbYwhHBcCKFcCGFDCKFkuscODyH8EULIl3q7Rwhhbur63wkhHJxu2SiEcFkIIRFI3N42hRBOTZ2OujKEMCmEUH2bHANDCN+mrn9ECKHAbmzD1SGEmcC6EELeEMI1IYTvQwhrUtd5Wuqy1YFHgWYhhLUhhJWp96dNFw4hHBNCWB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"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plot_multiclass_roc(grid_model, scaled_X_test, y_test, n_classes=3, figsize=(16, 10))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"------\n",
"------"
]
}
],
"metadata": {
"anaconda-cloud": {},
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}