forked from jargonautical/classification
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
391 lines (383 loc) · 23.8 KB
/
index.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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>Build a decision tree</title>
<link rel="stylesheet" href="css/page.css"/>
<link rel="stylesheet" href="css/cards.css"/>
<link rel="stylesheet" href="css/decision-tree.css"/>
<link rel="stylesheet" href="css/switch.css"/>
<script src="js/d3.v5.min.js"></script>
<!-- <script src='https://cdnjs.cloudflare.com/ajax/libs/interact.js/1.0.2/interact.min.js'></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://raw.githack.com/SortableJS/Sortable/master/Sortable.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-sortablejs@latest/jquery-sortable.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
</head>
<body>
<img src="img/learning-72-Pink-300px.png" class="logo"/>
<h3 id="title"> Build and test your own decision tree model</h3>
<!-- main flex container -->
<!-- cards -->
<div id="cards-wrapper">
<div class="switch-wrapper" style="text-align: right;">
<tab id="instructions-tab" onClick="selectSet('instructions');">Instructions</tab>
<tab id="training-tab" class="selected" onClick="selectSet('training');">Training set</tab>
<tab id="test-tab" onClick="selectSet('test');">Test set</tab>
<tab id="evaluation-tab" onClick="selectSet('evaluation');">Evaluation set</tab>
</div>
<div id="instructions-set" class='invisbox-small' style="display: none;">
<h4>Classification Game</h4>
<p>Your challenge is to create a decision tree that you think can successfully classify properties as either being in New York or San Francisco. Your decision must be based upon a limited number of characteristics.</p>
<p><b>Credit</b>: Dataset and original concept courtesy of <a href="https://www.linkedin.com/in/stephaniejyee/" target="_blank">Stephanie Yee</a> and <a href="https://www.linkedin.com/in/tonyhschu/" target="_blank">Tony Chu</a> @ <a href="https://r2d3.us" target="_blank">r2d3.us</a> where you can find further reading on machine learning that extends this exercise.</p>
<h4>Building your decision tree</h4>
<p>In order to help build your decision tree, you have been provided a <a href="#" onClick="selectSet('training');" style="text-decoration: underline;">training set</a> with details of 10 properties in San Francisco and 10 in New York. Use the data to decide on your factors and boundaries that you think will solve the challenge. You can also download the training set as CSV if you wish to do some analysis of the data in Excel. You can also drag and drop the cards around the screen.</p>
<h4>Buttons</h4>
<p><b>Run model: </b> Try your tree with the cards.</p>
<p><b>Reset: </b> Moves the cards back into the panel after an evaluation.</p>
<h4>Evaluating your decision tree</h4>
<p>Use the <a href="#" onClick="selectSet('evaluation');" style="text-decoration: underline;">evaluation set</a> to see if your tree works. You can select your own set of evaluation cards or generate 20 random cards. </p>
<p>Good luck!</p>
</div>
<div id='training-set' class='invisbox-small dropzone snapzone'>
<div id="buttons" style="width: 100%">
<button type="button" name="getTrainingDataCSV"><a id="groupcsv" href="data/csvs/Group_1.csv">Download cards (csv)</a></button>
<button type="button" name="getTrainingDataPDF"><a id="grouppdf" href="data/Group_1.pdf">Download cards (pdf)</a></button>
<button type="button" name="returnTrainingData" onClick="returnCards(cards.trainingSet,'area','b');">Reset</button>
<button type="button" class="model-button" name="runTrainingData" onClick="sortCards(cards.trainingSet,'b');">Run model</button>
</div>
<div id="area"></div>
</div>
<div id='test-set' class="invisbox-small" style="display: none;">
<div id="buttons" style="width: 100%">
<button type="button" name="evaluation-button" onClick="startInputPurple();">Add card</button>
<button type="button" id="fill-purples" name="fill-button" onClick="getRandomPurples(20);">Fill random</button>
<button type="button" id="remove-purples" name="remove-button" onClick="removeCards(cards.testSet,'p');" style="display: none;">Remove all</button>
<button type="button" name="returnTrainingData" onClick="returnCards(cards.testSet,'test-set','p');">Reset</button>
<button type="button" class="model-button" name="runEvaluationData" onClick="sortCards(cards.testSet,'p');">Run model</button>
</div>
</div>
<div id='evaluation-set' class="invisbox-small" style="display: none;">
<div id="buttons" style="width: 100%">
<button type="button" name="evaluation-button" onClick="startInput();">Add card</button>
<button type="button" id="fill-reds" name="fill-button" onClick="getRandomReds(20);">Fill random</button>
<button type="button" id="remove-reds" name="remove-button" onClick="removeCards(cards.evaluationSet,'r');" style="display: none;">Remove all</button>
<button type="button" name="returnTrainingData" onClick="returnCards(cards.evaluationSet,'evaluation-set','r');">Reset</button>
<button type="button" class="model-button" name="runEvaluationData" onClick="sortCards(cards.evaluationSet,'r');">Run model</button>
</div>
</div>
</div>
<div class="invisbox-big" id="decision-tree-wrapper">
<div class="switch-wrapper" style="text-align: right;">
<!-- <span style="color:white;">Enable drag</span> -->
<!-- <label class="switch" value="Enable Drag">
<input id="myCheck" type="checkbox" onclick="toggleDrag()">
<span class="slider round"></span>
</label> -->
<div>
<div id="canvas" class="dropzone" style="width: 100%; height: 100%; margin: auto;">
<div style="margin: auto;">
<svg style="display:none;">
<symbol id="sort-box" width="100%" height="300" preserveAspectRatio="none">
<rect width="100%" height="300" style="fill:silver;stroke-width:3;stroke:none" />
<text x="50%" y="50%" fill="white" dominant-baseline="middle" text-anchor="middle">CARDS</text>
</symbol>
</svg>
<!-- html form -->
<form>
<div class="container">
<!-- ROW 1 -->
<!-- first sort factor ................................ -->
<div class="flex-container">
<select id="factor_" name="factor" class="factor">
<option value="" disabled selected>Select first factor</option>
<option value="bath">Bathrooms</option>
<option value="beds">Bedrooms</option>
<option value="year_built">Year built</option>
<option value="elevation">Elevation</option>
<option value="sqft">Square Footage</option>
<option value="price">Price</option>
<option value="price_per_sqft">Price per sqft</option>
</select>
</div>
<!-- ROW 2 -->
<div class="flex-container arrows">
<div class="condition-left" style="width:100%;">
<img src="../classification/elements/neat-arrow-left.svg" class="arrow"/>
</div>
<div class="invisbox-tiny"></div>
<div class="condition-right" style="width:100%;">
<img src="../classification/elements/neat-arrow-right.svg" class="arrow"/>
</div>
</div>
<div class="flex-container conditions">
<div style="width:100%;">
<label for="condition_a"><=</label>
<input type="number" placeholder="condition" id="condition_a" name="condition_a" style="max-width: 100px;">
</div>
<div class="invisbox-tiny">
</div>
<div style="width:100%;">
<label for="condition_b" style="font-size: 1.4em;">></label>
<input disabled type="number" placeholder="condition" id="condition_b" name="condition_b" style="max-width: 100px; background-color: silver;">
</div>
</div>
<!-- ROW 3 ................................ -->
<div class="flex-container">
<div id="box_l" class="cardbox" style="background-color: silver; width:100%;"></div>
<div class="invisbox-tiny"></div>
<div id="box_r" class="cardbox" style="background-color: silver; width:100%;"></div>
</div>
<!-- ROW 4 -->
<div class="flex-container">
<div style="width:100%">
<textarea name="notes3" rows="1" style="width: 95%;">Write your notes here</textarea>
</div>
<div class="invisbox-tiny"></div>
<div style="width:100%">
<textarea name="notes3" rows="1" style="width: 95%;">Write your notes here</textarea>
</div>
</div>
<!-- SET 2 -->
<div class="flex-container conditions">
<div style="width:100%;">
<button type="button" name="Add Branch" class="add-branch decision_l_invert" onclick="addBranch('decision_l');">Add Branch</button>
<select id="factor_l" name="factor_l" class="decision_l">
<option value="" selected>No factor</option>
<option value="bath">Bathrooms</option>
<option value="beds">Bedrooms</option>
<option value="year_built">Year built</option>
<option value="elevation">Elevation</option>
<option value="sqft">Square Footage</option>
<option value="price">Price</option>
<option value="price_per_sqft">Price per sqft</option>
</select>
</div>
<div class="invisbox-tiny">
</div>
<div style="width:100%;">
<button type="button" name="Add Branch" class="add-branch decision_r_invert" onclick="addBranch('decision_r');">Add Branch</button>
<select id="factor_r" name="factor_r" class="decision_r">
<option value="" selected>No factor</option>
<option value="bath">Bathrooms</option>
<option value="beds">Bedrooms</option>
<option value="year_built">Year built</option>
<option value="elevation">Elevation</option>
<option value="sqft">Square Footage</option>
<option value="price">Price</option>
<option value="price_per_sqft">Price per sqft</option>
</select>
</div>
</div>
<div class="flex-container conditions">
<div class="invisbox-fill">
<condition class="decision_l">
<label for="condition_la"><=</label>
<input type="number" placeholder="condition" id="condition_la" name="condition_la" style="max-width: 70%;">
</condition>
</div>
<div class="invisbox-fill">
<condition class="decision_l">
<label for="condition_lb">></label>
<input disabled type="number" placeholder="condition" id="condition_lb" name="condition_lb" style="max-width: 70%; background-color: silver">
</condition>
</div>
<div class="invisbox-tiny">
</div>
<div class="invisbox-fill">
<condition class="decision_r">
<label for="condition_ra"><=</label>
<input type="number" placeholder="condition" id="condition_ra" name="condition_ra" style="max-width: 70%;">
</condition>
</div>
<div class="invisbox-fill">
<condition class="decision_r">
<label for="condition_rb">></label>
<input disabled type="number" placeholder="condition" id="condition_rb" name="condition_rb" style="max-width: 70%; background-color: silver">
</condition>
</div>
</div>
<!-- ROW 7 -->
<div class="flex-container">
<div class="invisbox-fill">
<div id="box_ll" class="cardbox-thin decision_l" style="background-color: silver; width:100%;"></div>
</div>
<div class="invisbox-fill">
<div id="box_lr" class="cardbox-thin decision_l" style="background-color: silver; width:100%;"></div>
</div>
<div class="invisbox-tiny">
</div>
<div class="invisbox-fill">
<div id="box_rl" class="cardbox-thin decision_r" style="background-color: silver; width:100%;"></div>
</div>
<div class="invisbox-fill">
<div id="box_rr" class="cardbox-thin decision_r" style="background-color: silver; width:100%;"></div>
</div>
</div>
<!-- ROW 8 -->
<div class="flex-container">
<div class="invisbox-fill">
<textarea class="decision_l" name="notes3" rows="2" style="width: 95%;">Write your notes here</textarea>
</div>
<div class="invisbox-fill">
<textarea class="decision_l" name="notes4" rows="2" style="width: 95%;">Write your notes here</textarea>
</div>
<div class="invisbox-tiny">
</div>
<div class="invisbox-fill">
<textarea class="decision_r" name="notes5" rows="2" style="width: 95%;">Write your notes here</textarea>
</div>
<div class="invisbox-fill">
<textarea class="decision_r" name="notes6" rows="2" style="width: 95%;">Write your notes here</textarea>
</div>
</div>
<!-- SET 3 -->
<div class="flex-container">
<div class="invisbox-fill" style="text-align: center;">
<button type="button" name="Add Branch" class="add-branch decision_l decision_ll_invert" onclick="addBranch('decision_ll');">Add Branch</button>
<select id="factor_ll" name="factor_ll" class="decision_ll">
<option value="" selected>No factor</option>
<option value="bath">Bathrooms</option>
<option value="beds">Bedrooms</option>
<option value="year_built">Year built</option>
<option value="elevation">Elevation</option>
<option value="sqft">Square Footage</option>
<option value="price">Price</option>
<option value="price_per_sqft">Price per sqft</option>
</select>
<div class="condition">
<condition class="decision_ll">
<label for="condition_lla"><=</label>
<input type="number" placeholder="condition" id="condition_lla" name="condition_lla" style="max-width: 70%;">
</condition>
</div>
<div id="box_lll" class="cardbox-thin decision_ll" style="background-color: silver; width:100%; height: 300px;"></div>
<div class="condition">
<condition class="decision_ll">
<label for="condition_llb">></label>
<input disabled type="number" placeholder="condition" id="condition_llb" name="condition_llb" style="max-width: 70%; background-color: silver;">
</condition>
</div>
<div id="box_llr" class="cardbox-thin decision_ll" style="background-color: silver; width:100%; height: 300px;"></div>
<textarea class="decision_ll" name="notes3" rows="2" style="width: 95%;">Write your notes here</textarea>
</div>
<div class="invisbox-fill" style="text-align: center;">
<button type="button" name="Add Branch" class="add-branch decision_l decision_lr_invert" onclick="addBranch('decision_lr');">Add Branch</button>
<select id="factor_lr" name="factor_lr" class="decision_lr">
<option value="" selected>No factor</option>
<option value="bath">Bathrooms</option>
<option value="beds">Bedrooms</option>
<option value="year_built">Year built</option>
<option value="elevation">Elevation</option>
<option value="sqft">Square Footage</option>
<option value="price">Price</option>
<option value="price_per_sqft">Price per sqft</option>
</select>
<div class="condition">
<condition class="decision_lr">
<label for="condition_lra"><=</label>
<input type="number" placeholder="condition" id="condition_lra" name="condition_lra" style="max-width: 70%;">
</condition>
</div>
<div id="box_lrl" class="cardbox-thin decision_lr" style="background-color: silver; width:100%; height: 300px;"></div>
<div class="condition">
<condition class="decision_lr">
<label for="condition_lrb">></label>
<input disabled type="number" placeholder="condition" id="condition_lrb" name="condition_lrb" style="max-width: 70%; background-color: silver;">
</condition>
</div>
<div id="box_lrr" class="cardbox-thin decision_lr" style="background-color: silver; width:100%; height: 300px;"></div>
<textarea class="decision_lr" name="notes3" rows="2" style="width: 95%;">Write your notes here</textarea>
</div>
<div class="invisbox-tiny">
</div>
<div class="invisbox-fill" style="text-align: center;">
<button type="button" name="Add Branch" class="add-branch decision_r decision_rl_invert" onclick="addBranch('decision_rl');">Add Branch</button>
<select id="factor_rl" name="factor_rl" class="decision_rl">
<option value="" selected>No factor</option>
<option value="bath">Bathrooms</option>
<option value="beds">Bedrooms</option>
<option value="year_built">Year built</option>
<option value="elevation">Elevation</option>
<option value="sqft">Square Footage</option>
<option value="price">Price</option>
<option value="price_per_sqft">Price per sqft</option>
</select>
<div class="condition">
<condition class="decision_rl">
<label for="condition_rla"><=</label>
<input type="number" placeholder="condition" id="condition_rla" name="condition_rla" style="max-width: 70%;">
</condition>
</div>
<div id="box_rll" class="cardbox-thin decision_rl" style="background-color: silver; width:100%; height: 300px;"></div>
<div class="condition">
<condition class="decision_rl">
<label for="condition_rlb">></label>
<input disabled type="number" placeholder="condition" id="condition_rlb" name="condition_rlb" style="max-width: 70%; background-color: silver;">
</condition>
</div>
<div id="box_rlr" class="cardbox-thin decision_rl" style="background-color: silver; width:100%; height: 300px;"></div>
<textarea class="decision_rl" name="notes3" rows="2" style="width: 95%;">Write your notes here</textarea>
</div>
<div class="invisbox-fill" style="text-align: center;">
<button type="button" name="Add Branch" class="add-branch decision_r decision_rr_invert" onclick="addBranch('decision_rr');">Add Branch</button>
<select id="factor_rr" name="factor_rr" class="decision_rr">
<option value="" selected>No factor</option>
<option value="bath">Bathrooms</option>
<option value="beds">Bedrooms</option>
<option value="year_built">Year built</option>
<option value="elevation">Elevation</option>
<option value="sqft">Square Footage</option>
<option value="price">Price</option>
<option value="price_per_sqft">Price per sqft</option>
</select>
<div class="condition">
<condition class="decision_rr">
<label for="condition_rra"><=</label>
<input type="number" placeholder="condition" id="condition_rra" name="condition_rra" style="max-width: 70%;">
</condition>
</div>
<div id="box_rrl" class="cardbox-thin decision_rr" style="background-color: silver; width:100%; height: 300px;"></div>
<div class="condition">
<condition class="decision_rr">
<label for="condition_rrb">></label>
<input disabled type="number" placeholder="condition" id="condition_rrb" name="condition_rrb" style="max-width: 70%; background-color: silver;">
</condition>
</div>
<div id="box_rrr" class="cardbox-thin decision_rr" style="background-color: silver; width:100%; height: 300px;"></div>
<textarea class="decision_rr" name="notes3" rows="2" style="width: 95%;">Write your notes here</textarea>
</div>
</div>
</div>
</form>
<!-- end of html form -->
</div>
</div>
</div>
</div>
</div>
</body>
<script src="js/DragAndSwap.min.js" type="text/javascript"></script>
<script src="js/dragdrop.js"></script>
<script src="js/switch.js"></script>
<script src="js/cards.js"></script>
<script src="js/decision-tree.js"></script>
<script type="text/javascript">
var group = 1;
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
group = urlParams.get('group');
if (!group) {
group = 1;
}
$('document').ready(function(){
getBlueCards(group,"blue");
document.getElementById("groupcsv").href="data/csvs/Group_" + group + ".csv";
document.getElementById("grouppdf").href="data/pdfs/Group_" + group + ".pdf";
$('#condition_a').on('change', onchange);
$('#condition_la').on('change', onchange);
$('#condition_ra').on('change', onchange);
});
</script>
</html>