Skip to content

Commit 1e6d9f4

Browse files
committed
Fixed minor issue in decision tree tutorial
1 parent 98b6793 commit 1e6d9f4

File tree

1 file changed

+35
-44
lines changed

1 file changed

+35
-44
lines changed

ML/9_decision_tree/9_decision_tree.ipynb

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 169,
13-
"metadata": {
14-
"collapsed": true
15-
},
12+
"execution_count": 1,
13+
"metadata": {},
1614
"outputs": [],
1715
"source": [
1816
"import pandas as pd"
1917
]
2018
},
2119
{
2220
"cell_type": "code",
23-
"execution_count": 170,
21+
"execution_count": 2,
2422
"metadata": {
2523
"scrolled": true
2624
},
@@ -101,7 +99,7 @@
10199
"4 google computer programmer bachelors 0"
102100
]
103101
},
104-
"execution_count": 170,
102+
"execution_count": 2,
105103
"metadata": {},
106104
"output_type": "execute_result"
107105
}
@@ -113,7 +111,7 @@
113111
},
114112
{
115113
"cell_type": "code",
116-
"execution_count": 171,
114+
"execution_count": 3,
117115
"metadata": {},
118116
"outputs": [],
119117
"source": [
@@ -122,21 +120,17 @@
122120
},
123121
{
124122
"cell_type": "code",
125-
"execution_count": 172,
126-
"metadata": {
127-
"collapsed": true
128-
},
123+
"execution_count": 4,
124+
"metadata": {},
129125
"outputs": [],
130126
"source": [
131127
"target = df['salary_more_then_100k']"
132128
]
133129
},
134130
{
135131
"cell_type": "code",
136-
"execution_count": 173,
137-
"metadata": {
138-
"collapsed": true
139-
},
132+
"execution_count": 5,
133+
"metadata": {},
140134
"outputs": [],
141135
"source": [
142136
"from sklearn.preprocessing import LabelEncoder\n",
@@ -147,18 +141,18 @@
147141
},
148142
{
149143
"cell_type": "code",
150-
"execution_count": 174,
144+
"execution_count": 6,
151145
"metadata": {},
152146
"outputs": [],
153147
"source": [
154148
"inputs['company_n'] = le_company.fit_transform(inputs['company'])\n",
155-
"inputs['job_n'] = le_company.fit_transform(inputs['job'])\n",
156-
"inputs['degree_n'] = le_company.fit_transform(inputs['degree'])"
149+
"inputs['job_n'] = le_job.fit_transform(inputs['job'])\n",
150+
"inputs['degree_n'] = le_degree.fit_transform(inputs['degree'])"
157151
]
158152
},
159153
{
160154
"cell_type": "code",
161-
"execution_count": 175,
155+
"execution_count": 7,
162156
"metadata": {},
163157
"outputs": [
164158
{
@@ -359,7 +353,7 @@
359353
"15 facebook computer programmer masters 1 1 1"
360354
]
361355
},
362-
"execution_count": 175,
356+
"execution_count": 7,
363357
"metadata": {},
364358
"output_type": "execute_result"
365359
}
@@ -370,18 +364,16 @@
370364
},
371365
{
372366
"cell_type": "code",
373-
"execution_count": 176,
374-
"metadata": {
375-
"collapsed": true
376-
},
367+
"execution_count": 8,
368+
"metadata": {},
377369
"outputs": [],
378370
"source": [
379371
"inputs_n = inputs.drop(['company','job','degree'],axis='columns')"
380372
]
381373
},
382374
{
383375
"cell_type": "code",
384-
"execution_count": 177,
376+
"execution_count": 9,
385377
"metadata": {},
386378
"outputs": [
387379
{
@@ -531,7 +523,7 @@
531523
"15 1 1 1"
532524
]
533525
},
534-
"execution_count": 177,
526+
"execution_count": 9,
535527
"metadata": {},
536528
"output_type": "execute_result"
537529
}
@@ -542,7 +534,7 @@
542534
},
543535
{
544536
"cell_type": "code",
545-
"execution_count": 178,
537+
"execution_count": 10,
546538
"metadata": {
547539
"scrolled": true
548540
},
@@ -569,7 +561,7 @@
569561
"Name: salary_more_then_100k, dtype: int64"
570562
]
571563
},
572-
"execution_count": 178,
564+
"execution_count": 10,
573565
"metadata": {},
574566
"output_type": "execute_result"
575567
}
@@ -580,10 +572,8 @@
580572
},
581573
{
582574
"cell_type": "code",
583-
"execution_count": 179,
584-
"metadata": {
585-
"collapsed": true
586-
},
575+
"execution_count": 11,
576+
"metadata": {},
587577
"outputs": [],
588578
"source": [
589579
"from sklearn import tree\n",
@@ -592,20 +582,21 @@
592582
},
593583
{
594584
"cell_type": "code",
595-
"execution_count": 180,
585+
"execution_count": 12,
596586
"metadata": {},
597587
"outputs": [
598588
{
599589
"data": {
600590
"text/plain": [
601591
"DecisionTreeClassifier(class_weight=None, criterion='gini', max_depth=None,\n",
602592
" max_features=None, max_leaf_nodes=None,\n",
603-
" min_impurity_split=1e-07, min_samples_leaf=1,\n",
604-
" min_samples_split=2, min_weight_fraction_leaf=0.0,\n",
605-
" presort=False, random_state=None, splitter='best')"
593+
" min_impurity_decrease=0.0, min_impurity_split=None,\n",
594+
" min_samples_leaf=1, min_samples_split=2,\n",
595+
" min_weight_fraction_leaf=0.0, presort=False, random_state=None,\n",
596+
" splitter='best')"
606597
]
607598
},
608-
"execution_count": 180,
599+
"execution_count": 12,
609600
"metadata": {},
610601
"output_type": "execute_result"
611602
}
@@ -616,7 +607,7 @@
616607
},
617608
{
618609
"cell_type": "code",
619-
"execution_count": 181,
610+
"execution_count": 13,
620611
"metadata": {},
621612
"outputs": [
622613
{
@@ -625,7 +616,7 @@
625616
"1.0"
626617
]
627618
},
628-
"execution_count": 181,
619+
"execution_count": 13,
629620
"metadata": {},
630621
"output_type": "execute_result"
631622
}
@@ -643,7 +634,7 @@
643634
},
644635
{
645636
"cell_type": "code",
646-
"execution_count": 182,
637+
"execution_count": 14,
647638
"metadata": {
648639
"scrolled": true
649640
},
@@ -654,7 +645,7 @@
654645
"array([0], dtype=int64)"
655646
]
656647
},
657-
"execution_count": 182,
648+
"execution_count": 14,
658649
"metadata": {},
659650
"output_type": "execute_result"
660651
}
@@ -672,7 +663,7 @@
672663
},
673664
{
674665
"cell_type": "code",
675-
"execution_count": 183,
666+
"execution_count": 15,
676667
"metadata": {
677668
"scrolled": true
678669
},
@@ -683,7 +674,7 @@
683674
"array([1], dtype=int64)"
684675
]
685676
},
686-
"execution_count": 183,
677+
"execution_count": 15,
687678
"metadata": {},
688679
"output_type": "execute_result"
689680
}
@@ -709,7 +700,7 @@
709700
"name": "python",
710701
"nbconvert_exporter": "python",
711702
"pygments_lexer": "ipython3",
712-
"version": "3.6.1"
703+
"version": "3.7.3"
713704
}
714705
},
715706
"nbformat": 4,

0 commit comments

Comments
 (0)