Skip to content

Commit 317b6e9

Browse files
committed
Merge branch 'master' of https://github.com/codebasics/py
2 parents 46deb0a + b84c2cd commit 317b6e9

File tree

3 files changed

+58
-30
lines changed

3 files changed

+58
-30
lines changed

ML/2_linear_reg_multivariate/2_linear_regression_multivariate.ipynb

+57-30
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@
3232
"cell_type": "markdown",
3333
"metadata": {},
3434
"source": [
35-
"We will use regression with multiple variables here. Price can be calculated as following equation,"
35+
"Given these home prices find out price of a home that has,\n",
36+
"\n",
37+
"**3000 sqr ft area, 3 bedrooms, 40 year old**\n",
38+
"\n",
39+
"**2500 sqr ft area, 4 bedrooms, 5 year old**"
40+
]
41+
},
42+
{
43+
"cell_type": "markdown",
44+
"metadata": {},
45+
"source": [
46+
"We will use regression with multiple variables here. Price can be calculated using following equation,"
3647
]
3748
},
3849
{
@@ -51,7 +62,7 @@
5162
},
5263
{
5364
"cell_type": "code",
54-
"execution_count": 49,
65+
"execution_count": 44,
5566
"metadata": {
5667
"collapsed": true
5768
},
@@ -64,7 +75,7 @@
6475
},
6576
{
6677
"cell_type": "code",
67-
"execution_count": 18,
78+
"execution_count": 45,
6879
"metadata": {
6980
"scrolled": true
7081
},
@@ -132,6 +143,13 @@
132143
" <td>8</td>\n",
133144
" <td>760000</td>\n",
134145
" </tr>\n",
146+
" <tr>\n",
147+
" <th>5</th>\n",
148+
" <td>4100</td>\n",
149+
" <td>6.0</td>\n",
150+
" <td>8</td>\n",
151+
" <td>810000</td>\n",
152+
" </tr>\n",
135153
" </tbody>\n",
136154
"</table>\n",
137155
"</div>"
@@ -142,10 +160,11 @@
142160
"1 3000 4.0 15 565000\n",
143161
"2 3200 NaN 18 610000\n",
144162
"3 3600 3.0 30 595000\n",
145-
"4 4000 5.0 8 760000"
163+
"4 4000 5.0 8 760000\n",
164+
"5 4100 6.0 8 810000"
146165
]
147166
},
148-
"execution_count": 18,
167+
"execution_count": 45,
149168
"metadata": {},
150169
"output_type": "execute_result"
151170
}
@@ -164,7 +183,7 @@
164183
},
165184
{
166185
"cell_type": "code",
167-
"execution_count": 35,
186+
"execution_count": 46,
168187
"metadata": {
169188
"collapsed": true
170189
},
@@ -176,7 +195,7 @@
176195
},
177196
{
178197
"cell_type": "code",
179-
"execution_count": 37,
198+
"execution_count": 47,
180199
"metadata": {
181200
"collapsed": true
182201
},
@@ -187,7 +206,7 @@
187206
},
188207
{
189208
"cell_type": "code",
190-
"execution_count": 38,
209+
"execution_count": 48,
191210
"metadata": {},
192211
"outputs": [
193212
{
@@ -235,7 +254,7 @@
235254
" <tr>\n",
236255
" <th>2</th>\n",
237256
" <td>3200</td>\n",
238-
" <td>3.0</td>\n",
257+
" <td>4.0</td>\n",
239258
" <td>18</td>\n",
240259
" <td>610000</td>\n",
241260
" </tr>\n",
@@ -253,6 +272,13 @@
253272
" <td>8</td>\n",
254273
" <td>760000</td>\n",
255274
" </tr>\n",
275+
" <tr>\n",
276+
" <th>5</th>\n",
277+
" <td>4100</td>\n",
278+
" <td>6.0</td>\n",
279+
" <td>8</td>\n",
280+
" <td>810000</td>\n",
281+
" </tr>\n",
256282
" </tbody>\n",
257283
"</table>\n",
258284
"</div>"
@@ -261,12 +287,13 @@
261287
" area bedrooms age price\n",
262288
"0 2600 3.0 20 550000\n",
263289
"1 3000 4.0 15 565000\n",
264-
"2 3200 3.0 18 610000\n",
290+
"2 3200 4.0 18 610000\n",
265291
"3 3600 3.0 30 595000\n",
266-
"4 4000 5.0 8 760000"
292+
"4 4000 5.0 8 760000\n",
293+
"5 4100 6.0 8 810000"
267294
]
268295
},
269-
"execution_count": 38,
296+
"execution_count": 48,
270297
"metadata": {},
271298
"output_type": "execute_result"
272299
}
@@ -277,7 +304,7 @@
277304
},
278305
{
279306
"cell_type": "code",
280-
"execution_count": 39,
307+
"execution_count": 49,
281308
"metadata": {
282309
"scrolled": true
283310
},
@@ -288,7 +315,7 @@
288315
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)"
289316
]
290317
},
291-
"execution_count": 39,
318+
"execution_count": 49,
292319
"metadata": {},
293320
"output_type": "execute_result"
294321
}
@@ -300,16 +327,16 @@
300327
},
301328
{
302329
"cell_type": "code",
303-
"execution_count": 40,
330+
"execution_count": 50,
304331
"metadata": {},
305332
"outputs": [
306333
{
307334
"data": {
308335
"text/plain": [
309-
"array([ 137.25, -26025. , -6825. ])"
336+
"array([ 112.06244194, 23388.88007794, -3231.71790863])"
310337
]
311338
},
312-
"execution_count": 40,
339+
"execution_count": 50,
313340
"metadata": {},
314341
"output_type": "execute_result"
315342
}
@@ -320,18 +347,18 @@
320347
},
321348
{
322349
"cell_type": "code",
323-
"execution_count": 41,
350+
"execution_count": 51,
324351
"metadata": {
325352
"scrolled": true
326353
},
327354
"outputs": [
328355
{
329356
"data": {
330357
"text/plain": [
331-
"383724.99999999983"
358+
"221323.00186540384"
332359
]
333360
},
334-
"execution_count": 41,
361+
"execution_count": 51,
335362
"metadata": {},
336363
"output_type": "execute_result"
337364
}
@@ -349,16 +376,16 @@
349376
},
350377
{
351378
"cell_type": "code",
352-
"execution_count": 43,
379+
"execution_count": 52,
353380
"metadata": {},
354381
"outputs": [
355382
{
356383
"data": {
357384
"text/plain": [
358-
"array([ 444400.])"
385+
"array([ 498408.25158031])"
359386
]
360387
},
361-
"execution_count": 43,
388+
"execution_count": 52,
362389
"metadata": {},
363390
"output_type": "execute_result"
364391
}
@@ -369,24 +396,24 @@
369396
},
370397
{
371398
"cell_type": "code",
372-
"execution_count": 44,
399+
"execution_count": 55,
373400
"metadata": {
374401
"scrolled": true
375402
},
376403
"outputs": [
377404
{
378405
"data": {
379406
"text/plain": [
380-
"444399.9999999998"
407+
"498408.25157402386"
381408
]
382409
},
383-
"execution_count": 44,
410+
"execution_count": 55,
384411
"metadata": {},
385412
"output_type": "execute_result"
386413
}
387414
],
388415
"source": [
389-
"137.25*3000 + -26025*3 + -6825*40 + 383724.99999999983"
416+
"112.06244194*3000 + 23388.88007794*3 + -3231.71790863*40 + 221323.00186540384"
390417
]
391418
},
392419
{
@@ -398,16 +425,16 @@
398425
},
399426
{
400427
"cell_type": "code",
401-
"execution_count": 45,
428+
"execution_count": 54,
402429
"metadata": {},
403430
"outputs": [
404431
{
405432
"data": {
406433
"text/plain": [
407-
"array([ 588625.])"
434+
"array([ 578876.03748933])"
408435
]
409436
},
410-
"execution_count": 45,
437+
"execution_count": 54,
411438
"metadata": {},
412439
"output_type": "execute_result"
413440
}

ML/2_linear_reg_multivariate/homeprices.csv

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ area,bedrooms,age,price
44
3200,,18,610000
55
3600,3,30,595000
66
4000,5,8,760000
7+
4100,6,8,810000
-5.03 KB
Loading

0 commit comments

Comments
 (0)