444 lines
85 KiB
Plaintext
444 lines
85 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 43,
|
||
|
"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",
|
||
|
"import statsmodels.api as sm\n",
|
||
|
"import statsmodels.formula.api as smf\n",
|
||
|
"from sklearn import metrics\n",
|
||
|
"\n",
|
||
|
"sns.set()\n",
|
||
|
"sns.set(style=\"whitegrid\")\n",
|
||
|
"tips = sns.load_dataset(\"tips\")\n",
|
||
|
"plt.rcParams[\"figure.figsize\"] = (8,5)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 27,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"\n",
|
||
|
"def precision_stats(model, y, X):\n",
|
||
|
" pred_y = model.predict(X)\n",
|
||
|
" coefficients = model.coef_\n",
|
||
|
" intercept = model.intercept_\n",
|
||
|
" MSE = metrics.mean_squared_error(y,pred_y)\n",
|
||
|
" # these 3 are all the saem\n",
|
||
|
" score = model.score(X,y)\n",
|
||
|
" explained_var = metrics.explained_variance_score(y, pred_y)\n",
|
||
|
" R2 = metrics.r2_score(y, pred_y)\n",
|
||
|
" # residuals\n",
|
||
|
" res = y - pred_y \n",
|
||
|
" print(\"Residuals info\", res.describe())\n",
|
||
|
" \n",
|
||
|
" print(\"coefficients:\", coefficients)\n",
|
||
|
" print(\"intercept\", intercept)\n",
|
||
|
" \n",
|
||
|
" print(\"MSE\", MSE)\n",
|
||
|
" print(\"explained variance\", explained_var)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"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>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": 6,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"Boston = pd.read_csv(\"../../datasets/Boston.csv\")\n",
|
||
|
"Boston.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 28,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Residuals info count 5.060000e+02\n",
|
||
|
"mean -4.437382e-15\n",
|
||
|
"std 6.209603e+00\n",
|
||
|
"min -1.516745e+01\n",
|
||
|
"25% -3.989612e+00\n",
|
||
|
"50% -1.318186e+00\n",
|
||
|
"75% 2.033701e+00\n",
|
||
|
"max 2.450013e+01\n",
|
||
|
"Name: medv, dtype: float64\n",
|
||
|
"coefficients: [-0.95004935]\n",
|
||
|
"intercept 34.5538408793831\n",
|
||
|
"MSE 38.48296722989415\n",
|
||
|
"explained variance 0.5441462975864798\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 65,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
" 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: Sat, 28 Mar 2020 Prob (F-statistic): 5.08e-88\n",
|
||
|
"Time: 09:39:54 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"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"results = smf.ols('medv ~ lstat', data=Boston).fit()\n",
|
||
|
"print(results.summary())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 66,
|
||
|
"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": 66,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"results.conf_int()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 69,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.axes._subplots.AxesSubplot at 0x7f18fc4f2130>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 69,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfUAAAFCCAYAAADoh0TcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOydeXgU9f3H3zt7J9kkm4QA4VTOCEFDIFwBLAhSK6LSlqgtgkQsYKG2WM5yKBAQqoJVPDgUi8a2/CxyFAVTFTkSCKGQiIAc4UoIJJvNJtl75vfHMpM9Zje7yW4uPq/n8ZHsMfOdCcz7+7klHMdxIAiCIAiixcM09QIIgiAIgggOJOoEQRAE0UogUScIgiCIVgKJOkEQBEG0Elq0qHMcB7PZDMr1IwiCIO4G6tI9WSOvJ6iYzWYUFhaiZ8+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1bFrz9bXmaxOjUUQ9Pz8fBQUFmDt3bsjOkZKSErJjNzV5eXkhv75SXY1oWZ1SpQ75uRvj+poSur6WDV1fy6U1XpvZbEZBQYHX9xvF/X7s2DFcuHABo0ePxqhRo1BSUoJp06ahqKgIN27cED5XXl4OhmECttKJhuNPgx2CIAiiedMoT+zp06fj+++/R3Z2NrKzs9GuXTts3rwZGRkZMJlMOH78OAAgKysL48aNa4wlNTnNLSmNyuoIgiBaPk3afIZhGLz22mtYunSpS0lba6c59nqnsjqCIIiWT5OIenZ2tvDn/v37Y9euXU2xjCbDW6/3dXNGNOmoVpqtThAE0bKhgGkTQL3
|
||
|
"text/plain": [
|
||
|
"<Figure size 576x360 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"residu = results.predict(Boston[\"lstat\"]) - Boston[\"medv\"]\n",
|
||
|
"sns.scatterplot(\"lstat\" ,\"medv\",data=Boston)\n",
|
||
|
"sns.lineplot(Boston[\"lstat\"], results.predict(Boston[\"lstat\"]))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 74,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.axes._subplots.AxesSubplot at 0x7f18fc475340>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 74,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAe0AAAFCCAYAAADc/oXAAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO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Lhwr2wtRyQrySRQM9sg3nP6iz3VWd9LzkYmBUHkG9o3N9oBUhbDstmVeO/4ZQDAuSsu/PbNs5g/eRCeX/ZNbFpUhdIisyCwgbBwW7vzGM5faZC0TpVaJWJLd9ZTB7Hk1x+gxROIWQwTWdHJuuP543l9IcUeAbk5hVjEnHvtzmNwe/wxx4guJ/rLh8MC4LEt+ZFzzFdVi2fhKvmOEqSu98IpQ7Dv/U9ztqWg1twIor1AlnYWkEqx+kv155h6zx24WNOEOpcHLrcXnYqtcDpsAMJWoJRw48uOiq3TZCxnJZauEitazpXq84diLFhxdPzciQMVewTkLK36Ro+s4JeLNufn5nJ78yYiOds5yvz13rBgNL5s8KCx2Y/fvnkW56648mZLgSDaOyS00yDdFKua+hZsWDAaPp8fBQUWwSq+fK0J1xs9ksLN3RoAEBY2LMvhRpMXXl8QNfXN2HvwPFxub8pR4+L5JBJscq7UL10eNHsCKC40wecPoXOxNaI4h9xWgNw+pVT9brlzG/RMyspGOlYk3zAkGeHKshzcrT74AuHrbjLqUVLY9rtc5SgzjA6diq1o9gTwiz3q554TBJEeJLRTRI0Uq6NnajF
|
||
|
"text/plain": [
|
||
|
"<Figure size 576x360 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.scatterplot(residu, Boston[\"lstat\"])\n",
|
||
|
"# sns.lineplot(Boston[\"lstat\"], 0)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"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
|
||
|
}
|