Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save STHITAPRAJNAS/d4b02ae59732be9ad1797b13aeba49f2 to your computer and use it in GitHub Desktop.
Save STHITAPRAJNAS/d4b02ae59732be9ad1797b13aeba49f2 to your computer and use it in GitHub Desktop.
Created on Cognitive Class Labs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<a href=\"https://www.bigdatauniversity.com\"><img src=\"https://ibm.box.com/shared/static/cw2c7r3o20w9zn8gkecaeyjhgw3xdgbj.png\" width=\"400\" align=\"center\"></a>\n",
"\n",
"<h1><center>Multiple Linear Regression</center></h1>\n",
"\n",
"<h4>About this Notebook</h4>\n",
"In this notebook, we learn how to use scikit-learn to implement Multiple linear regression. We download a dataset that is related to fuel consumption and Carbon dioxide emission of cars. Then, we split our data into training and test sets, create a model using training set, Evaluate your model using test set, and finally use model to predict unknown value\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1>Table of contents</h1>\n",
"\n",
"<div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n",
" <ol>\n",
" <li><a href=\"#understanding-data\">Understanding the Data</a></li>\n",
" <li><a href=\"#reading_data\">Reading the Data in</a></li>\n",
" <li><a href=\"#multiple_regression_model\">Multiple Regression Model</a></li>\n",
" <li><a href=\"#prediction\">Prediction</a></li>\n",
" <li><a href=\"#practice\">Practice</a></li>\n",
" </ol>\n",
"</div>\n",
"<br>\n",
"<hr>"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Importing Needed packages"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import pylab as pl\n",
"import numpy as np\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"### Downloading Data\n",
"To download the data, we will use !wget to download it from IBM Object Storage."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2019-09-07 19:05:58-- https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/ML0101ENv3/labs/FuelConsumptionCo2.csv\n",
"Resolving s3-api.us-geo.objectstorage.softlayer.net (s3-api.us-geo.objectstorage.softlayer.net)... 67.228.254.193\n",
"Connecting to s3-api.us-geo.objectstorage.softlayer.net (s3-api.us-geo.objectstorage.softlayer.net)|67.228.254.193|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 72629 (71K) [text/csv]\n",
"Saving to: ‘FuelConsumption.csv’\n",
"\n",
"FuelConsumption.csv 100%[===================>] 70.93K --.-KB/s in 0.04s \n",
"\n",
"2019-09-07 19:05:58 (1.64 MB/s) - ‘FuelConsumption.csv’ saved [72629/72629]\n",
"\n"
]
}
],
"source": [
"!wget -O FuelConsumption.csv https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/ML0101ENv3/labs/FuelConsumptionCo2.csv"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"__Did you know?__ When it comes to Machine Learning, you will likely be working with large datasets. As a business, where can you host your data? IBM is offering a unique opportunity for businesses, with 10 Tb of IBM Cloud Object Storage: [Sign up now for free](http://cocl.us/ML0101EN-IBM-Offer-CC)"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"\n",
"<h2 id=\"understanding_data\">Understanding the Data</h2>\n",
"\n",
"### `FuelConsumption.csv`:\n",
"We have downloaded a fuel consumption dataset, **`FuelConsumption.csv`**, which contains model-specific fuel consumption ratings and estimated carbon dioxide emissions for new light-duty vehicles for retail sale in Canada. [Dataset source](http://open.canada.ca/data/en/dataset/98f1a129-f628-4ce4-b24d-6f16bf24dd64)\n",
"\n",
"- **MODELYEAR** e.g. 2014\n",
"- **MAKE** e.g. Acura\n",
"- **MODEL** e.g. ILX\n",
"- **VEHICLE CLASS** e.g. SUV\n",
"- **ENGINE SIZE** e.g. 4.7\n",
"- **CYLINDERS** e.g 6\n",
"- **TRANSMISSION** e.g. A6\n",
"- **FUELTYPE** e.g. z\n",
"- **FUEL CONSUMPTION in CITY(L/100 km)** e.g. 9.9\n",
"- **FUEL CONSUMPTION in HWY (L/100 km)** e.g. 8.9\n",
"- **FUEL CONSUMPTION COMB (L/100 km)** e.g. 9.2\n",
"- **CO2 EMISSIONS (g/km)** e.g. 182 --> low --> 0\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<h2 id=\"reading_data\">Reading the data in</h2>"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"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>MODELYEAR</th>\n",
" <th>MAKE</th>\n",
" <th>MODEL</th>\n",
" <th>VEHICLECLASS</th>\n",
" <th>ENGINESIZE</th>\n",
" <th>CYLINDERS</th>\n",
" <th>TRANSMISSION</th>\n",
" <th>FUELTYPE</th>\n",
" <th>FUELCONSUMPTION_CITY</th>\n",
" <th>FUELCONSUMPTION_HWY</th>\n",
" <th>FUELCONSUMPTION_COMB</th>\n",
" <th>FUELCONSUMPTION_COMB_MPG</th>\n",
" <th>CO2EMISSIONS</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>0</td>\n",
" <td>2014</td>\n",
" <td>ACURA</td>\n",
" <td>ILX</td>\n",
" <td>COMPACT</td>\n",
" <td>2.0</td>\n",
" <td>4</td>\n",
" <td>AS5</td>\n",
" <td>Z</td>\n",
" <td>9.9</td>\n",
" <td>6.7</td>\n",
" <td>8.5</td>\n",
" <td>33</td>\n",
" <td>196</td>\n",
" </tr>\n",
" <tr>\n",
" <td>1</td>\n",
" <td>2014</td>\n",
" <td>ACURA</td>\n",
" <td>ILX</td>\n",
" <td>COMPACT</td>\n",
" <td>2.4</td>\n",
" <td>4</td>\n",
" <td>M6</td>\n",
" <td>Z</td>\n",
" <td>11.2</td>\n",
" <td>7.7</td>\n",
" <td>9.6</td>\n",
" <td>29</td>\n",
" <td>221</td>\n",
" </tr>\n",
" <tr>\n",
" <td>2</td>\n",
" <td>2014</td>\n",
" <td>ACURA</td>\n",
" <td>ILX HYBRID</td>\n",
" <td>COMPACT</td>\n",
" <td>1.5</td>\n",
" <td>4</td>\n",
" <td>AV7</td>\n",
" <td>Z</td>\n",
" <td>6.0</td>\n",
" <td>5.8</td>\n",
" <td>5.9</td>\n",
" <td>48</td>\n",
" <td>136</td>\n",
" </tr>\n",
" <tr>\n",
" <td>3</td>\n",
" <td>2014</td>\n",
" <td>ACURA</td>\n",
" <td>MDX 4WD</td>\n",
" <td>SUV - SMALL</td>\n",
" <td>3.5</td>\n",
" <td>6</td>\n",
" <td>AS6</td>\n",
" <td>Z</td>\n",
" <td>12.7</td>\n",
" <td>9.1</td>\n",
" <td>11.1</td>\n",
" <td>25</td>\n",
" <td>255</td>\n",
" </tr>\n",
" <tr>\n",
" <td>4</td>\n",
" <td>2014</td>\n",
" <td>ACURA</td>\n",
" <td>RDX AWD</td>\n",
" <td>SUV - SMALL</td>\n",
" <td>3.5</td>\n",
" <td>6</td>\n",
" <td>AS6</td>\n",
" <td>Z</td>\n",
" <td>12.1</td>\n",
" <td>8.7</td>\n",
" <td>10.6</td>\n",
" <td>27</td>\n",
" <td>244</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" MODELYEAR MAKE MODEL VEHICLECLASS ENGINESIZE CYLINDERS \\\n",
"0 2014 ACURA ILX COMPACT 2.0 4 \n",
"1 2014 ACURA ILX COMPACT 2.4 4 \n",
"2 2014 ACURA ILX HYBRID COMPACT 1.5 4 \n",
"3 2014 ACURA MDX 4WD SUV - SMALL 3.5 6 \n",
"4 2014 ACURA RDX AWD SUV - SMALL 3.5 6 \n",
"\n",
" TRANSMISSION FUELTYPE FUELCONSUMPTION_CITY FUELCONSUMPTION_HWY \\\n",
"0 AS5 Z 9.9 6.7 \n",
"1 M6 Z 11.2 7.7 \n",
"2 AV7 Z 6.0 5.8 \n",
"3 AS6 Z 12.7 9.1 \n",
"4 AS6 Z 12.1 8.7 \n",
"\n",
" FUELCONSUMPTION_COMB FUELCONSUMPTION_COMB_MPG CO2EMISSIONS \n",
"0 8.5 33 196 \n",
"1 9.6 29 221 \n",
"2 5.9 48 136 \n",
"3 11.1 25 255 \n",
"4 10.6 27 244 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv(\"FuelConsumption.csv\")\n",
"\n",
"# take a look at the dataset\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets select some features that we want to use for regression."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"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>ENGINESIZE</th>\n",
" <th>CYLINDERS</th>\n",
" <th>FUELCONSUMPTION_CITY</th>\n",
" <th>FUELCONSUMPTION_HWY</th>\n",
" <th>FUELCONSUMPTION_COMB</th>\n",
" <th>CO2EMISSIONS</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>0</td>\n",
" <td>2.0</td>\n",
" <td>4</td>\n",
" <td>9.9</td>\n",
" <td>6.7</td>\n",
" <td>8.5</td>\n",
" <td>196</td>\n",
" </tr>\n",
" <tr>\n",
" <td>1</td>\n",
" <td>2.4</td>\n",
" <td>4</td>\n",
" <td>11.2</td>\n",
" <td>7.7</td>\n",
" <td>9.6</td>\n",
" <td>221</td>\n",
" </tr>\n",
" <tr>\n",
" <td>2</td>\n",
" <td>1.5</td>\n",
" <td>4</td>\n",
" <td>6.0</td>\n",
" <td>5.8</td>\n",
" <td>5.9</td>\n",
" <td>136</td>\n",
" </tr>\n",
" <tr>\n",
" <td>3</td>\n",
" <td>3.5</td>\n",
" <td>6</td>\n",
" <td>12.7</td>\n",
" <td>9.1</td>\n",
" <td>11.1</td>\n",
" <td>255</td>\n",
" </tr>\n",
" <tr>\n",
" <td>4</td>\n",
" <td>3.5</td>\n",
" <td>6</td>\n",
" <td>12.1</td>\n",
" <td>8.7</td>\n",
" <td>10.6</td>\n",
" <td>244</td>\n",
" </tr>\n",
" <tr>\n",
" <td>5</td>\n",
" <td>3.5</td>\n",
" <td>6</td>\n",
" <td>11.9</td>\n",
" <td>7.7</td>\n",
" <td>10.0</td>\n",
" <td>230</td>\n",
" </tr>\n",
" <tr>\n",
" <td>6</td>\n",
" <td>3.5</td>\n",
" <td>6</td>\n",
" <td>11.8</td>\n",
" <td>8.1</td>\n",
" <td>10.1</td>\n",
" <td>232</td>\n",
" </tr>\n",
" <tr>\n",
" <td>7</td>\n",
" <td>3.7</td>\n",
" <td>6</td>\n",
" <td>12.8</td>\n",
" <td>9.0</td>\n",
" <td>11.1</td>\n",
" <td>255</td>\n",
" </tr>\n",
" <tr>\n",
" <td>8</td>\n",
" <td>3.7</td>\n",
" <td>6</td>\n",
" <td>13.4</td>\n",
" <td>9.5</td>\n",
" <td>11.6</td>\n",
" <td>267</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ENGINESIZE CYLINDERS FUELCONSUMPTION_CITY FUELCONSUMPTION_HWY \\\n",
"0 2.0 4 9.9 6.7 \n",
"1 2.4 4 11.2 7.7 \n",
"2 1.5 4 6.0 5.8 \n",
"3 3.5 6 12.7 9.1 \n",
"4 3.5 6 12.1 8.7 \n",
"5 3.5 6 11.9 7.7 \n",
"6 3.5 6 11.8 8.1 \n",
"7 3.7 6 12.8 9.0 \n",
"8 3.7 6 13.4 9.5 \n",
"\n",
" FUELCONSUMPTION_COMB CO2EMISSIONS \n",
"0 8.5 196 \n",
"1 9.6 221 \n",
"2 5.9 136 \n",
"3 11.1 255 \n",
"4 10.6 244 \n",
"5 10.0 230 \n",
"6 10.1 232 \n",
"7 11.1 255 \n",
"8 11.6 267 "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cdf = df[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_CITY','FUELCONSUMPTION_HWY','FUELCONSUMPTION_COMB','CO2EMISSIONS']]\n",
"cdf.head(9)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets plot Emission values with respect to Engine size:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
},
"scrolled": true
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEHCAYAAAB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0A4dv5iTn6PgIstrCOsZkNmdnK1ovM7Ax3/5q7/x7wDHBayyVXAQ+6+02Rti8CG0ITFWZ2Vo8XvBEzCM0UxGxifmjeaXC7u7cLS/048NnQ9/APBOaf57M8yN1fCc07f25mryX4v/ZJYE/LpX9sZmcSvP3vAh4AfiFy/kPAnojcv0dQWnQ5cF/o1D4MvCOLXEKkoZBUIRIws3nAUXc/Er7xX9PGJyFEX6CZghDJLANuNrMB4BXg12uWR4jK0UxBCCHEJHI0CyGEmERKQQghxCRSCkIIISaRUhBCCDGJlIIQQohJpBSEEEJM8v8B1Ou58Axie6kAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(cdf.ENGINESIZE, cdf.CO2EMISSIONS, color='blue')\n",
"plt.xlabel(\"Engine size\")\n",
"plt.ylabel(\"Emission\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Creating train and test dataset\n",
"Train/Test Split involves splitting the dataset into training and testing sets respectively, which are mutually exclusive. After which, you train with the training set and test with the testing set. \n",
"This will provide a more accurate evaluation on out-of-sample accuracy because the testing dataset is not part of the dataset that have been used to train the data. It is more realistic for real world problems.\n",
"\n",
"This means that we know the outcome of each data point in this dataset, making it great to test with! And since this data has not been used to train the model, the model has no knowledge of the outcome of these data points. So, in essence, it’s truly an out-of-sample testing.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [],
"source": [
"msk = np.random.rand(len(df)) < 0.8\n",
"train = cdf[msk]\n",
"test = cdf[~msk]"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"#### Train data distribution"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEHCAYAAABBW1qbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dfZAc9X3n8fd3H4T1YBtYyZRASOKI4pzk2MJsCD5SCWHBEOwCnIs5+RaXKqQikEiCk3P5UHQX26lTijw4Mbk7yShGsoI21imxc6YIAYMMyTlxTFZYYCTMoRySkNGBAGMjm5OQ+N4f3bPbO+rn6Z6Z3f28qrpm9jfdPb+dlfo7/Xv4/szdERERAejpdAVERKR7KCiIiMgYBQURERmjoCAiImMUFEREZIyCgoiIjOmr8+Rmth94DTgJnHD3QTM7E/gfwGJgP3C9u38v3H8t8Cvh/r/h7g+knX/u3Lm+ePHiuqovIjIl7dq16yV3nxf3Wq1BIfTz7v5S5OfbgJ3ufruZ3Rb+/B/NbCmwAlgGnA08ZGY/7u4nk068ePFiRkdH66y7iMiUY2YHkl7rRPPRtcDW8PlW4LpI+XZ3P+buzwL7gIs6UD8RkWmr7qDgwFfNbJeZrQrLznL3wwDh4zvC8nOA5yLHHgrLRESkTepuPrrE3Z83s3cAD5rZd1L2tZiyU3JwhMFlFcDChQurqaWIiAA13ym4+/Ph44vAXxM0B71gZvMBwscXw90PAedGDl8APB9zzk3uPujug/PmxfaTiIhISbUFBTObbWZvbTwH3g88CdwDrAx3Wwl8JXx+D7DCzE4zs/OAJcCjddVPREROVeedwlnA183scYKL+9+4+/3A7cAVZvYMcEX4M+6+B9gB7AXuB25JG3kkItPLyAgsXgw9PcHjyEinazQ12WROnT04OOgakioy9Y2MwKpV8KMfjZfNmgWbNsHwcOfqNVmZ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r7zWb20wQLAe02swlBK1xBbDvwu+7eSJJnwK+7+wM56yeSm5qPRJJ9HbgeIPx2fkaBY58G5lm4jrGZ9ZvZsuadzOx8d/+mu/8O8BJwbtMutwNPuPv2SNkDwOqwiQoz+/EuX/BGJhHdKch0MjNs3mm4393ThqV+Gvhi2PfwdwTNP6/leSN3Px427/ypmb2d4P/aZ4E9Tbv+oZktIfj2vxN4HPi5yOsfB/ZE6v07BEuLLgYeCzu1jwDX5amXSBYNSRVJYGanASfd/UT4jX9jSp+EyJSgOwWRZAuBHWbWAxwHfrXD9RGpne4URERkjDqaRURkjIKCiIiMUVAQEZExCgoiIjJGQUFERMYoKIiIyJj/D5RNTCQNTGe3AAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(train.ENGINESIZE, train.CO2EMISSIONS, color='blue')\n",
"plt.xlabel(\"Engine size\")\n",
"plt.ylabel(\"Emission\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<h2 id=\"multiple_regression_model\">Multiple Regression Model</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In reality, there are multiple variables that predict the Co2emission. When more than one independent variable is present, the process is called multiple linear regression. For example, predicting co2emission using FUELCONSUMPTION_COMB, EngineSize and Cylinders of cars. The good thing here is that Multiple linear regression is the extension of simple linear regression model."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Coefficients: [[10.88991587 7.11332999 9.94815352]]\n"
]
}
],
"source": [
"from sklearn import linear_model\n",
"regr = linear_model.LinearRegression()\n",
"x = np.asanyarray(train[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_COMB']])\n",
"y = np.asanyarray(train[['CO2EMISSIONS']])\n",
"regr.fit (x, y)\n",
"# The coefficients\n",
"print ('Coefficients: ', regr.coef_)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([63.57236007])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"regr.intercept_"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As mentioned before, __Coefficient__ and __Intercept__ , are the parameters of the fit line. \n",
"Given that it is a multiple linear regression, with 3 parameters, and knowing that the parameters are the intercept and coefficients of hyperplane, sklearn can estimate them from our data. Scikit-learn uses plain Ordinary Least Squares method to solve this problem.\n",
"\n",
"#### Ordinary Least Squares (OLS)\n",
"OLS is a method for estimating the unknown parameters in a linear regression model. OLS chooses the parameters of a linear function of a set of explanatory variables by minimizing the sum of the squares of the differences between the target dependent variable and those predicted by the linear function. In other words, it tries to minimizes the sum of squared errors (SSE) or mean squared error (MSE) between the target variable (y) and our predicted output ($\\hat{y}$) over all samples in the dataset.\n",
"\n",
"OLS can find the best parameters using of the following methods:\n",
" - Solving the model parameters analytically using closed-form equations\n",
" - Using an optimization algorithm (Gradient Descent, Stochastic Gradient Descent, Newton’s Method, etc.)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"prediction\">Prediction</h2>"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Residual sum of squares: 495.89\n",
"Variance score: 0.86\n"
]
}
],
"source": [
"y_hat= regr.predict(test[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_COMB']])\n",
"x = np.asanyarray(test[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_COMB']])\n",
"y = np.asanyarray(test[['CO2EMISSIONS']])\n",
"print(\"Residual sum of squares: %.2f\"\n",
" % np.mean((y_hat - y) ** 2))\n",
"\n",
"# Explained variance score: 1 is perfect prediction\n",
"print('Variance score: %.2f' % regr.score(x, y))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"__explained variance regression score:__ \n",
"If $\\hat{y}$ is the estimated target output, y the corresponding (correct) target output, and Var is Variance, the square of the standard deviation, then the explained variance is estimated as follow:\n",
"\n",
"$\\texttt{explainedVariance}(y, \\hat{y}) = 1 - \\frac{Var\\{ y - \\hat{y}\\}}{Var\\{y\\}}$ \n",
"The best possible score is 1.0, lower values are worse."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"practice\">Practice</h2>\n",
"Try to use a multiple linear regression with the same dataset but this time use __FUEL CONSUMPTION in CITY__ and \n",
"__FUEL CONSUMPTION in HWY__ instead of FUELCONSUMPTION_COMB. Does it result in better accuracy?"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Coefficients: [[11.00836005 6.62874911 6.7465043 2.78417258]]\n",
"Residual sum of squares: 500.93\n",
"Variance score: 0.86\n"
]
}
],
"source": [
"# write your code here\n",
"\n",
"regr = linear_model.LinearRegression()\n",
"x = np.asanyarray(train[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_CITY','FUELCONSUMPTION_HWY']])\n",
"y = np.asanyarray(train[['CO2EMISSIONS']])\n",
"regr.fit (x, y)\n",
"print ('Coefficients: ', regr.coef_)\n",
"y_= regr.predict(test[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_CITY','FUELCONSUMPTION_HWY']])\n",
"x = np.asanyarray(test[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_CITY','FUELCONSUMPTION_HWY']])\n",
"y = np.asanyarray(test[['CO2EMISSIONS']])\n",
"print(\"Residual sum of squares: %.2f\"% np.mean((y_ - y) ** 2))\n",
"print('Variance score: %.2f' % regr.score(x, y))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"\n",
"regr = linear_model.LinearRegression()\n",
"x = np.asanyarray(train[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_CITY','FUELCONSUMPTION_HWY']])\n",
"y = np.asanyarray(train[['CO2EMISSIONS']])\n",
"regr.fit (x, y)\n",
"print ('Coefficients: ', regr.coef_)\n",
"y_= regr.predict(test[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_CITY','FUELCONSUMPTION_HWY']])\n",
"x = np.asanyarray(test[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_CITY','FUELCONSUMPTION_HWY']])\n",
"y = np.asanyarray(test[['CO2EMISSIONS']])\n",
"print(\"Residual sum of squares: %.2f\"% np.mean((y_ - y) ** 2))\n",
"print('Variance score: %.2f' % regr.score(x, y))\n",
"\n",
"\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {
"button": false,
"deletable": true,
"new_sheet": false,
"run_control": {
"read_only": false
}
},
"source": [
"<h2>Want to learn more?</h2>\n",
"\n",
"IBM SPSS Modeler is a comprehensive analytics platform that has many machine learning algorithms. It has been designed to bring predictive intelligence to decisions made by individuals, by groups, by systems – by your enterprise as a whole. A free trial is available through this course, available here: <a href=\"http://cocl.us/ML0101EN-SPSSModeler\">SPSS Modeler</a>\n",
"\n",
"Also, you can use Watson Studio to run these notebooks faster with bigger datasets. Watson Studio is IBM's leading cloud solution for data scientists, built by data scientists. With Jupyter notebooks, RStudio, Apache Spark and popular libraries pre-packaged in the cloud, Watson Studio enables data scientists to collaborate on their projects without having to install anything. Join the fast-growing community of Watson Studio users today with a free account at <a href=\"https://cocl.us/ML0101EN_DSX\">Watson Studio</a>\n",
"\n",
"<h3>Thanks for completing this lesson!</h3>\n",
"\n",
"<h4>Author: <a href=\"https://ca.linkedin.com/in/saeedaghabozorgi\">Saeed Aghabozorgi</a></h4>\n",
"<p><a href=\"https://ca.linkedin.com/in/saeedaghabozorgi\">Saeed Aghabozorgi</a>, PhD is a Data Scientist in IBM with a track record of developing enterprise level applications that substantially increases clients’ ability to turn data into actionable knowledge. He is a researcher in data mining field and expert in developing advanced analytic methods like machine learning and statistical modelling on large datasets.</p>\n",
"\n",
"<hr>\n",
"\n",
"<p>Copyright &copy; 2018 <a href=\"https://cocl.us/DX0108EN_CC\">Cognitive Class</a>. This notebook and its source code are released under the terms of the <a href=\"https://bigdatauniversity.com/mit-license/\">MIT License</a>.</p>"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python",
"language": "python",
"name": "conda-env-python-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
},
"widgets": {
"state": {},
"version": "1.1.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment