2020-03-28 01:06:31 +00:00
{
"cells": [
{
"cell_type": "code",
2020-08-01 22:25:45 +00:00
"execution_count": 21,
2020-03-28 01:06:31 +00:00
"metadata": {},
"outputs": [],
"source": [
"import seaborn as sns\n",
"import pandas as pd\n",
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"from sklearn import linear_model\n",
2020-08-01 22:25:45 +00:00
"import statsmodels.api as sm\n",
"import statsmodels.formula.api as smf\n",
"from sklearn import metrics\n",
"from statsmodels.stats import *\n",
2020-03-28 01:06:31 +00:00
"\n",
"sns.set()\n",
"sns.set(style=\"whitegrid\")\n",
"tips = sns.load_dataset(\"tips\")\n",
2020-08-01 22:25:45 +00:00
"plt.rcParams[\"figure.figsize\"] = (6,6)"
2020-03-28 01:06:31 +00:00
]
},
{
"cell_type": "code",
2020-08-01 22:25:45 +00:00
"execution_count": null,
2020-03-28 01:06:31 +00:00
"metadata": {},
"outputs": [],
2020-08-01 22:25:45 +00:00
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"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>Unnamed: 0</th>\n",
" <th>crim</th>\n",
" <th>zn</th>\n",
" <th>indus</th>\n",
" <th>chas</th>\n",
" <th>nox</th>\n",
" <th>rm</th>\n",
" <th>age</th>\n",
" <th>dis</th>\n",
" <th>rad</th>\n",
" <th>tax</th>\n",
" <th>ptratio</th>\n",
" <th>black</th>\n",
" <th>lstat</th>\n",
" <th>medv</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.00632</td>\n",
" <td>18.0</td>\n",
" <td>2.31</td>\n",
" <td>0</td>\n",
" <td>0.538</td>\n",
" <td>6.575</td>\n",
" <td>65.2</td>\n",
" <td>4.0900</td>\n",
" <td>1</td>\n",
" <td>296</td>\n",
" <td>15.3</td>\n",
" <td>396.90</td>\n",
" <td>4.98</td>\n",
" <td>24.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>0.02731</td>\n",
" <td>0.0</td>\n",
" <td>7.07</td>\n",
" <td>0</td>\n",
" <td>0.469</td>\n",
" <td>6.421</td>\n",
" <td>78.9</td>\n",
" <td>4.9671</td>\n",
" <td>2</td>\n",
" <td>242</td>\n",
" <td>17.8</td>\n",
" <td>396.90</td>\n",
" <td>9.14</td>\n",
" <td>21.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>0.02729</td>\n",
" <td>0.0</td>\n",
" <td>7.07</td>\n",
" <td>0</td>\n",
" <td>0.469</td>\n",
" <td>7.185</td>\n",
" <td>61.1</td>\n",
" <td>4.9671</td>\n",
" <td>2</td>\n",
" <td>242</td>\n",
" <td>17.8</td>\n",
" <td>392.83</td>\n",
" <td>4.03</td>\n",
" <td>34.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>0.03237</td>\n",
" <td>0.0</td>\n",
" <td>2.18</td>\n",
" <td>0</td>\n",
" <td>0.458</td>\n",
" <td>6.998</td>\n",
" <td>45.8</td>\n",
" <td>6.0622</td>\n",
" <td>3</td>\n",
" <td>222</td>\n",
" <td>18.7</td>\n",
" <td>394.63</td>\n",
" <td>2.94</td>\n",
" <td>33.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>0.06905</td>\n",
" <td>0.0</td>\n",
" <td>2.18</td>\n",
" <td>0</td>\n",
" <td>0.458</td>\n",
" <td>7.147</td>\n",
" <td>54.2</td>\n",
" <td>6.0622</td>\n",
" <td>3</td>\n",
" <td>222</td>\n",
" <td>18.7</td>\n",
" <td>396.90</td>\n",
" <td>5.33</td>\n",
" <td>36.2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Unnamed: 0 crim zn indus chas nox rm age dis rad \\\n",
"0 1 0.00632 18.0 2.31 0 0.538 6.575 65.2 4.0900 1 \n",
"1 2 0.02731 0.0 7.07 0 0.469 6.421 78.9 4.9671 2 \n",
"2 3 0.02729 0.0 7.07 0 0.469 7.185 61.1 4.9671 2 \n",
"3 4 0.03237 0.0 2.18 0 0.458 6.998 45.8 6.0622 3 \n",
"4 5 0.06905 0.0 2.18 0 0.458 7.147 54.2 6.0622 3 \n",
"\n",
" tax ptratio black lstat medv \n",
"0 296 15.3 396.90 4.98 24.0 \n",
"1 242 17.8 396.90 9.14 21.6 \n",
"2 242 17.8 392.83 4.03 34.7 \n",
"3 222 18.7 394.63 2.94 33.4 \n",
"4 222 18.7 396.90 5.33 36.2 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
2020-03-28 01:06:31 +00:00
"source": [
2020-08-01 22:25:45 +00:00
"Boston = pd.read_csv(\"../../datasets/Boston.csv\")\n",
"Boston.head()"
2020-03-28 01:06:31 +00:00
]
},
{
"cell_type": "code",
2020-08-01 22:25:45 +00:00
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 3,
2020-03-28 01:06:31 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2020-08-01 22:25:45 +00:00
" OLS Regression Results \n",
"==============================================================================\n",
"Dep. Variable: medv R-squared: 0.544\n",
"Model: OLS Adj. R-squared: 0.543\n",
"Method: Least Squares F-statistic: 601.6\n",
"Date: Sun, 29 Mar 2020 Prob (F-statistic): 5.08e-88\n",
"Time: 09:34:27 Log-Likelihood: -1641.5\n",
"No. Observations: 506 AIC: 3287.\n",
"Df Residuals: 504 BIC: 3295.\n",
"Df Model: 1 \n",
"Covariance Type: nonrobust \n",
"==============================================================================\n",
" coef std err t P>|t| [0.025 0.975]\n",
"------------------------------------------------------------------------------\n",
"Intercept 34.5538 0.563 61.415 0.000 33.448 35.659\n",
"lstat -0.9500 0.039 -24.528 0.000 -1.026 -0.874\n",
"==============================================================================\n",
"Omnibus: 137.043 Durbin-Watson: 0.892\n",
"Prob(Omnibus): 0.000 Jarque-Bera (JB): 291.373\n",
"Skew: 1.453 Prob(JB): 5.36e-64\n",
"Kurtosis: 5.319 Cond. No. 29.7\n",
"==============================================================================\n",
"\n",
"Warnings:\n",
"[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n"
2020-03-28 01:06:31 +00:00
]
}
],
"source": [
2020-08-01 22:25:45 +00:00
"results = smf.ols('medv ~ lstat', data=Boston).fit()\n",
"print(results.summary())"
2020-03-28 01:06:31 +00:00
]
},
2020-08-01 22:25:45 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
2020-03-28 01:06:31 +00:00
{
"cell_type": "code",
2020-08-01 22:25:45 +00:00
"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>0</th>\n",
" <th>1</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Intercept</th>\n",
" <td>33.448457</td>\n",
" <td>35.659225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>lstat</th>\n",
" <td>-1.026148</td>\n",
" <td>-0.873951</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1\n",
"Intercept 33.448457 35.659225\n",
"lstat -1.026148 -0.873951"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# confidence interval\n",
"results.conf_int()\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7fa58a217250>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAF5CAYAAABwczYqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOydeWATZfrHv5ncadM2bUmhyLHLWTlLoZVDXHFh8cTdrlI8EKTgAkplxZVDOVygIKwurKIiCMKi6C4/RY5FF7ouh1iglIViOVTksIUKpG3S5p78/ggzZJKZJi1Jz+fzF2Qm7zxJ2+d53+eUeTweDwiCIAgCANPQAhAEQRCNBzIKBEEQBA8ZBYIgCIKHjAJBEATBQ0aBIAiC4FE0tAC3AsuyqKqqglKphEwma2hxCIIgmgQejwdOpxNRUVFgGOHZoEkbhaqqKpw5c6ahxSAIgmiSdO3aFXq9XvBakzYKSqUSgPeDqVSqBpamZoqKitCzZ8+GFiMoJGd4ITnDC8kZHhwOB86cOcPrUF+atFHgXEYqlQpqtbqBpQlOU5ARIDnDDckZXkjO8CHmdqdAM0EQBMFDRoEgCILgIaNAEARB8JBRIAiCIHjIKBAEQRA8ZBQIgiAIHjIKBEEQBA8ZBYIgCIKn3orXhg0bJigymzFjBu68804cO3YMc+fOhd1uR9u2bbFs2TIkJCTUl1gEQRCED/Va0bxy5Up07dqV/z/LsnjxxReRm5uL/v37Y9WqVVi+fDlyc3MjKgfLelBRZQfLesCy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A9FoToIgIgE5ocOAVLvsiip7A0tGEARRO8gohIG
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# plot y and X\n",
"sns.scatterplot(\"lstat\" ,\"medv\",data=Boston)\n",
"# plot regression line\n",
"sns.lineplot(Boston[\"lstat\"], results.predict(Boston[\"lstat\"]))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7fa5881a8b50>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAF5CAYAAABz6PpHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOy9e5xcdX3w//6ec+Z+2dlr2EAgYbmIiRISBKIgNSkQhRCtYiniteivFHlsnwdb//BFtK1tgzy0VWjx0vo8ffCKCCGgBIqAEYNoYsSABVwDAbJkrzM795lzzvf3x5mdzOzO7s7szuzM7n7ff2iYnXPOZ86c+Xw/389VSCklCoVCoVgWaM0WQKFQKBQLh1L6CoVCsYxQSl+hUCiWEUrpKxQKxTJCKX2FQqFYRhjNFmAmbNsmmUzicrkQQjRbHIVCoVgUSCnJ5/MEAgE0rdy2b2mln0wmeeGFF5othkKhUCxKzjjjDEKhUNlrLa30XS5X8d/r1q1roiTVcejQoZaXU8lYH5SM9WExyAiLQ85SGXO5HC+88EKZDp2gpZV+qUvH4/E0UZLqWQxyKhnrg5KxPiwGGWFxyDlZxkpucRXIVSgUimWEUvoKhUKxjFBKX6FQKJYRSukrFArFMqJugdyxsTH+6q/+iiNHjuB2uznllFP4m7/5Gzo6OjjzzDM544wzivmit9xyC2eeeWa9L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F7wbgPTvD5J5rXJ30OmwcxnsfHb2N7YoxlD/tCPiFApF9ZjRQbCtSf25BNK2qw7Ulo5slEK
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# because reasons, I have to do x * -1 to get the same plot as\n",
"sns.lineplot(Boston[\"lstat\"] * -1, 0)\n",
"sns.regplot(Boston[\"lstat\"] * -1, results.resid ,order=2)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgYAAAGJCAYAAADxMfswAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdeVhVVfvw8S8cZsREQEVBMnMiwQGQnA3nKcmRJ2d6RJy1pMhKxczCygmj0tAiNRNTCsKJn+KUiiCJhZYSKgkyCKgoMp3z/uHLfjyCiiWj9+e6vC72Onuvc98Hdd9n7bXX1tFoNBqEEEIIIQDdqg5ACCGEENWHFAZCCCGEUEhhIIQQQgiFFAZCCCGEUEhhIIQQQgiFFAZCCCGEUEhhIISoMAEBAcyfPx+AlJQUOnToQHFx8RN9Dzc3N3755Zcn2mdZBg8ezIkTJ8p87cSJE/To0eOJvM/48eMJCQl5In1Vdzt27OA///lPVYch7iOFgagylfUfem3m5uZG586duX37ttIWEhLC+PHjqzCqsjVu3Ji4uDhUKlVVh/KP/Pzzz7i6ulZ1GEJUOCkMxFOrqKioqkN4ItRqNcHBwf+6H41Gg1qtfgIRVV9PerRC/E9t+fckpDAQ1dSBAwcYNmwYzs7OeHh4cO7cOQDWrVvH7NmztfZdunQpS5cuBeDmzZssWLCAbt260b17d1auXKmcDHbs2IGHhwfLli3D1dWVgIAALl++zIQJE3B1dcXV1ZU33niDGzduKH3//v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432 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"fig, ax = plt.subplots(figsize=(8,6))\n",
"fig = sm.graphics.plot_leverage_resid2(results, ax=ax)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1QAAAI1CAYAAADRvrsWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdeXxM1//48des2cUWKmJXkYqkSGy1RqjYVakutGhVW5RaWhT90lJEtZYqXX6qRVRLVFUprZYPiYo1mlIUIcQShKyz3N8fY0ZGFklEkuH9fDw8ZGbuPfd9L5k77znnvI9KURQFIYQQQgghhBAFpi7pAIQQQgghhBDCUUlCJYQQQgghhBCFJAmVEEIIIYQQQhSSJFRCCCGEEEIIUUiSUAkhhBBCCCFEIUlCJYQQQgghhBCFJAmVEEKIuxowYACTJk0q6TAAWLBgAR07diyRYxuNRiZMmECzZs3w9fUlOjq6SNtfu3Ytjz32WJG2KYQQ4v7SlnQAQgjhyN555x3WrVsHgFqtxsvLi+bNmzNmzBgqV65cwtEVnQULFqDV3v9bxtmzZ+nQoYPtsbu7O7Vr1+bVV18lNDS00O2+9NJLPPLII3z44Yf3FN+WLVv46aef+Prrr6lWrRqenp731N69Kux5rV+/nvHjx3P06NH7FJkQQjw8pIdKCCHuUVBQEDt37mT79u3MnTuXuLg43nzzzWI5dmZmZrEcp2zZsri7uxfLsQA+/fRTdu7cyXfffUedOnUYOXIkBw4cKLbj5+bUqVNUrlyZxo0b4+XlhV6vL1Q7xfXvJoQQ4v6ThEoIIe6RTqfDy8uLypUrExwcTL9+/di/fz83b960bWMwGFiwYAEhISE0bNiQrl27EhERYddOfHw8gwcPpmHDhrRt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ytVqkSfPn2YPXs2H3zwARs2bLArrGFVo0YN9Ho9f/31l93zf/31F48++mj+L1QeKlWqRI0aNfKVTNWtWzdbLHv27MHZ2Zlq1aoBlsTOZDJl2/du1+RuiuNalC1blm7dujFt2jSWLFnCnj17bPOocjqvmJgYypUrx+jRowkMDKRWrVpcuHDBbhtropvTNRFCCFEw0kMlhBBFrGbNmrRv356PP/6YL7/8kho1atCnTx8mT57M2LFjadSoEWlpacTGxpKUlMTQoUNp2bIl9evXZ/z48UycOBG9Xs+8efPQaDR37blq3rw5LVu2ZMSIEYwbNw5fX1+uX7/O/v37cXJyol+/fqxZswZFUQgICMDDw4Pdu3eTkpJC3bp1AZg2bRpt27alVq1aZGRksGXLFqpUqYKbm1u247m4uDBgwADmz59P+fLlbYUYtm3bxv/7f//vvlzTvLz66qsMGzaMpUuX0rFjR+Li4li4cCGDBg2ylTX38fEhOjqaM2fO4O7ujoeHB5GRkXlek/y439di3rx5NGjQgLp166JWq9mwYQOurq62RDmn86pVqxZJSUmsWbOG5s2bExMTw8qVK+3atc6R++2332jSpAlOTk45/lsLIYS4O0mohBDiPhgyZAjPPvss0dHRNGvWjOnTp/PVV1/x2WefcfbsWdzc3Hj00UdtZc9VKhULFy5kypQpPP/885QvX56hQ4dy5coVnJyc8jyWSqVi8eLFLFy4kBkzZnDx4kU8PT2pX78+L7/8MmCp/vbVV18xZ84cMjMzqVatGtOmTbMVTVAUhRkzZnD+/HlcXFwIDAzk888/zzWZGz16NGq1mhkzZnD16lWqV6/OnDlzClS9r6i0bduWGTNmsHTpUubPn0+5cuV47rnnGD58uG2bwYMHc+zYMXr27ElqairLly+/6zXJr/t5LfR6PfPnz+fcuXOo1Wr8/Pz4/PPPbcV
"text/plain": [
"<Figure size 864x576 with 4 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"fig = plt.figure(figsize=(12,8))\n",
"fig = sm.graphics.plot_regress_exog(results, \"lstat\", fig=fig)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.0, 0.05)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZYAAAGNCAYAAAAy6VfOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOydd3gVVd6A35nbb8pNT0iA0JLQIaCggCDFBigqiq6i4IpYVteyfq7uigvsomLZ1VVcFWyIu4INUFB6UUgA6SFACuk9uak3N7fNfH/c5MIlCQQIEJN5n4fHzJwz55yZmPnN+VVBlmUZBQUFBQWFVkK83AtQUFBQUGhfKIJFQUFBQaFVUQSLgoKCgkKroggWBQUFBYVWRREsCgoKCgqtiiJYFBQUFBRaFUWwKLRJPv30UwRBIC0t7byu//jjj4mJiUGr1RIQEABAt27dmDlzZiuusm2SmZmJIAief1qtltjYWJ5++mnKy8s9/WbOnEm3bt3OefytW7cyd+5cJElqxVUrtCcUwaLQ7sjPz2f27NmMGDGCzZs3s3Hjxsu9pMvCCy+8QEJCAhs2bGDmzJl88MEH3HbbbVxo6NrWrVuZN2+eIlgUmkV9uRegoNDapKam4nK5mDFjBqNGjbrcy7ls9OjRg6uuugqAMWPG4HA4mDt3Lvv372fIkCGXeXUK7Rllx6Lwm+Haa69l1KhRbNy4kSFDhmA0Gunfvz/fffedp8/MmTO59tprARg/fjyCIDSr/po7dy6CIDQ635SKqLa2lj//+c90794drVZL9+7dWbBggddX+9atWxEEgdWrV/P4448TEhJCSEgI06dPp6Kiwms8p9PJwoUL6du3L3q9ntDQUG688UaOHTvm6VNSUsIjjzxCVFQUOp2O3r178+GHH57jUzvJlVdeCXBG9WJBQQH3338/ISEh6HQ6Bg4cyLJlyzztc+fOZd68eQBoN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msWbMAMJlM7Ny5k/nz57Nw4ULy8vIICAggLi6OqVOnttYj8MLHx4dt27bx3HPP8fzzz1NdXU1cXByff/4506dP9/SbPHkyjz32GO+99x7z589HluULjuZXaF8Icgf6P+LTTz9l4cKFSJLEjz/+SI8ePbzaJ06cSFlZGevXr2fs2LFERUXx/fffe9r37t3LgAEDKC4uZvz48TzyyCM8+uijTJkyhYqKCnbs2IFa3W5ltYKCgkKL6FCR95MnT/ZESp9uwD906BDp6elMnDiRbdu2NWnAHzp0aKOvU71ez9ixY6moqKC0tPTi3oCCgoLCb4B2/3l9qgG/Qb1hMBgaGfBXrlwJwG233cZbb711Tgb84uJi1Gq1YshUUFBQoJ0KlrKyMoKDgwFYsmQJ7777rlf7rFmzPK6m4HY3XbNmDT179iQ8PJyEhARGjx5NSEjIWedKT09n/fr1jBs3Dh8fn9a9EQUFBYXfIO1SsLz00ktUVFQwbNgwdDodd955JwcPHiQlJQUfH59GQZFbt26loqKCBx98kFWrViFJUiM1GMCyZcuoqqryqNF2797NihUrEEWRadOmXZJ7U1BQUGjrtCvBIkkSFouF6667jtWrV/P1119jNpvRarV069aNp556CkEQmD17Nl9//bXHeP/NN98giiI33XQTs2fPxmQyMXLkSGw2m9f4H330Efn5+Z7jffv2eX4uKCho1F9BQUHht4AsyzgcDnx8fLzCMc6XduUVVl1dTUpKyhn7VFZWejy5TncPTk9PZ86cOVx33XU88MADzY7hdDp54403OHLkCE899RRDhw5tlfUrKCgoXE5iY2NbxVbcrnYsDXmVYmNjm40taNh
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"fig, ax = plt.subplots(figsize=(6,6))\n",
"fig = sm.graphics.influence_plot(results, ax=ax)\n",
"plt.xlim(0.0, 0.05)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Multiple regression"
]
},
{
"cell_type": "code",
"execution_count": 19,
2020-03-28 01:06:31 +00:00
"metadata": {},
"outputs": [],
2020-08-01 22:25:45 +00:00
"source": [
"features = list(Boston.columns)\n",
"features.pop(features.index(\"medv\"))\n",
"features = \"+\".join(features)\n",
"features\n",
"model = smf.ols(\"medv~{}\".format(features), data=Boston).fit()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table class=\"simpletable\">\n",
"<caption>OLS Regression Results</caption>\n",
"<tr>\n",
" <th>Dep. Variable:</th> <td>medv</td> <th> R-squared: </th> <td> 0.741</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Model:</th> <td>OLS</td> <th> Adj. R-squared: </th> <td> 0.734</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Method:</th> <td>Least Squares</td> <th> F-statistic: </th> <td> 108.1</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Date:</th> <td>Sun, 29 Mar 2020</td> <th> Prob (F-statistic):</th> <td>6.72e-135</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Time:</th> <td>09:48:27</td> <th> Log-Likelihood: </th> <td> -1498.8</td> \n",
"</tr>\n",
"<tr>\n",
" <th>No. Observations:</th> <td> 506</td> <th> AIC: </th> <td> 3026.</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Df Residuals:</th> <td> 492</td> <th> BIC: </th> <td> 3085.</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Df Model:</th> <td> 13</td> <th> </th> <td> </td> \n",
"</tr>\n",
"<tr>\n",
" <th>Covariance Type:</th> <td>nonrobust</td> <th> </th> <td> </td> \n",
"</tr>\n",
"</table>\n",
"<table class=\"simpletable\">\n",
"<tr>\n",
" <td></td> <th>coef</th> <th>std err</th> <th>t</th> <th>P>|t|</th> <th>[0.025</th> <th>0.975]</th> \n",
"</tr>\n",
"<tr>\n",
" <th>Intercept</th> <td> 36.4595</td> <td> 5.103</td> <td> 7.144</td> <td> 0.000</td> <td> 26.432</td> <td> 46.487</td>\n",
"</tr>\n",
"<tr>\n",
" <th>crim</th> <td> -0.1080</td> <td> 0.033</td> <td> -3.287</td> <td> 0.001</td> <td> -0.173</td> <td> -0.043</td>\n",
"</tr>\n",
"<tr>\n",
" <th>zn</th> <td> 0.0464</td> <td> 0.014</td> <td> 3.382</td> <td> 0.001</td> <td> 0.019</td> <td> 0.073</td>\n",
"</tr>\n",
"<tr>\n",
" <th>indus</th> <td> 0.0206</td> <td> 0.061</td> <td> 0.334</td> <td> 0.738</td> <td> -0.100</td> <td> 0.141</td>\n",
"</tr>\n",
"<tr>\n",
" <th>chas</th> <td> 2.6867</td> <td> 0.862</td> <td> 3.118</td> <td> 0.002</td> <td> 0.994</td> <td> 4.380</td>\n",
"</tr>\n",
"<tr>\n",
" <th>nox</th> <td> -17.7666</td> <td> 3.820</td> <td> -4.651</td> <td> 0.000</td> <td> -25.272</td> <td> -10.262</td>\n",
"</tr>\n",
"<tr>\n",
" <th>rm</th> <td> 3.8099</td> <td> 0.418</td> <td> 9.116</td> <td> 0.000</td> <td> 2.989</td> <td> 4.631</td>\n",
"</tr>\n",
"<tr>\n",
" <th>age</th> <td> 0.0007</td> <td> 0.013</td> <td> 0.052</td> <td> 0.958</td> <td> -0.025</td> <td> 0.027</td>\n",
"</tr>\n",
"<tr>\n",
" <th>dis</th> <td> -1.4756</td> <td> 0.199</td> <td> -7.398</td> <td> 0.000</td> <td> -1.867</td> <td> -1.084</td>\n",
"</tr>\n",
"<tr>\n",
" <th>rad</th> <td> 0.3060</td> <td> 0.066</td> <td> 4.613</td> <td> 0.000</td> <td> 0.176</td> <td> 0.436</td>\n",
"</tr>\n",
"<tr>\n",
" <th>tax</th> <td> -0.0123</td> <td> 0.004</td> <td> -3.280</td> <td> 0.001</td> <td> -0.020</td> <td> -0.005</td>\n",
"</tr>\n",
"<tr>\n",
" <th>ptratio</th> <td> -0.9527</td> <td> 0.131</td> <td> -7.283</td> <td> 0.000</td> <td> -1.210</td> <td> -0.696</td>\n",
"</tr>\n",
"<tr>\n",
" <th>black</th> <td> 0.0093</td> <td> 0.003</td> <td> 3.467</td> <td> 0.001</td> <td> 0.004</td> <td> 0.015</td>\n",
"</tr>\n",
"<tr>\n",
" <th>lstat</th> <td> -0.5248</td> <td> 0.051</td> <td> -10.347</td> <td> 0.000</td> <td> -0.624</td> <td> -0.425</td>\n",
"</tr>\n",
"</table>\n",
"<table class=\"simpletable\">\n",
"<tr>\n",
" <th>Omnibus:</th> <td>178.041</td> <th> Durbin-Watson: </th> <td> 1.078</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Prob(Omnibus):</th> <td> 0.000</td> <th> Jarque-Bera (JB): </th> <td> 783.126</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Skew:</th> <td> 1.521</td> <th> Prob(JB): </th> <td>8.84e-171</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Kurtosis:</th> <td> 8.281</td> <th> Cond. No. </th> <td>1.51e+04</td> \n",
"</tr>\n",
"</table><br/><br/>Warnings:<br/>[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.<br/>[2] The condition number is large, 1.51e+04. This might indicate that there are<br/>strong multicollinearity or other numerical problems."
],
"text/plain": [
"<class 'statsmodels.iolib.summary.Summary'>\n",
"\"\"\"\n",
" OLS Regression Results \n",
"==============================================================================\n",
"Dep. Variable: medv R-squared: 0.741\n",
"Model: OLS Adj. R-squared: 0.734\n",
"Method: Least Squares F-statistic: 108.1\n",
"Date: Sun, 29 Mar 2020 Prob (F-statistic): 6.72e-135\n",
"Time: 09:48:27 Log-Likelihood: -1498.8\n",
"No. Observations: 506 AIC: 3026.\n",
"Df Residuals: 492 BIC: 3085.\n",
"Df Model: 13 \n",
"Covariance Type: nonrobust \n",
"==============================================================================\n",
" coef std err t P>|t| [0.025 0.975]\n",
"------------------------------------------------------------------------------\n",
"Intercept 36.4595 5.103 7.144 0.000 26.432 46.487\n",
"crim -0.1080 0.033 -3.287 0.001 -0.173 -0.043\n",
"zn 0.0464 0.014 3.382 0.001 0.019 0.073\n",
"indus 0.0206 0.061 0.334 0.738 -0.100 0.141\n",
"chas 2.6867 0.862 3.118 0.002 0.994 4.380\n",
"nox -17.7666 3.820 -4.651 0.000 -25.272 -10.262\n",
"rm 3.8099 0.418 9.116 0.000 2.989 4.631\n",
"age 0.0007 0.013 0.052 0.958 -0.025 0.027\n",
"dis -1.4756 0.199 -7.398 0.000 -1.867 -1.084\n",
"rad 0.3060 0.066 4.613 0.000 0.176 0.436\n",
"tax -0.0123 0.004 -3.280 0.001 -0.020 -0.005\n",
"ptratio -0.9527 0.131 -7.283 0.000 -1.210 -0.696\n",
"black 0.0093 0.003 3.467 0.001 0.004 0.015\n",
"lstat -0.5248 0.051 -10.347 0.000 -0.624 -0.425\n",
"==============================================================================\n",
"Omnibus: 178.041 Durbin-Watson: 1.078\n",
"Prob(Omnibus): 0.000 Jarque-Bera (JB): 783.126\n",
"Skew: 1.521 Prob(JB): 8.84e-171\n",
"Kurtosis: 8.281 Cond. No. 1.51e+04\n",
"==============================================================================\n",
"\n",
"Warnings:\n",
"[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n",
"[2] The condition number is large, 1.51e+04. This might indicate that there are\n",
"strong multicollinearity or other numerical problems.\n",
"\"\"\""
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.summary()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## No working VIF function found in stats\n",
"outliers_influence.variance_inflation_factor(reduced) in statsmodels.stats doesnt work\n"
]
},
{
"cell_type": "code",
"execution_count": 32,
"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>Unnamed: 0</th>\n",
" <th>crim</th>\n",
" <th>zn</th>\n",
" <th>indus</th>\n",
" <th>chas</th>\n",
" <th>nox</th>\n",
" <th>rm</th>\n",
" <th>age</th>\n",
" <th>dis</th>\n",
" <th>rad</th>\n",
" <th>tax</th>\n",
" <th>ptratio</th>\n",
" <th>black</th>\n",
" <th>lstat</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.00632</td>\n",
" <td>18.0</td>\n",
" <td>2.31</td>\n",
" <td>0</td>\n",
" <td>0.538</td>\n",
" <td>6.575</td>\n",
" <td>65.2</td>\n",
" <td>4.0900</td>\n",
" <td>1</td>\n",
" <td>296</td>\n",
" <td>15.3</td>\n",
" <td>396.90</td>\n",
" <td>4.98</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>0.02731</td>\n",
" <td>0.0</td>\n",
" <td>7.07</td>\n",
" <td>0</td>\n",
" <td>0.469</td>\n",
" <td>6.421</td>\n",
" <td>78.9</td>\n",
" <td>4.9671</td>\n",
" <td>2</td>\n",
" <td>242</td>\n",
" <td>17.8</td>\n",
" <td>396.90</td>\n",
" <td>9.14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>0.02729</td>\n",
" <td>0.0</td>\n",
" <td>7.07</td>\n",
" <td>0</td>\n",
" <td>0.469</td>\n",
" <td>7.185</td>\n",
" <td>61.1</td>\n",
" <td>4.9671</td>\n",
" <td>2</td>\n",
" <td>242</td>\n",
" <td>17.8</td>\n",
" <td>392.83</td>\n",
" <td>4.03</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>0.03237</td>\n",
" <td>0.0</td>\n",
" <td>2.18</td>\n",
" <td>0</td>\n",
" <td>0.458</td>\n",
" <td>6.998</td>\n",
" <td>45.8</td>\n",
" <td>6.0622</td>\n",
" <td>3</td>\n",
" <td>222</td>\n",
" <td>18.7</td>\n",
" <td>394.63</td>\n",
" <td>2.94</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>0.06905</td>\n",
" <td>0.0</td>\n",
" <td>2.18</td>\n",
" <td>0</td>\n",
" <td>0.458</td>\n",
" <td>7.147</td>\n",
" <td>54.2</td>\n",
" <td>6.0622</td>\n",
" <td>3</td>\n",
" <td>222</td>\n",
" <td>18.7</td>\n",
" <td>396.90</td>\n",
" <td>5.33</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>501</th>\n",
" <td>502</td>\n",
" <td>0.06263</td>\n",
" <td>0.0</td>\n",
" <td>11.93</td>\n",
" <td>0</td>\n",
" <td>0.573</td>\n",
" <td>6.593</td>\n",
" <td>69.1</td>\n",
" <td>2.4786</td>\n",
" <td>1</td>\n",
" <td>273</td>\n",
" <td>21.0</td>\n",
" <td>391.99</td>\n",
" <td>9.67</td>\n",
" </tr>\n",
" <tr>\n",
" <th>502</th>\n",
" <td>503</td>\n",
" <td>0.04527</td>\n",
" <td>0.0</td>\n",
" <td>11.93</td>\n",
" <td>0</td>\n",
" <td>0.573</td>\n",
" <td>6.120</td>\n",
" <td>76.7</td>\n",
" <td>2.2875</td>\n",
" <td>1</td>\n",
" <td>273</td>\n",
" <td>21.0</td>\n",
" <td>396.90</td>\n",
" <td>9.08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>503</th>\n",
" <td>504</td>\n",
" <td>0.06076</td>\n",
" <td>0.0</td>\n",
" <td>11.93</td>\n",
" <td>0</td>\n",
" <td>0.573</td>\n",
" <td>6.976</td>\n",
" <td>91.0</td>\n",
" <td>2.1675</td>\n",
" <td>1</td>\n",
" <td>273</td>\n",
" <td>21.0</td>\n",
" <td>396.90</td>\n",
" <td>5.64</td>\n",
" </tr>\n",
" <tr>\n",
" <th>504</th>\n",
" <td>505</td>\n",
" <td>0.10959</td>\n",
" <td>0.0</td>\n",
" <td>11.93</td>\n",
" <td>0</td>\n",
" <td>0.573</td>\n",
" <td>6.794</td>\n",
" <td>89.3</td>\n",
" <td>2.3889</td>\n",
" <td>1</td>\n",
" <td>273</td>\n",
" <td>21.0</td>\n",
" <td>393.45</td>\n",
" <td>6.48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>505</th>\n",
" <td>506</td>\n",
" <td>0.04741</td>\n",
" <td>0.0</td>\n",
" <td>11.93</td>\n",
" <td>0</td>\n",
" <td>0.573</td>\n",
" <td>6.030</td>\n",
" <td>80.8</td>\n",
" <td>2.5050</td>\n",
" <td>1</td>\n",
" <td>273</td>\n",
" <td>21.0</td>\n",
" <td>396.90</td>\n",
" <td>7.88</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>506 rows × 14 columns</p>\n",
"</div>"
],
"text/plain": [
" Unnamed: 0 crim zn indus chas nox rm age dis rad \\\n",
"0 1 0.00632 18.0 2.31 0 0.538 6.575 65.2 4.0900 1 \n",
"1 2 0.02731 0.0 7.07 0 0.469 6.421 78.9 4.9671 2 \n",
"2 3 0.02729 0.0 7.07 0 0.469 7.185 61.1 4.9671 2 \n",
"3 4 0.03237 0.0 2.18 0 0.458 6.998 45.8 6.0622 3 \n",
"4 5 0.06905 0.0 2.18 0 0.458 7.147 54.2 6.0622 3 \n",
".. ... ... ... ... ... ... ... ... ... ... \n",
"501 502 0.06263 0.0 11.93 0 0.573 6.593 69.1 2.4786 1 \n",
"502 503 0.04527 0.0 11.93 0 0.573 6.120 76.7 2.2875 1 \n",
"503 504 0.06076 0.0 11.93 0 0.573 6.976 91.0 2.1675 1 \n",
"504 505 0.10959 0.0 11.93 0 0.573 6.794 89.3 2.3889 1 \n",
"505 506 0.04741 0.0 11.93 0 0.573 6.030 80.8 2.5050 1 \n",
"\n",
" tax ptratio black lstat \n",
"0 296 15.3 396.90 4.98 \n",
"1 242 17.8 396.90 9.14 \n",
"2 242 17.8 392.83 4.03 \n",
"3 222 18.7 394.63 2.94 \n",
"4 222 18.7 396.90 5.33 \n",
".. ... ... ... ... \n",
"501 273 21.0 391.99 9.67 \n",
"502 273 21.0 396.90 9.08 \n",
"503 273 21.0 396.90 5.64 \n",
"504 273 21.0 393.45 6.48 \n",
"505 273 21.0 396.90 7.88 \n",
"\n",
"[506 rows x 14 columns]"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
2020-03-28 01:06:31 +00:00
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}