| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent eb7a386 commit ec6f459
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -267,24 +267,26 @@ | |||
| 267 | 267 | }, | |
| 268 | 268 | { | |
| 269 | 269 | "cell_type": "code", | |
| 270 | - "execution_count": 24, | ||
| 270 | + "execution_count": 30, | ||
| 271 | 271 | "metadata": { | |
| 272 | 272 | "collapsed": false | |
| 273 | 273 | }, | |
| 274 | 274 | "outputs": [], | |
| 275 | 275 | "source": [ | |
| 276 | 276 | "clf = tree.DecisionTreeClassifier(max_depth=2) \n", | |
| 277 | - "clf = clf.fit(df[['Sex', 'Age', 'Fare']], df[['Survived']]) \n", | ||
| 277 | + "clf = clf.fit(df[['Sex', 'Age']], df[['Survived']]) \n", | ||
| 278 | 278 | "tree.export_graphviz(clf,\n", | |
| 279 | 279 | " out_file=\"decisionTreeTitantic.dot\",\n", | |
| 280 | - " feature_names=['Sex', 'Age', 'Fare'],\n", | ||
| 280 | + " feature_names=['Sex', 'Age'],\n", | ||
| 281 | 281 | " class_names=['Dead', 'Alive'],\n", | |
| 282 | + " proportion = True,\n", | ||
| 283 | + " rotate = True, \n", | ||
| 282 | 284 | " filled = True)" | |
| 283 | 285 | ] | |
| 284 | 286 | }, | |
| 285 | 287 | { | |
| 286 | 288 | "cell_type": "code", | |
| 287 | - "execution_count": 25, | ||
| 289 | + "execution_count": 31, | ||
| 288 | 290 | "metadata": { | |
| 289 | 291 | "collapsed": true | |
| 290 | 292 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,16 +1,17 @@ | |||
| 1 | 1 | digraph Tree { | |
| 2 | 2 | node [shape=box, style="filled", color="black"] ; | |
| 3 | - 0 [label="Sex <= 0.5\ngini = 0.473\nsamples = 891\nvalue = [549, 342]\nclass = Dead", fillcolor="#e5813960"] ; | ||
| 4 | - 1 [label="Fare <= 48.2\ngini = 0.383\nsamples = 314\nvalue = [81, 233]\nclass = Alive", fillcolor="#399de5a6"] ; | ||
| 5 | - 0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ; | ||
| 6 | - 2 [label="gini = 0.447\nsamples = 225\nvalue = [76, 149]\nclass = Alive", fillcolor="#399de57d"] ; | ||
| 3 | + rankdir=LR ; | ||
| 4 | + 0 [label="Sex <= 0.5\ngini = 0.473\nsamples = 100.0%\nvalue = [0.616, 0.384]\nclass = Dead", fillcolor="#e5813960"] ; | ||
| 5 | + 1 [label="Age <= 32.25\ngini = 0.383\nsamples = 35.2%\nvalue = [0.258, 0.742]\nclass = Alive", fillcolor="#399de5a6"] ; | ||
| 6 | + 0 -> 1 [labeldistance=2.5, labelangle=-45, headlabel="True"] ; | ||
| 7 | + 2 [label="gini = 0.414\nsamples = 24.9%\nvalue = [0.293, 0.707]\nclass = Alive", fillcolor="#399de595"] ; | ||
| 7 | 8 | 1 -> 2 ; | |
| 8 | - 3 [label="gini = 0.106\nsamples = 89\nvalue = [5, 84]\nclass = Alive", fillcolor="#399de5f0"] ; | ||
| 9 | + 3 [label="gini = 0.287\nsamples = 10.3%\nvalue = [0.174, 0.826]\nclass = Alive", fillcolor="#399de5c9"] ; | ||
| 9 | 10 | 1 -> 3 ; | |
| 10 | - 4 [label="Age <= 6.5\ngini = 0.306\nsamples = 577\nvalue = [468, 109]\nclass = Dead", fillcolor="#e58139c4"] ; | ||
| 11 | - 0 -> 4 [labeldistance=2.5, labelangle=-45, headlabel="False"] ; | ||
| 12 | - 5 [label="gini = 0.444\nsamples = 24\nvalue = [8, 16]\nclass = Alive", fillcolor="#399de57f"] ; | ||
| 11 | + 4 [label="Age <= 6.5\ngini = 0.306\nsamples = 64.8%\nvalue = [0.811, 0.189]\nclass = Dead", fillcolor="#e58139c4"] ; | ||
| 12 | + 0 -> 4 [labeldistance=2.5, labelangle=45, headlabel="False"] ; | ||
| 13 | + 5 [label="gini = 0.444\nsamples = 2.7%\nvalue = [0.333, 0.667]\nclass = Alive", fillcolor="#399de57f"] ; | ||
| 13 | 14 | 4 -> 5 ; | |
| 14 | - 6 [label="gini = 0.28\nsamples = 553\nvalue = [460, 93]\nclass = Dead", fillcolor="#e58139cb"] ; | ||
| 15 | + 6 [label="gini = 0.28\nsamples = 62.1%\nvalue = [0.832, 0.168]\nclass = Dead", fillcolor="#e58139cb"] ; | ||
| 15 | 16 | 4 -> 6 ; | |
| 16 | 17 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments