Skip to content

Commit

Permalink
updated linear reg multivariant notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
dhavalsays committed Jul 4, 2018
1 parent 77366e2 commit b84c2cd
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 30 deletions.
87 changes: 57 additions & 30 deletions ML/2_linear_reg_multivariate/2_linear_regression_multivariate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We will use regression with multiple variables here. Price can be calculated as following equation,"
"Given these home prices find out price of a home that has,\n",
"\n",
"**3000 sqr ft area, 3 bedrooms, 40 year old**\n",
"\n",
"**2500 sqr ft area, 4 bedrooms, 5 year old**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will use regression with multiple variables here. Price can be calculated using following equation,"
]
},
{
Expand All @@ -51,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 49,
"execution_count": 44,
"metadata": {
"collapsed": true
},
Expand All @@ -64,7 +75,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 45,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -132,6 +143,13 @@
" <td>8</td>\n",
" <td>760000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>4100</td>\n",
" <td>6.0</td>\n",
" <td>8</td>\n",
" <td>810000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
Expand All @@ -142,10 +160,11 @@
"1 3000 4.0 15 565000\n",
"2 3200 NaN 18 610000\n",
"3 3600 3.0 30 595000\n",
"4 4000 5.0 8 760000"
"4 4000 5.0 8 760000\n",
"5 4100 6.0 8 810000"
]
},
"execution_count": 18,
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -164,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 46,
"metadata": {
"collapsed": true
},
Expand All @@ -176,7 +195,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 47,
"metadata": {
"collapsed": true
},
Expand All @@ -187,7 +206,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 48,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -235,7 +254,7 @@
" <tr>\n",
" <th>2</th>\n",
" <td>3200</td>\n",
" <td>3.0</td>\n",
" <td>4.0</td>\n",
" <td>18</td>\n",
" <td>610000</td>\n",
" </tr>\n",
Expand All @@ -253,6 +272,13 @@
" <td>8</td>\n",
" <td>760000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>4100</td>\n",
" <td>6.0</td>\n",
" <td>8</td>\n",
" <td>810000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
Expand All @@ -261,12 +287,13 @@
" area bedrooms age price\n",
"0 2600 3.0 20 550000\n",
"1 3000 4.0 15 565000\n",
"2 3200 3.0 18 610000\n",
"2 3200 4.0 18 610000\n",
"3 3600 3.0 30 595000\n",
"4 4000 5.0 8 760000"
"4 4000 5.0 8 760000\n",
"5 4100 6.0 8 810000"
]
},
"execution_count": 38,
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -277,7 +304,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 49,
"metadata": {
"scrolled": true
},
Expand All @@ -288,7 +315,7 @@
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)"
]
},
"execution_count": 39,
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -300,16 +327,16 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 137.25, -26025. , -6825. ])"
"array([ 112.06244194, 23388.88007794, -3231.71790863])"
]
},
"execution_count": 40,
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -320,18 +347,18 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 51,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"383724.99999999983"
"221323.00186540384"
]
},
"execution_count": 41,
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -349,16 +376,16 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 444400.])"
"array([ 498408.25158031])"
]
},
"execution_count": 43,
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -369,24 +396,24 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 55,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"444399.9999999998"
"498408.25157402386"
]
},
"execution_count": 44,
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"137.25*3000 + -26025*3 + -6825*40 + 383724.99999999983"
"112.06244194*3000 + 23388.88007794*3 + -3231.71790863*40 + 221323.00186540384"
]
},
{
Expand All @@ -398,16 +425,16 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 588625.])"
"array([ 578876.03748933])"
]
},
"execution_count": 45,
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
1 change: 1 addition & 0 deletions ML/2_linear_reg_multivariate/homeprices.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ area,bedrooms,age,price
3200,,18,610000
3600,3,30,595000
4000,5,8,760000
4100,6,8,810000
Binary file modified ML/2_linear_reg_multivariate/homeprices.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b84c2cd

Please sign in to comment.