Skip to content

Commit 2769809

Browse files
committed
Fixed an issue in one hot encoding tutorial
1 parent c62e490 commit 2769809

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

ML/5_one_hot_encoding/one_hot_encoding.ipynb

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 203,
12+
"execution_count": 9,
1313
"metadata": {
1414
"collapsed": true
1515
},
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"cell_type": "code",
23-
"execution_count": 204,
23+
"execution_count": 10,
2424
"metadata": {},
2525
"outputs": [
2626
{
@@ -149,7 +149,7 @@
149149
"12 robinsville 3600 695000"
150150
]
151151
},
152-
"execution_count": 204,
152+
"execution_count": 10,
153153
"metadata": {},
154154
"output_type": "execute_result"
155155
}
@@ -168,7 +168,7 @@
168168
},
169169
{
170170
"cell_type": "code",
171-
"execution_count": 205,
171+
"execution_count": 11,
172172
"metadata": {},
173173
"outputs": [
174174
{
@@ -297,7 +297,7 @@
297297
"12 0 1 0"
298298
]
299299
},
300-
"execution_count": 205,
300+
"execution_count": 11,
301301
"metadata": {},
302302
"output_type": "execute_result"
303303
}
@@ -309,7 +309,7 @@
309309
},
310310
{
311311
"cell_type": "code",
312-
"execution_count": 211,
312+
"execution_count": 12,
313313
"metadata": {
314314
"scrolled": true
315315
},
@@ -482,7 +482,7 @@
482482
"12 robinsville 3600 695000 0 1 0"
483483
]
484484
},
485-
"execution_count": 211,
485+
"execution_count": 12,
486486
"metadata": {},
487487
"output_type": "execute_result"
488488
}
@@ -494,7 +494,7 @@
494494
},
495495
{
496496
"cell_type": "code",
497-
"execution_count": 212,
497+
"execution_count": 13,
498498
"metadata": {},
499499
"outputs": [
500500
{
@@ -651,7 +651,7 @@
651651
"12 3600 695000 0 1 0"
652652
]
653653
},
654-
"execution_count": 212,
654+
"execution_count": 13,
655655
"metadata": {},
656656
"output_type": "execute_result"
657657
}
@@ -689,7 +689,7 @@
689689
},
690690
{
691691
"cell_type": "code",
692-
"execution_count": 213,
692+
"execution_count": 14,
693693
"metadata": {},
694694
"outputs": [
695695
{
@@ -832,7 +832,7 @@
832832
"12 3600 695000 0 1"
833833
]
834834
},
835-
"execution_count": 213,
835+
"execution_count": 14,
836836
"metadata": {},
837837
"output_type": "execute_result"
838838
}
@@ -844,7 +844,7 @@
844844
},
845845
{
846846
"cell_type": "code",
847-
"execution_count": 214,
847+
"execution_count": 15,
848848
"metadata": {},
849849
"outputs": [
850850
{
@@ -853,20 +853,23 @@
853853
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)"
854854
]
855855
},
856-
"execution_count": 214,
856+
"execution_count": 15,
857857
"metadata": {},
858858
"output_type": "execute_result"
859859
}
860860
],
861861
"source": [
862862
"X = df_dummies.drop('price',axis='columns')\n",
863863
"y = df_dummies.price\n",
864+
"\n",
865+
"from sklearn.linear_model import LinearRegression\n",
866+
"model = LinearRegression()\n",
864867
"model.fit(X,y)"
865868
]
866869
},
867870
{
868871
"cell_type": "code",
869-
"execution_count": 215,
872+
"execution_count": 16,
870873
"metadata": {},
871874
"outputs": [
872875
{
@@ -995,7 +998,7 @@
995998
"12 3600 0 1"
996999
]
9971000
},
998-
"execution_count": 215,
1001+
"execution_count": 16,
9991002
"metadata": {},
10001003
"output_type": "execute_result"
10011004
}
@@ -1006,7 +1009,7 @@
10061009
},
10071010
{
10081011
"cell_type": "code",
1009-
"execution_count": 216,
1012+
"execution_count": 17,
10101013
"metadata": {
10111014
"scrolled": true
10121015
},
@@ -1021,7 +1024,7 @@
10211024
" 692293.59277574])"
10221025
]
10231026
},
1024-
"execution_count": 216,
1027+
"execution_count": 17,
10251028
"metadata": {},
10261029
"output_type": "execute_result"
10271030
}
@@ -1032,7 +1035,7 @@
10321035
},
10331036
{
10341037
"cell_type": "code",
1035-
"execution_count": 217,
1038+
"execution_count": 18,
10361039
"metadata": {},
10371040
"outputs": [
10381041
{
@@ -1041,7 +1044,7 @@
10411044
"0.95739290372218733"
10421045
]
10431046
},
1044-
"execution_count": 217,
1047+
"execution_count": 18,
10451048
"metadata": {},
10461049
"output_type": "execute_result"
10471050
}
@@ -1052,7 +1055,7 @@
10521055
},
10531056
{
10541057
"cell_type": "code",
1055-
"execution_count": 221,
1058+
"execution_count": 19,
10561059
"metadata": {},
10571060
"outputs": [
10581061
{
@@ -1061,7 +1064,7 @@
10611064
"array([ 681241.66845839])"
10621065
]
10631066
},
1064-
"execution_count": 221,
1067+
"execution_count": 19,
10651068
"metadata": {},
10661069
"output_type": "execute_result"
10671070
}
@@ -1072,7 +1075,7 @@
10721075
},
10731076
{
10741077
"cell_type": "code",
1075-
"execution_count": 222,
1078+
"execution_count": 20,
10761079
"metadata": {},
10771080
"outputs": [
10781081
{
@@ -1081,7 +1084,7 @@
10811084
"array([ 590775.63964739])"
10821085
]
10831086
},
1084-
"execution_count": 222,
1087+
"execution_count": 20,
10851088
"metadata": {},
10861089
"output_type": "execute_result"
10871090
}
@@ -1106,8 +1109,10 @@
11061109
},
11071110
{
11081111
"cell_type": "code",
1109-
"execution_count": 223,
1110-
"metadata": {},
1112+
"execution_count": 21,
1113+
"metadata": {
1114+
"collapsed": true
1115+
},
11111116
"outputs": [],
11121117
"source": [
11131118
"from sklearn.preprocessing import LabelEncoder\n",
@@ -1116,7 +1121,7 @@
11161121
},
11171122
{
11181123
"cell_type": "code",
1119-
"execution_count": 224,
1124+
"execution_count": 22,
11201125
"metadata": {},
11211126
"outputs": [
11221127
{
@@ -1245,7 +1250,7 @@
12451250
"12 1 3600 695000"
12461251
]
12471252
},
1248-
"execution_count": 224,
1253+
"execution_count": 22,
12491254
"metadata": {},
12501255
"output_type": "execute_result"
12511256
}
@@ -1258,7 +1263,7 @@
12581263
},
12591264
{
12601265
"cell_type": "code",
1261-
"execution_count": 235,
1266+
"execution_count": 23,
12621267
"metadata": {
12631268
"collapsed": true
12641269
},
@@ -1269,7 +1274,7 @@
12691274
},
12701275
{
12711276
"cell_type": "code",
1272-
"execution_count": 236,
1277+
"execution_count": 24,
12731278
"metadata": {},
12741279
"outputs": [
12751280
{
@@ -1290,7 +1295,7 @@
12901295
" [ 1, 3600]], dtype=int64)"
12911296
]
12921297
},
1293-
"execution_count": 236,
1298+
"execution_count": 24,
12941299
"metadata": {},
12951300
"output_type": "execute_result"
12961301
}
@@ -1301,7 +1306,7 @@
13011306
},
13021307
{
13031308
"cell_type": "code",
1304-
"execution_count": 228,
1309+
"execution_count": 25,
13051310
"metadata": {},
13061311
"outputs": [
13071312
{
@@ -1311,7 +1316,7 @@
13111316
" 710000, 575000, 600000, 620000, 695000], dtype=int64)"
13121317
]
13131318
},
1314-
"execution_count": 228,
1319+
"execution_count": 25,
13151320
"metadata": {},
13161321
"output_type": "execute_result"
13171322
}
@@ -1330,7 +1335,7 @@
13301335
},
13311336
{
13321337
"cell_type": "code",
1333-
"execution_count": 229,
1338+
"execution_count": 26,
13341339
"metadata": {
13351340
"collapsed": true
13361341
},
@@ -1342,7 +1347,7 @@
13421347
},
13431348
{
13441349
"cell_type": "code",
1345-
"execution_count": 237,
1350+
"execution_count": 27,
13461351
"metadata": {},
13471352
"outputs": [
13481353
{
@@ -1376,7 +1381,7 @@
13761381
" 3.60000000e+03]])"
13771382
]
13781383
},
1379-
"execution_count": 237,
1384+
"execution_count": 27,
13801385
"metadata": {},
13811386
"output_type": "execute_result"
13821387
}
@@ -1388,7 +1393,7 @@
13881393
},
13891394
{
13901395
"cell_type": "code",
1391-
"execution_count": 238,
1396+
"execution_count": 28,
13921397
"metadata": {
13931398
"collapsed": true
13941399
},
@@ -1399,7 +1404,7 @@
13991404
},
14001405
{
14011406
"cell_type": "code",
1402-
"execution_count": 239,
1407+
"execution_count": 29,
14031408
"metadata": {},
14041409
"outputs": [
14051410
{
@@ -1420,7 +1425,7 @@
14201425
" [ 1.00000000e+00, 0.00000000e+00, 3.60000000e+03]])"
14211426
]
14221427
},
1423-
"execution_count": 239,
1428+
"execution_count": 29,
14241429
"metadata": {},
14251430
"output_type": "execute_result"
14261431
}
@@ -1431,7 +1436,7 @@
14311436
},
14321437
{
14331438
"cell_type": "code",
1434-
"execution_count": 244,
1439+
"execution_count": 30,
14351440
"metadata": {},
14361441
"outputs": [
14371442
{
@@ -1440,7 +1445,7 @@
14401445
"LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)"
14411446
]
14421447
},
1443-
"execution_count": 244,
1448+
"execution_count": 30,
14441449
"metadata": {},
14451450
"output_type": "execute_result"
14461451
}
@@ -1451,7 +1456,7 @@
14511456
},
14521457
{
14531458
"cell_type": "code",
1454-
"execution_count": 249,
1459+
"execution_count": 31,
14551460
"metadata": {},
14561461
"outputs": [
14571462
{
@@ -1460,7 +1465,7 @@
14601465
"array([ 681241.6684584])"
14611466
]
14621467
},
1463-
"execution_count": 249,
1468+
"execution_count": 31,
14641469
"metadata": {},
14651470
"output_type": "execute_result"
14661471
}
@@ -1471,7 +1476,7 @@
14711476
},
14721477
{
14731478
"cell_type": "code",
1474-
"execution_count": 250,
1479+
"execution_count": 32,
14751480
"metadata": {
14761481
"scrolled": true
14771482
},
@@ -1482,7 +1487,7 @@
14821487
"array([ 590775.63964739])"
14831488
]
14841489
},
1485-
"execution_count": 250,
1490+
"execution_count": 32,
14861491
"metadata": {},
14871492
"output_type": "execute_result"
14881493
}

0 commit comments

Comments
 (0)