-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecision-tree.html
242 lines (189 loc) · 8.87 KB
/
decision-tree.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>A Visual Introduction To Machine Learning</title>
<!-- Style Sheets -->
<link rel="stylesheet" href="libraries/js/bokeh-0.12.4.min.js">
<link rel="stylesheet" href="libraries/js/bokeh-widgets-0.12.4.min.js">
<link rel="stylesheet" href="libraries/css/layout.css">
<link rel="stylesheet" href="libraries/css/typography.css">
<!-- JS Scripts -->
<script type="text/javascript" src="libraries/js/bokeh-0.12.4.min.js"></script>
<script type="text/javascript" src="libraries/js/bokeh-widgets-0.12.4.min.js"></script>
<script type="text/javascript" src="libraries/js/d3.js"></script>
<script type="text/javascript" src="libraries/js/jquery-3.1.1.min.js"></script>
</head>
<body>
<header>
<div id = "website-title">
<h2>A Visual Introduction To Machine Learning</h2>
</div>
<div id = "top-menu-bar">
<center>
<a href="index.html"><button>Background</button></a>
<a href="decision-tree.html"><button>Decision<br>Tree</button></a>
<a href="k-nearest-neighbors.html"><button>K Nearest<br>Neighbors</button></a>
<a href="k-means.html"><button>K Means</button></a>
</center>
</div>
</header>
<!-- Page title -->
<div id = "page-title">
<center> <u> <h1>Decision Tree</h1> </u></center>
</div>
<div id = "teaching-container">
<!-- Teaching section 1 -->
<div class = "teaching-div 1">
<div class = "text">
<h5>A decision tree works by sucessively splitting the data into smaller groups based on the attributes, trying to produce groups that all have the same label. So in this case, it is trying to define groups that are all the same species.
To get there, the decision tree first splits the data into two parts and classifies every data point in a given section as the category that is most common in that section.</h5>
<h5>The first split, show to the left here, divides the data into setosa and virginica groups.</h5>
<h5>How does it decide where to divide the data? Simple. It choses the sections in order to correctly classify as many points as possible.</h5>
</div>
<div class = "viz">
<script>
$(document).ready(function()
{
$(".teaching-div:nth-child(1) .viz").load("decision-tree/decision-boundary-depth-1.html");
});
</script>
</div>
</div>
<!-- Teaching section 2 -->
<div class = "teaching-div 2">
<div class = "text">
<h5>In the second step, the process is repeated. For each resulting section from the first step, another optimal split is made.</h5>
<h5>Once again, every data point in a given section is classified as the category that makes up a pluraliity of the points in the section. Since each previously split section can be split again, each step in the decision tree algorithm creates more new classification sections than the previous step did.</h5>
</div>
<div class = "viz">
<script>$(".teaching-div:nth-child(2) .viz").load("decision-tree/decision-boundary-depth-2.html");</script>
</div>
</div>
<!-- Teaching section 3 -->
<div class = "teaching-div 3">
<div class = "text">
<h5>This process continues in an iterative fashion until one of the following things happens:</h5>
<h5>A) The pre-defined maximum number of iterations (what we call the maximum tree depth) has been reached.</h5>
<h5>B) The tree's decision surface (the collection of all sections of identically classified points) has converged. This means that the groups are as narrowly divided as they can be and no further splits exist which would allow the algorithm to better classify the points.</h5>
</div>
<div class = "viz">
<script>$(".teaching-div:nth-child(3) .viz").load("decision-tree/decision-boundary-converged.html");</script></div>
</div>
<!-- Teaching section 4 -->
<div class = "teaching-div 4">
<div class = "text">
<h5>The main advantage of a decision tree classifier is that it is one of the few classifiers where the process itself is easy to visualize. The tree itself can be constructed for an intuitive overview of each decsion at every step.</h5>
</div>
<div class = "viz">
<img src = "decision-tree/decision-tree-example.png">
</div>
</div>
</div>
<!-- Interactive controls -->
<div class = "interactive-controls">
<center><H3>Try it yourself!</H3></center>
<center><h5>Use the controls below to see how the accuracy of the decision tree classifier improves as its depth increases.</h5></center>
<script type="text/javascript">
var boundary_plots = new Array(
"decision-tree/decision-boundary-depth-0.html",
"decision-tree/decision-boundary-depth-1.html",
"decision-tree/decision-boundary-depth-2.html",
"decision-tree/decision-boundary-depth-3.html",
"decision-tree/decision-boundary-depth-4.html",
"decision-tree/decision-boundary-depth-5.html",
"decision-tree/decision-boundary-depth-6.html",
"decision-tree/decision-boundary-depth-7.html",
"decision-tree/decision-boundary-depth-8.html",
"decision-tree/decision-boundary-depth-9.html",
"decision-tree/decision-boundary-depth-10.html",
"decision-tree/decision-boundary-depth-11.html",
"decision-tree/decision-boundary-depth-12.html");
var accuracy_plots = new Array(
"decision-tree/accuracy-0.html",
"decision-tree/accuracy-1.html",
"decision-tree/accuracy-2.html",
"decision-tree/accuracy-3.html",
"decision-tree/accuracy-4.html",
"decision-tree/accuracy-5.html",
"decision-tree/accuracy-6.html",
"decision-tree/accuracy-7.html",
"decision-tree/accuracy-8.html",
"decision-tree/accuracy-9.html",
"decision-tree/accuracy-10.html",
"decision-tree/accuracy-11.html",
"decision-tree/accuracy-12.html");
var index = 0;
var paused = true;
function tostart()
{
updateIndex(0);
paused = true;
}
function decreaseone()
{
updateIndex(index - 1);
pause = true;
}
function advanceone()
{
updateIndex(index + 1);
pause = true;
}
function toend()
{
updateIndex(boundary_plots.length - 1);
pause = true;
}
function updateIndex(i)
{
if ( (i >= 0) && (i < boundary_plots.length))
{
index = i;
$("#model-results #decision-surface-container #decision-surface")
.load(boundary_plots[index]);
$("#model-results #accuracy-chart-container #accuracy-chart")
.load(accuracy_plots[index]);
}
}
</script>
<div class = "vcr-controls">
<center>
<button onclick = 'tostart()'>|◀</button>
<button onclick = 'decreaseone()'>◀</button>
<button onclick = 'advanceone()'>▶</button>
<button onclick = 'toend()'>▶|</button>
</center>
</div>
</div>
<div id = "model-results">
<div id = "decision-surface-container">
<center><u>Decision Surface</u></center>
<div id = "decision-surface">
<script>$("#model-results #decision-surface-container #decision-surface")
.load(boundary_plots[index]);</script>
</div>
</div>
<div id="accuracy-chart-container">
<center><u>Accuracy Chart</u></center>
<div id = "accuracy-chart">
<script>$("#model-results #accuracy-chart-container #accuracy-chart")
.load(accuracy_plots[index]);</script>
</div>
</div>
</div>
<div id = "bottom-menu-bar">
<center>
<a href="index.html"><button>Background</button></a>
<a href="decision-tree.html"><button>Decision<br>Tree</button></a>
<a href="k-nearest-neighbors.html"><button>K Nearest<br>Neighbors</button></a>
<a href="k-means.html"><button>K Means</button></a>
</center>
</div>
<footer>
<p class="white">Copyright 2017 by Sarah Kelley, Brad Putman, and David Skarbrevik.
<br>School of Information, University of California, Berkeley. All rights reserved.</p>
<p class="white">Website design derived from a template created by
<u><a href="http://www.fabianbentz.de">Fabian Bentz</a></u>.</p>
</footer>
</body>
</html>