-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
486 lines (406 loc) · 20.2 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
<!DOCTYPE html>
<!--
Welcome. UI stuff is in ui.js and Three.js stuff is in dreda.js (links at bottom).
Source is at github.com/metasyn/dreda.
Here's a Red panda, because.
ydmmmmmddds+:/yhysooymNNmmmmNNmy//+ossysyyyysysysssysoossooo++++smms/:
hdmmmmmmddhy+//oyso++/smNMMMMmo+oosyyyyyyyyysyyyyyyyssyssyyssooo+smNh+
hdmmmmmmmmmmds+//oo++++++shmh++syyyhhhhhyyyyhyyhso/:.````.oyyoooosohNd
dmmmddddmmmmmmho/:/+++////:----.---::/osyhhhho/.` ```.```.shysyssssoyN
dd+---::/+syhdmdyo/::--..--::/:-.........-//.```-/+++:-..:yyyyyyyshhhm
yy.```````````:os+-...-..--:/:----...-....-`..-/shhy+:-..+yyyyysssssos
+s/`..-/++/-.```-:.--.----:--::----.------:--:/oyhhyo/-./yyyhyyyyyyyso
+ss:--:+shhs/::--.--:/:--.---::-------:-:::-.-:/+oo++/--yhhhysyyhhhhyy
/sso:--:+syyo/:::--:::::---.---.-::::-----------/++/:-.+hddddhhhhhhhyh
++ooo:-:+ooo+::::::---:::--...----:::::----:--.-:os+:.`:shhhhhhhhhdhhh
oshddy/-:/+o+:---:::::::::::--:://:---:/::-::-..-:oso/.-oyyyhhdhdhhhhh
/:+syys:-/+ss:.-----:/:--:++/++/os/..:+o+++/:--.-:ohhyo/+oyhhhdddddddd
s+/+sss:-/sds:---:+o++/:.-ohyo/+oso::/+/+s+:.....-/shhyyyssyyyhdmmmmmm
o:.:oss+:ohdo---::+syooo+sss+/-.--:ohysoso-```..-:+syhyyhhyyhhhhddmmmm
o:.-/oso+ymdo:-----:ossyyhs-.``````-/osyhhs:..``.-/syhhydmdhyhhhhddmNN
s:-:/+ssshmms+:....:sddhs:..`.-:-`````-+hNNmo-.`.-/oyhhdmNmmhyhdddmmNN
+--++/+syhdmdo:..-:yNNNh+-``.+yhyo-```.:ymmmd+----/shddNNNNNmhhhmmmNNN
-.:oo+/oyssdds:--:/hNMMms-..oNNNNNm:.../ydNNdo///shmmmNNNNNNNmdhmNNNMM
--+ooo++o//ydho/+++ymNmdy/-:+dNMMmy+//oyhddddddmmNNNNMMMMMMNNNmddNNMMM
-:/+ooo++//ohdmddhdddhhdmhhydmNNNmmmmddhdmmmmMMNNMMMMMMMMMMMNNNmdmNMMM
/++++//+//:/smNNNNNddmmmmNNmmNNmdmdddmsymNNMNdNMMMMMMMMMMMMMMNNNmmNMMM
ooooo++/:/oyhmMMMNNMMMMNMMMNddmysyysyyyNMMMMNNMMMMMMMMMMMMMMNNNNmmmNMM
ooooooo+///oymNMNNMMMMMMMMMMMmhddmmNNmMMMMMMMMMMMMMMMMMMMMMMMMMNNNmNMM
/oo+++++/++syhNMNMMMMMMMMMMMMMMNMMMMMMMMMMNMMMMMMMMMMMMMMMMMMNNNNmmNMM
/+/////+oosyydNMMNMMMMMMMMMMMMMMMMMNNNNMMMNNNMMMMMMMMMMMMMMMMMMNmmmNNM
///+oyhyso++ohNMMMMMMMMMMMMMMMMMMMMNdyhmNMMNmMMMMMMMMMMMMMMMMMNmhhdmNM
ooosyhyo++//oyNMMMMMMMMMMMMMMMMMMMMNh/-:hNMMMMMMMMMMMMMMMMMMMNyooyhdNN
+++++osoo+//+smNMMMMMMMMMMMMMMMMMMMMM+::+hmNMMMMMMMMMMMMMMMNhs//+syhmm
/+/++so+oo///+osmMMMMMMMMMMMMMMMMMMMMs:::+oyhmNNNNMMMMMMMMNys+::/syydm
/oosso++++/////:omMMMMMMMMMMMMMMMMMMdy+::/yssyhdmNNNNNNNNMNs+o/::oysyd
oysooooo+o+///+//odNMMMMMMMMMMMMMMNhysy+:+yssyddmmmmNNNNNMNh::/::+yssh
+++ooooo+++///++::+ydNMMMMMMMMMNmmyo++s+.:sssyhdmmmmNNNNNNNmy+::-/sosh
-->
<html>
<head>
<title>dreda</title>
<!--junk-->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<!--styles-->
<link href="./css/stylish.css" rel="stylesheet" type="text/css">
<link href="./css/tomorrow-night.css" rel="stylesheet" type="text/css">
<link href="./Semantic-UI-1.12.0/dist/semantic.min.css" rel="stylesheet" type="text/css">
<!--dependencies-->
<script src="./lib/three.min.js"></script>
<script src="./lib/OrbitControls-Touch.js"></script>
<script src="./lib/rAF.js"></script>
<script src="./lib/jquery-2.1.3.min.js"></script>
<script src="./lib/lodash.min.js"></script>
<script src="./Semantic-UI-1.12.0/dist/semantic.min.js"></script>
<script src="./lib/rainbow-custom.min.js"></script>
</head>
<body>
<!-- LEFT SIDE BAR -->
<div class="ui wide sidebar">
<div class="side">
<div id="side-center">
<svg class="icon icon-table2"><use xlink:href="#icon-table2"></use></svg><svg class="icon icon-shrink"><use xlink:href="#icon-shrink"></use></svg><svg class="icon icon-arrow-right2"><use xlink:href="#icon-arrow-right2"></use></svg><svg class="icon icon-stats-dots"><use xlink:href="#icon-stats-dots"></use></svg>
<h2><u>d</u>imensionality <u>r</u>educed <u>e</u>xploratory <u>d</u>ata <u>a</u>nalysis</h2>
<div class="ui green button" onClick="toggleExampleModal()">Plot Example</div>
<div class="ui teal button" onClick="toggleExplanationModal()">Tutorial</div>
<div class="ui blue button" onClick="toggleUploadModal()">Upload</div>
</div>
<div id="side-explanation">
<p>
Dreda is a tool for exploring data, primarily clustered data that has been reduced to three numerical dimensions. However, that doesn't mean you can't explore more traditional data.
</p>
<p>
Try looking at some of the examples to get a feel for whats possible.
</p>
<p>
Often,
<a href="http://en.wikipedia.org/wiki/Curse_of_dimensionality#The_.22curse_of_dimensionality.22_depends_on_the_algorithm"
data-content="
The curse of dimensionality refers to various phenomena that arise when analyzing and organizing data in high-dimensional spaces (often with hundreds or thousands of dimensions) that do not occur in low-dimensional settings such as the three-dimensional physical space of everyday experience.">
the curse of dimensionality
</a>
encourages one to use
<a href="http://en.wikipedia.org/wiki/Dimensionality_reduction"
data-content="
In machine learning and statistics, dimensionality reduction or dimension reduction is the process of reducing the number of random variables under consideration, and can be divided into feature selection and feature extraction.">
dimensionality reduction
</a>
to turn high dimensional data into 3-dimensional data, a.k.a. data we can <strong>see</strong>!</p>
<p>
Dreda takes a JSON as input - really its just an object of objects though - its set to accept the default 'index' output from a <a href="http://pandas.pydata.org">pandas</a> DataFrame.<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_json.html">to_json()</a> function. The reasoning here is that pandas will allow you to make DataFrames based on SQL queries, CSVs, <a href="http://en.wikipedia.org/wiki/Hierarchical_Data_Format">HDF</a>, STATA, excel, as well as JSON from <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.io.json.read_json.html">read_json()</a> in a variety of ways.
</p>
<p>
Read more about Pandas IO <a href="http://pandas.pydata.org/pandas-docs/stable/io.html">here</a>.
</p>
</div>
<div class="ui divider"></div>
<div id="side-center">
<p>
More details about the project can be found <a href="http://metasyn.github.io/dreda">here</a>.<br>
Better yet, fork it and have some fun.
</p>
<a href="http://github.com/metasyn/dreda"><i class="massive github icon"></i></a>
</div>
</div>
</div>
<i class="fixed big white content icon"></i>
<!-- RIGHT SIDE BAR -->
<div id="info-box" class="hidden">
<div class="ui segment">
<div class="ui green inverted statistic">
<div id="statsSize" class="value">
0
</div>
<div class="label">
Points Plotted
</div>
</div>
<div class="ui blue inverted statistic">
<div id="clusterSize" class="value">
0
</div>
<div class="label">
Clusters
</div>
</div>
</div>
<div class="ui divider"></div>
<i class="ui white big undo icon"></i>
<div class="ui inverted toggle checkbox">
<label id="rotateLabel">Rotate</label>
<input type="checkbox" name="rotateCheckbox" checked="checked" onClick="rotateToggle()">
</div>
<div class="ui divider"></div>
<div id="clusterInfo">
</div>
</div>
<i class="fixed big white info icon"></i>
<!-- EXPLANATION MODAL -->
<div class="ui modal" id="explanationModal">
<i class="close icon"></i>
<div class="header">
Using your own data
</div>
<div class="content">
<div class="description">
<div class="ui header">Prereqs</div>
<p>For Dreda to visualize your data, you'll need to meet a few requirements:</p>
<ol>
<li>valid JSON - maybe check with <a href="http://jsonlint.com/">JSONLint</a></li>
<li>'index' style format output from a <a href="http://pandas.pydata.org">pandas</a> DataFrame.<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_json.html">to_json()</a></li>
</ol>
<div class="ui header">Format</div>
<p>
Basically, the data is formatted as an <strong>object</strong> of <strong>objects</strong>. More specifically, we have three numerical values, and one categorical value that gets used as the coloring for the cluster. Within each object, we have key-value pairs. The key is the point-id (index value) and the value is, well, the value for that particular parent-object (a given dimension).
</p>
<div class="ui header">Scaling</div>
<p>
Dreda is already set up to obtain the scale of the data and calculate the scale of the axes. But as it stands, its just checking the max of one dimension and putting that as the max for all of them. So you probably want to do some scaling. Consider <a href="http://en.wikipedia.org/wiki/Standard_score">standardizing</a> your data so it is displayed neatly across the origin (maybe with <a href="http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html#sklearn.preprocessing.StandardScaler">sklearn?</a>), e.g.:
<pre data-language="python">
import pandas as pd
from sklearn import preprocessing
data = pd.read_csv('foobar.csv')
# only need to scale numerical values
scaled = pd.DataFrame( \\
preprocessing.scale( \\
data[['x', 'y', 'z']]))
scaled['cid'] = data.cid
scaled.to_json('data_for_dreda.json')
</pre>
</p>
<div class="ui header">It done broke</div>
<p>
Lastly, I haven't written an elegant catch for badly formatted data. So right now if you try uploading something that doesn't work, feel free to check the console, see the error, and file an issue on <a href="http://github.com/metasyn/dreda">github</a>.
</div>
<pre id="sampleDataPreview"><code data-language="javascript">{
"x":
{
"0":117.0501353217,
"1":63.4789054268,
"2":-92.4110611211
},
"y":
{
"0":-33.8277679817,
"1":120.3959209587,
"2":172.3790645372
},
"z":
{
"0":-17.441790351,
"1":-34.4737315608,
"2":-224.6172323059
},
"cid":
{
"0":4.0,
"1":1.0,
"2":4.0
}
}</code></pre>
</div>
<div class="actions">
<div class="ui blue button" onClick="redirectToTutorial()">
Read More
</div>
<div class="ui black button" onClick="toggleExampleModal()">
Show me an example !
</div>
<div class="ui positive right labeled icon button">
Upload
<i class="checkmark icon"></i>
</div>
</div>
</div>
<!-- UPLOAD MODAL -->
<div class="ui small modal" id="uploadModal">
<i class="close icon"></i>
<div class="header">
Uploading your Data
</div>
<div class="content">
<form name="uploadForm">
<div class="ui input">
<input type="file" id="fileInput" accept="application/json"></input>
</input>
</div>
</form>
<i class="ui massive folder open icon" id="fileSelector"></i>
<div class="ui positive message hidden">
<i class="close icon"></i>
<div class="header">
Your data has been uploaded !
</div>
<p>Click <strong>Plot Data</strong> to see what it looks like.</a>
</p>
</div>
<div class="ui negative message hidden">
<i class="close icon"></i>
<div class="header">
Are you sure that is valid JSON ?
</div>
<p>Try using a JSON validator like <a href="http://jsonlint.com/">JSONLint</a>
</p>
</div>
</div>
<div class="actions">
<div class="ui black button" onClick="redirectToTutorial()">
Read More
</div>
<div class="ui positive right labeled icon button disabled" id="userPlotButton">
Plot Data
<i class="checkmark icon"></i>
</div>
</div>
</div>
<!-- EXAMPLE MODAL -->
<div class="ui medium modal" id="exampleModal">
<i class="close icon"></i>
<div class="header">
Examples
</div>
<div class="content">
<div class="description">
<div class="ui secondary pointing five menu" id="exampleMenu">
<a class="item active" data-tab-category="ted">
Ted Talks
</a>
<a class="item" data-tab-category="iris">
Iris Flowers
</a>
<a class="item" data-tab-category="tree">
SF Trees
</a>
<a class="item" data-tab-category="evictions">
SF Evictions
</a>
<a class="item" data-tab-category="datacratic">
Datacratic Clusters
</a>
</div>
<div class="ui relaxed items">
<div class="item ted tab-content">
<div class="ui small image">
<img src="./img/ted.png">
</div>
<div class="content">
<a class="header">TED Talks</a>
<div class="meta">
<a>2013 : </a>
<a>1169 Talks</a>
</div>
<div class="description">
K-Means clustering on the TED Talks of 2013; the colors represent clusters, which loosely matches to topics. The x, y, and z values are the result of PCA and SVD on really long tf-idf vectors.
</div>
</div>
</div>
<div class="item iris tab-content">
<div class="ui small image">
<img src="./img/iris.png">
</div>
<div class="content">
<a class="header">Iris Flower</a>
<div class="meta">
<a>1936 : </a>
<a>150 Samples</a>
</div>
<div class="description">
K-Means clustering on the infamous <a href="http://en.wikipedia.org/wiki/Iris_flower_data_set">Iris flower data set.</a> The data set consists of 50 samples from each of three species of Iris (Iris setosa, Iris virginica and Iris versicolor). Four features were measured from each sample: the length and the width of the sepals and petals, in centimetres. The data here is just being clustered on the first three: sepal length, sepal width, and petal length. The colors, as you would expect, represent one of the three species. Please compare to <a href="http://en.wikipedia.org/wiki/Iris_flower_data_set#/media/File:Iris_Flowers_Clustering_kMeans.svg"> this type of ugliness</a>.
<small>
Picture from <a href="http://blog.kaggle.com/wp-content/uploads/2015/04/iris_petal_sepal.png">here</a>.
</small>
</div>
</div>
</div>
<div class="item tree tab-content">
<div class="ui small image">
<img src="./img/sfopendata.png">
</div>
<div class="content">
<a class="header">SF Trees</a>
<div class="meta">
<a>1955 - Present : </a>
<a>57436 Trees in San Francisco</a>
</div>
<div class="description">
Tree data from <a href='datasf.org'>DataSF.org</a>. The colors represent different legal statuses. The x and y are latitude and longitude and z is the age of the tree. The map is flipped on its side - look for gold gate park (a big blank rectangle) or market street to get oriented.
</div>
</div>
</div>
<div class="item evictions tab-content">
<div class="ui small image">
<img src="./img/sfopendata.png">
</div>
<div class="content">
<a class="header">SF Evictions</a>
<div class="meta">
<a>1997 - 2015 : </a>
<a>32,623 Evictions</a>
</div>
<div class="description">
Eviction data from <a href='datasf.org'>DataSF.org</a>. The colors represent different eviction reasons. The x and y are latitude and longitude, whereas z is days-since eviction filing. The easy way to get oriented is by finding golden gate park (the big blank rectangle).
</div>
</div>
</div>
<div class="item datacratic tab-content">
<div class="ui small image">
<img src="./img/datacratic.png">
</div>
<div class="content">
<a class="header">Datacratic's User Clusters</a>
<div class="meta">
<a>07/15/2014 : </a>
<a>10,000 Users</a>
</div>
<div class="description">
User clusters from datacratic's post <a href="http://datacratic.com/site/blog/visualizing-high-dimensional-data-browser-svd-t-sne-and-threejs">here</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="actions">
<div class="ui black button" onClick="redirectToTutorial()">
Read More
</div>
<div class="ui positive right labeled icon button" onClick="plotExampleAndLoad()">
Show Me!
<i class="right chevron icon"></i>
</div>
</div>
</div>
<!--PUSHER -->
<div class="pusher">
<canvas id="data-canvas"></canvas>
<div id="loader">
<div class="ui large indeterminate loader"></div>
</div>
</div>
<script src="./js/ui.js"></script> <script src="./js/dreda.js"></script>
<!--CUSTOM ICONS -->
<svg display="none" width="0" height="0" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<symbol id="icon-stats-dots" viewBox="0 0 1024 1024">
<title>stats-dots</title>
<path class="path1" d="M128 896h896v128h-1024v-1024h128zM288 832c-53.020 0-96-42.98-96-96s42.98-96 96-96c2.828 0 5.622 0.148 8.388 0.386l103.192-171.986c-9.84-15.070-15.58-33.062-15.58-52.402 0-53.020 42.98-96 96-96s96 42.98 96 96c0 19.342-5.74 37.332-15.58 52.402l103.192 171.986c2.766-0.238 5.56-0.386 8.388-0.386 2.136 0 4.248 0.094 6.35 0.23l170.356-298.122c-10.536-15.408-16.706-34.036-16.706-54.11 0-53.020 42.98-96 96-96s96 42.98 96 96c0 53.020-42.98 96-96 96-2.14 0-4.248-0.094-6.35-0.232l-170.356 298.124c10.536 15.406 16.706 34.036 16.706 54.11 0 53.020-42.98 96-96 96s-96-42.98-96-96c0-19.34 5.74-37.332 15.578-52.402l-103.19-171.984c-2.766 0.238-5.56 0.386-8.388 0.386s-5.622-0.146-8.388-0.386l-103.192 171.986c9.84 15.068 15.58 33.060 15.58 52.4 0 53.020-42.98 96-96 96z"></path>
</symbol>
<symbol id="icon-shrink" viewBox="0 0 1024 1024">
<title>shrink</title>
<path class="path1" d="M576 448h416l-160-160 192-192-96-96-192 192-160-160z"></path>
<path class="path2" d="M576 576v416l160-160 192 192 96-96-192-192 160-160z"></path>
<path class="path3" d="M448 575.996h-416l160 160-192 192 96 96 192-192 160 160z"></path>
<path class="path4" d="M448 448v-416l-160 160-192-192-96 96 192 192-160 160z"></path>
</symbol>
<symbol id="icon-arrow-right2" viewBox="0 0 1024 1024">
<title>arrow-right2</title>
<path class="path1" d="M621.254 877.254l320-320c24.994-24.992 24.994-65.516 0-90.51l-320-320c-24.994-24.992-65.516-24.992-90.51 0-24.994 24.994-24.994 65.516 0 90.51l210.746 210.746h-613.49c-35.346 0-64 28.654-64 64s28.654 64 64 64h613.49l-210.746 210.746c-12.496 12.496-18.744 28.876-18.744 45.254s6.248 32.758 18.744 45.254c24.994 24.994 65.516 24.994 90.51 0z"></path>
</symbol>
<symbol id="icon-table2" viewBox="0 0 1024 1024">
<title>table2</title>
<path class="path1" d="M0 64v896h1024v-896h-1024zM384 640v-192h256v192h-256zM640 704v192h-256v-192h256zM640 192v192h-256v-192h256zM320 192v192h-256v-192h256zM64 448h256v192h-256v-192zM704 448h256v192h-256v-192zM704 384v-192h256v192h-256zM64 704h256v192h-256v-192zM704 896v-192h256v192h-256z"></path>
</symbol>
</defs>
</svg>
</body>
</html>