w-cluster 1.0.9 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsdoc +1 -1
- package/LICENSE +1 -1
- package/README.md +53 -42
- package/dist/w-cluster.umd.js +2 -2
- package/dist/w-cluster.umd.js.map +1 -1
- package/dist/w-cluster.wk.umd.js +1 -1
- package/docs/WCluster.mjs.html +66 -56
- package/docs/examples/ex-PCA.html +1 -1
- package/docs/examples/{ex-cluster-webworker-k-medoids.html → ex-cluster-webworker.html} +12 -4
- package/docs/examples/{ex-cluster-k-means.html → ex-cluster.html} +11 -3
- package/docs/global.html +11 -6
- package/docs/index.html +1 -1
- package/examples/{ex-cluster-webworker-k-medoids.html → ex-cluster-webworker.html} +11 -3
- package/examples/{ex-cluster-k-means.html → ex-cluster.html} +10 -2
- package/g-PCA-nodeworker.mjs +22 -5
- package/g-PCA.mjs +22 -5
- package/g-cluster-nodeworker.mjs +20 -28
- package/g-cluster.mjs +20 -29
- package/package.json +3 -8
- package/src/WCluster.mjs +65 -55
- package/src/WClusterCore.mjs +14 -9
- package/src/WClusterMat.mjs +4 -3
- package/src/WPCAMat.mjs +33 -11
- package/test/PCA.test.mjs +4 -4
- package/test/cluster.test.mjs +54 -2
- package/docs/examples/ex-cluster-k-medoids.html +0 -138
- package/examples/ex-cluster-k-medoids.html +0 -138
- package/temp-bzmWVlF38ndGv0ip7atIxG1RSDXI39mk-nw.js +0 -1
package/docs/global.html
CHANGED
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
|
|
131
131
|
<dt class="tag-source">Source:</dt>
|
|
132
132
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
133
|
-
<a href="WCluster.mjs.html">WCluster.mjs</a>, <a href="WCluster.mjs.html#
|
|
133
|
+
<a href="WCluster.mjs.html">WCluster.mjs</a>, <a href="WCluster.mjs.html#line184">line 184</a>
|
|
134
134
|
</li></ul></dd>
|
|
135
135
|
|
|
136
136
|
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
|
|
182
182
|
<h5>Example</h5>
|
|
183
183
|
|
|
184
|
-
<pre class="prettyprint"><code>async function testCluster() {
|
|
185
184
|
let mode = 'k-medoids'
|
|
186
185
|
let mat = [
|
|
187
186
|
[40, 50, 60],
|
|
188
187
|
[50, 70, 60],
|
|
189
188
|
[80, 70, 90],
|
|
190
189
|
[50, 60, 80]
|
|
191
190
|
]
|
|
192
191
|
console.log('mat', mat)
|
|
193
192
|
// => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
|
|
194
193
|
let resMat = await WCluster.cluster(mat, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
195
194
|
console.log(JSON.stringify(resMat, null, 2))
|
|
196
195
|
// => {
|
|
197
196
|
// "keys": null,
|
|
198
197
|
// "ginds": [
|
|
199
198
|
// [ 2 ],
|
|
200
199
|
// [ 0, 1, 3 ]
|
|
201
200
|
// ],
|
|
202
201
|
// "gltdt": [
|
|
203
202
|
// [
|
|
204
203
|
// [ 80, 70, 90 ]
|
|
205
204
|
// ],
|
|
206
205
|
// [
|
|
207
206
|
// [ 40, 50, 60 ],
|
|
208
207
|
// [ 50, 70, 60 ],
|
|
209
208
|
// [ 50, 60, 80 ],
|
|
210
209
|
// ]
|
|
211
210
|
// ],
|
|
212
211
|
// "dmat": [
|
|
213
212
|
// [
|
|
214
213
|
// [77.39502404588043, 70.65388036857387, 91.60517102143689]
|
|
215
214
|
// ],
|
|
216
215
|
// [
|
|
217
216
|
// [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
|
|
218
217
|
// [ 50.520478881706346, 69.86935352609807, 59.679283942385844],
|
|
219
218
|
// [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
|
|
220
219
|
// ]
|
|
221
220
|
// ]
|
|
222
221
|
// }
|
|
223
222
|
let ltdt = [
|
|
224
223
|
{ name: 'Cameron', a: 40, b: 50, c: 60 },
|
|
225
224
|
{ name: 'Buckley', a: 50, b: 70, c: 60 },
|
|
226
225
|
{ name: 'Paul', a: 80, b: 70, c: 90 },
|
|
227
226
|
{ name: 'Fawcett', a: 50, b: 60, c: 80 },
|
|
228
227
|
]
|
|
229
228
|
console.log('ltdt', ltdt)
|
|
230
229
|
// => ltdt [
|
|
231
230
|
// { name: 'Cameron', a: 40, b: 50, c: 60 },
|
|
232
231
|
// { name: 'Buckley', a: 50, b: 70, c: 60 },
|
|
233
232
|
// { name: 'Paul', a: 80, b: 70, c: 90 },
|
|
234
233
|
// { name: 'Fawcett', a: 50, b: 60, c: 80 }
|
|
235
234
|
// ]
|
|
236
235
|
let resLtdt = await WCluster.cluster(ltdt, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
237
236
|
console.log(JSON.stringify(resLtdt, null, 2))
|
|
238
237
|
// => {
|
|
239
238
|
// "keys": [ "a", "b", "c" ],
|
|
240
239
|
// "ginds": [
|
|
241
240
|
// [ 2 ],
|
|
242
241
|
// [ 0, 1, 3 ]
|
|
243
242
|
// ],
|
|
244
243
|
// "gltdt": [
|
|
245
244
|
// [
|
|
246
245
|
// {
|
|
247
246
|
// "name": "Paul", "a": 80, "b": 70, "c": 90
|
|
248
247
|
// }
|
|
249
248
|
// ],
|
|
250
249
|
// [
|
|
251
250
|
// {
|
|
252
251
|
// "name": "Cameron", "a": 40, "b": 50, "c": 60
|
|
253
252
|
// },
|
|
254
253
|
// {
|
|
255
254
|
// "name": "Buckley", "a": 50, "b": 70, "c": 60
|
|
256
255
|
// },
|
|
257
256
|
// {
|
|
258
257
|
// "name": "Fawcett", "a": 50, "b": 60, "c": 80
|
|
259
258
|
// }
|
|
260
259
|
// ]
|
|
261
260
|
// ],
|
|
262
261
|
// "dmat": [
|
|
263
262
|
// [
|
|
264
263
|
// [77.39502404588043, 70.65388036857387, 91.60517102143689]
|
|
265
264
|
// ],
|
|
266
265
|
// [
|
|
267
266
|
// [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
|
|
268
267
|
// [ 50.520478881706346, 69.86935352609807, 59.679283942385844],
|
|
269
268
|
// [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
|
|
270
269
|
// ]
|
|
271
270
|
// ]
|
|
272
271
|
// }
|
|
273
272
|
.catch((err) => {
|
|
274
273
|
console.log(err)
|
|
275
274
|
})</code></pre>
|
|
275
|
+
<pre class="prettyprint"><code>async function testPCA() {
|
|
276
276
|
let mat = [
|
|
277
277
|
[40, 50, 60],
|
|
278
278
|
[50, 70, 60],
|
|
279
279
|
[80, 70, 90],
|
|
280
280
|
[50, 60, 80]
|
|
281
281
|
]
|
|
282
282
|
console.log('mat', mat)
|
|
283
283
|
// => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
|
|
284
284
|
let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
285
285
|
console.log(resMat)
|
|
286
286
|
// => [
|
|
287
287
|
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
288
288
|
// [ -9.12778006150881, 12.303870466192656 ],
|
|
289
289
|
// [ 31.31672176507748, 0.2183960452169238 ],
|
|
290
290
|
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
291
291
|
// ]
|
|
292
292
|
let mat2 = [
|
|
293
293
|
[1040, 50, 60],
|
|
294
294
|
[1050, 70, 60],
|
|
295
295
|
[1080, 70, 90],
|
|
296
296
|
[1050, 60, 80]
|
|
297
297
|
]
|
|
298
298
|
console.log('mat2', mat2)
|
|
299
299
|
// => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
|
|
300
300
|
let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
|
|
301
301
|
console.log(resMat2)
|
|
302
302
|
// => [
|
|
303
303
|
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
304
304
|
// [ -9.12778006150881, 12.303870466192656 ],
|
|
305
305
|
// [ 31.31672176507748, 0.2183960452169238 ],
|
|
306
306
|
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
307
307
|
// ]
|
|
308
308
|
.catch((err) => {
|
|
309
309
|
console.log(err)
|
|
310
310
|
})
|
|
311
311
|
let mode = 'k-medoids'
|
|
312
312
|
let mat = [
|
|
313
313
|
[40, 50, 60],
|
|
314
314
|
[50, 70, 60],
|
|
315
315
|
[80, 70, 90],
|
|
316
316
|
[50, 60, 80]
|
|
317
317
|
]
|
|
318
318
|
console.log('mat', mat)
|
|
319
319
|
// => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
|
|
320
320
|
let resMat = await WCluster.cluster(mat, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
321
321
|
console.log(JSON.stringify(resMat, null, 2))
|
|
322
322
|
// => {
|
|
323
323
|
// "keys": null,
|
|
324
324
|
// "ginds": [
|
|
325
325
|
// [ 2 ],
|
|
326
326
|
// [ 0, 1, 3 ]
|
|
327
327
|
// ],
|
|
328
328
|
// "gmat": [
|
|
329
329
|
// [
|
|
330
330
|
// [ 31.31672176507748, 0.2183960452169238 ]
|
|
331
331
|
// ],
|
|
332
332
|
// [
|
|
333
333
|
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
334
334
|
// [ -9.12778006150881, 12.303870466192656 ],
|
|
335
335
|
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
336
336
|
// ]
|
|
337
337
|
// ],
|
|
338
338
|
// "gltdt": [
|
|
339
339
|
// [
|
|
340
340
|
// [ 80, 70, 90 ]
|
|
341
341
|
// ],
|
|
342
342
|
// [
|
|
343
343
|
// [ 40, 50, 60 ],
|
|
344
344
|
// [ 50, 70, 60 ],
|
|
345
345
|
// [ 50, 60, 80 ]
|
|
346
346
|
// ]
|
|
347
347
|
// ]
|
|
348
348
|
// }
|
|
349
349
|
let ltdt = [
|
|
350
350
|
{ name: 'Cameron', a: 40, b: 50, c: 60 },
|
|
351
351
|
{ name: 'Buckley', a: 50, b: 70, c: 60 },
|
|
352
352
|
{ name: 'Paul', a: 80, b: 70, c: 90 },
|
|
353
353
|
{ name: 'Fawcett', a: 50, b: 60, c: 80 },
|
|
354
354
|
]
|
|
355
355
|
console.log('ltdt', ltdt)
|
|
356
356
|
// => ltdt [
|
|
357
357
|
// { name: 'Cameron', a: 40, b: 50, c: 60 },
|
|
358
358
|
// { name: 'Buckley', a: 50, b: 70, c: 60 },
|
|
359
359
|
// { name: 'Paul', a: 80, b: 70, c: 90 },
|
|
360
360
|
// { name: 'Fawcett', a: 50, b: 60, c: 80 }
|
|
361
361
|
// ]
|
|
362
362
|
let resLtdt = await WCluster.cluster(ltdt, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
363
363
|
console.log(JSON.stringify(resLtdt, null, 2))
|
|
364
364
|
// => {
|
|
365
365
|
// "keys": [ "a", "b", "c" ],
|
|
366
366
|
// "ginds": [
|
|
367
367
|
// [ 2 ],
|
|
368
368
|
// [ 0, 1, 3 ]
|
|
369
369
|
// ],
|
|
370
370
|
// "gmat": [
|
|
371
371
|
// [
|
|
372
372
|
// [ 31.31672176507748, 0.2183960452169238 ]
|
|
373
373
|
// ],
|
|
374
374
|
// [
|
|
375
375
|
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
376
376
|
// [ -9.12778006150881, 12.303870466192656 ],
|
|
377
377
|
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
378
378
|
// ]
|
|
379
379
|
// ],
|
|
380
380
|
// "gltdt": [
|
|
381
381
|
// [
|
|
382
382
|
// { "name": "Paul", "a": 80, "b": 70, "c": 90 }
|
|
383
383
|
// ],
|
|
384
384
|
// [
|
|
385
385
|
// { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
|
|
386
386
|
// { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
|
|
387
387
|
// { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
|
|
388
388
|
// ]
|
|
389
389
|
// ]
|
|
390
390
|
// }
|
|
391
391
|
.catch((err) => {
|
|
392
392
|
console.log(err)
|
|
393
393
|
})</code></pre>
|
|
394
394
|
|
|
395
395
|
|
|
396
396
|
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
|
|
209
209
|
<dt class="tag-source">Source:</dt>
|
|
210
210
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
211
|
-
<a href="WCluster.mjs.html">WCluster.mjs</a>, <a href="WCluster.mjs.html#
|
|
211
|
+
<a href="WCluster.mjs.html">WCluster.mjs</a>, <a href="WCluster.mjs.html#line31">line 31</a>
|
|
212
212
|
</li></ul></dd>
|
|
213
213
|
|
|
214
214
|
|
|
@@ -259,6 +259,11 @@
|
|
|
259
259
|
|
|
260
260
|
|
|
261
261
|
|
|
262
|
+
<h5>Example</h5>
|
|
263
|
+
|
|
264
|
+
<pre class="prettyprint"><code></code></pre>
|
|
265
|
+
|
|
266
|
+
|
|
262
267
|
|
|
263
268
|
|
|
264
269
|
<h5>Parameters:</h5>
|
|
@@ -568,7 +573,7 @@
|
|
|
568
573
|
|
|
569
574
|
<dt class="tag-source">Source:</dt>
|
|
570
575
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
571
|
-
<a href="WCluster.mjs.html">WCluster.mjs</a>, <a href="WCluster.mjs.html#
|
|
576
|
+
<a href="WCluster.mjs.html">WCluster.mjs</a>, <a href="WCluster.mjs.html#line15">line 15</a>
|
|
572
577
|
</li></ul></dd>
|
|
573
578
|
|
|
574
579
|
|
|
@@ -621,7 +626,7 @@
|
|
|
621
626
|
|
|
622
627
|
<h5>Example</h5>
|
|
623
628
|
|
|
624
|
-
<pre class="prettyprint"><code>async function testPCA() {
|
|
625
629
|
let mat = [
|
|
626
630
|
[40, 50, 60],
|
|
627
631
|
[50, 70, 60],
|
|
628
632
|
[80, 70, 90],
|
|
629
633
|
[50, 60, 80]
|
|
630
634
|
]
|
|
631
635
|
console.log('mat', mat)
|
|
632
636
|
// => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
|
|
633
637
|
let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
634
638
|
console.log(resMat)
|
|
635
639
|
// => [
|
|
636
640
|
// [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
|
|
637
641
|
// [ 50.520478881706346, 69.86935352609807, 59.679283942385844 ],
|
|
638
642
|
// [ 77.39502404588043, 70.65388036857387, 91.60517102143689 ],
|
|
639
643
|
// [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
|
|
640
644
|
// ]
|
|
641
645
|
.catch((err) => {
|
|
642
646
|
console.log(err)
|
|
643
647
|
})</code></pre>
|
|
648
|
+
<pre class="prettyprint"><code></code></pre>
|
|
644
649
|
|
|
645
650
|
|
|
646
651
|
|
|
@@ -897,7 +902,7 @@
|
|
|
897
902
|
<br class="clear">
|
|
898
903
|
|
|
899
904
|
<footer>
|
|
900
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on
|
|
905
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Wed Aug 03 2022 19:57:58 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
901
906
|
</footer>
|
|
902
907
|
|
|
903
908
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
<br class="clear">
|
|
69
69
|
|
|
70
70
|
<footer>
|
|
71
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on
|
|
71
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Wed Aug 03 2022 19:57:58 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
72
72
|
</footer>
|
|
73
73
|
|
|
74
74
|
<script>prettyPrint();</script>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<head>
|
|
5
5
|
<meta http-equiv="content-type" content="text/html charset=UTF-8" />
|
|
6
|
-
<title>
|
|
6
|
+
<title>cluster with web worker</title>
|
|
7
7
|
|
|
8
8
|
<!-- @babel/polyfill已廢棄 -->
|
|
9
9
|
<script nomodule src="https://cdn.jsdelivr.net/npm/@babel/polyfill@7.12.1/dist/polyfill.min.js"></script>
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
<div style="margin-bottom:5px; color:#f26; font-size:0.9rem;">WebWorkers(from blob) does not support IE11</div>
|
|
26
26
|
|
|
27
27
|
<div style="display:flex;">
|
|
28
|
+
<div style="margin-right:5px;">method:</div>
|
|
29
|
+
<select id="method" style="width:100px; margin-right:15px;" onchange="cls()">
|
|
30
|
+
<option value="k-means" selected>k-means</option>
|
|
31
|
+
<option value="k-medoids">k-medoids</option>
|
|
32
|
+
</select>
|
|
28
33
|
<div style="margin-right:5px;">kNumber:</div>
|
|
29
34
|
<select id="kNumber" style="width:50px; margin-right:15px;" onchange="cls()">
|
|
30
35
|
<option value="2">2</option>
|
|
@@ -54,7 +59,10 @@
|
|
|
54
59
|
console.log(WCluster)
|
|
55
60
|
|
|
56
61
|
function cls(){
|
|
57
|
-
|
|
62
|
+
|
|
63
|
+
let method = wsemi.cint(document.querySelector('#method option:checked').value)
|
|
64
|
+
console.log('method',method)
|
|
65
|
+
|
|
58
66
|
let kNumber = wsemi.cint(document.querySelector('#kNumber option:checked').value)
|
|
59
67
|
console.log('kNumber',kNumber)
|
|
60
68
|
|
|
@@ -66,7 +74,7 @@
|
|
|
66
74
|
wsemi.delay(100)
|
|
67
75
|
.then(function (){
|
|
68
76
|
|
|
69
|
-
WCluster.cluster(dataIris, { kNumber: kNumber, nCompNIPALS: nCompNIPALS, mode:
|
|
77
|
+
WCluster.cluster(dataIris, { kNumber: kNumber, nCompNIPALS: nCompNIPALS, mode: method })
|
|
70
78
|
.then(function(res){
|
|
71
79
|
console.log('res',res)
|
|
72
80
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<head>
|
|
5
5
|
<meta http-equiv="content-type" content="text/html charset=UTF-8" />
|
|
6
|
-
<title>
|
|
6
|
+
<title>cluster</title>
|
|
7
7
|
|
|
8
8
|
<!-- @babel/polyfill已廢棄 -->
|
|
9
9
|
<script nomodule src="https://cdn.jsdelivr.net/npm/@babel/polyfill@7.12.1/dist/polyfill.min.js"></script>
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
<body>
|
|
24
24
|
|
|
25
25
|
<div style="display:flex;">
|
|
26
|
+
<div style="margin-right:5px;">method:</div>
|
|
27
|
+
<select id="method" style="width:100px; margin-right:15px;" onchange="cls()">
|
|
28
|
+
<option value="k-means" selected>k-means</option>
|
|
29
|
+
<option value="k-medoids">k-medoids</option>
|
|
30
|
+
</select>
|
|
26
31
|
<div style="margin-right:5px;">kNumber:</div>
|
|
27
32
|
<select id="kNumber" style="width:50px; margin-right:15px;" onchange="cls()">
|
|
28
33
|
<option value="2">2</option>
|
|
@@ -53,6 +58,9 @@
|
|
|
53
58
|
|
|
54
59
|
function cls(){
|
|
55
60
|
|
|
61
|
+
let method = wsemi.cint(document.querySelector('#method option:checked').value)
|
|
62
|
+
console.log('method',method)
|
|
63
|
+
|
|
56
64
|
let kNumber = wsemi.cint(document.querySelector('#kNumber option:checked').value)
|
|
57
65
|
console.log('kNumber',kNumber)
|
|
58
66
|
|
|
@@ -64,7 +72,7 @@
|
|
|
64
72
|
wsemi.delay(100)
|
|
65
73
|
.then(function (){
|
|
66
74
|
|
|
67
|
-
WCluster.cluster(dataIris, { kNumber: kNumber, nCompNIPALS: nCompNIPALS, mode:
|
|
75
|
+
WCluster.cluster(dataIris, { kNumber: kNumber, nCompNIPALS: nCompNIPALS, mode: method })
|
|
68
76
|
.then(function(res){
|
|
69
77
|
console.log('res',res)
|
|
70
78
|
|
package/g-PCA-nodeworker.mjs
CHANGED
|
@@ -16,10 +16,28 @@ async function testPCA() {
|
|
|
16
16
|
let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
17
17
|
console.log(resMat)
|
|
18
18
|
// => [
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
19
|
+
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
20
|
+
// [ -9.12778006150881, 12.303870466192656 ],
|
|
21
|
+
// [ 31.31672176507748, 0.2183960452169238 ],
|
|
22
|
+
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
23
|
+
// ]
|
|
24
|
+
|
|
25
|
+
let mat2 = [
|
|
26
|
+
[1040, 50, 60],
|
|
27
|
+
[1050, 70, 60],
|
|
28
|
+
[1080, 70, 90],
|
|
29
|
+
[1050, 60, 80]
|
|
30
|
+
]
|
|
31
|
+
console.log('mat2', mat2)
|
|
32
|
+
// => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
|
|
33
|
+
|
|
34
|
+
let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
|
|
35
|
+
console.log(resMat2)
|
|
36
|
+
// => [
|
|
37
|
+
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
38
|
+
// [ -9.12778006150881, 12.303870466192656 ],
|
|
39
|
+
// [ 31.31672176507748, 0.2183960452169238 ],
|
|
40
|
+
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
23
41
|
// ]
|
|
24
42
|
|
|
25
43
|
}
|
|
@@ -29,4 +47,3 @@ testPCA()
|
|
|
29
47
|
})
|
|
30
48
|
|
|
31
49
|
//node --experimental-modules --es-module-specifier-resolution=node g-PCA-nodeworker.mjs
|
|
32
|
-
|
package/g-PCA.mjs
CHANGED
|
@@ -15,10 +15,28 @@ async function testPCA() {
|
|
|
15
15
|
let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
16
16
|
console.log(resMat)
|
|
17
17
|
// => [
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
18
|
+
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
19
|
+
// [ -9.12778006150881, 12.303870466192656 ],
|
|
20
|
+
// [ 31.31672176507748, 0.2183960452169238 ],
|
|
21
|
+
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
22
|
+
// ]
|
|
23
|
+
|
|
24
|
+
let mat2 = [
|
|
25
|
+
[1040, 50, 60],
|
|
26
|
+
[1050, 70, 60],
|
|
27
|
+
[1080, 70, 90],
|
|
28
|
+
[1050, 60, 80]
|
|
29
|
+
]
|
|
30
|
+
console.log('mat2', mat2)
|
|
31
|
+
// => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
|
|
32
|
+
|
|
33
|
+
let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
|
|
34
|
+
console.log(resMat2)
|
|
35
|
+
// => [
|
|
36
|
+
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
37
|
+
// [ -9.12778006150881, 12.303870466192656 ],
|
|
38
|
+
// [ 31.31672176507748, 0.2183960452169238 ],
|
|
39
|
+
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
22
40
|
// ]
|
|
23
41
|
|
|
24
42
|
}
|
|
@@ -28,4 +46,3 @@ testPCA()
|
|
|
28
46
|
})
|
|
29
47
|
|
|
30
48
|
//node --experimental-modules --es-module-specifier-resolution=node g-PCA.mjs
|
|
31
|
-
|
package/g-cluster-nodeworker.mjs
CHANGED
|
@@ -22,24 +22,24 @@ async function testCluster() {
|
|
|
22
22
|
// [ 2 ],
|
|
23
23
|
// [ 0, 1, 3 ]
|
|
24
24
|
// ],
|
|
25
|
-
// "
|
|
25
|
+
// "gmat": [
|
|
26
26
|
// [
|
|
27
|
-
// [
|
|
27
|
+
// [ 31.31672176507748, 0.2183960452169238 ]
|
|
28
28
|
// ],
|
|
29
29
|
// [
|
|
30
|
-
// [
|
|
31
|
-
// [
|
|
32
|
-
// [
|
|
30
|
+
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
31
|
+
// [ -9.12778006150881, 12.303870466192656 ],
|
|
32
|
+
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
33
33
|
// ]
|
|
34
34
|
// ],
|
|
35
|
-
// "
|
|
35
|
+
// "gltdt": [
|
|
36
36
|
// [
|
|
37
|
-
// [
|
|
37
|
+
// [ 80, 70, 90 ]
|
|
38
38
|
// ],
|
|
39
39
|
// [
|
|
40
|
-
// [
|
|
41
|
-
// [ 50
|
|
42
|
-
// [
|
|
40
|
+
// [ 40, 50, 60 ],
|
|
41
|
+
// [ 50, 70, 60 ],
|
|
42
|
+
// [ 50, 60, 80 ]
|
|
43
43
|
// ]
|
|
44
44
|
// ]
|
|
45
45
|
// }
|
|
@@ -66,32 +66,24 @@ async function testCluster() {
|
|
|
66
66
|
// [ 2 ],
|
|
67
67
|
// [ 0, 1, 3 ]
|
|
68
68
|
// ],
|
|
69
|
-
// "
|
|
69
|
+
// "gmat": [
|
|
70
70
|
// [
|
|
71
|
-
//
|
|
72
|
-
// "name": "Paul", "a": 80, "b": 70, "c": 90
|
|
73
|
-
// }
|
|
71
|
+
// [ 31.31672176507748, 0.2183960452169238 ]
|
|
74
72
|
// ],
|
|
75
73
|
// [
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
// {
|
|
80
|
-
// "name": "Buckley", "a": 50, "b": 70, "c": 60
|
|
81
|
-
// },
|
|
82
|
-
// {
|
|
83
|
-
// "name": "Fawcett", "a": 50, "b": 60, "c": 80
|
|
84
|
-
// }
|
|
74
|
+
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
75
|
+
// [ -9.12778006150881, 12.303870466192656 ],
|
|
76
|
+
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
85
77
|
// ]
|
|
86
78
|
// ],
|
|
87
|
-
// "
|
|
79
|
+
// "gltdt": [
|
|
88
80
|
// [
|
|
89
|
-
//
|
|
81
|
+
// { "name": "Paul", "a": 80, "b": 70, "c": 90 }
|
|
90
82
|
// ],
|
|
91
83
|
// [
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
84
|
+
// { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
|
|
85
|
+
// { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
|
|
86
|
+
// { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
|
|
95
87
|
// ]
|
|
96
88
|
// ]
|
|
97
89
|
// }
|
package/g-cluster.mjs
CHANGED
|
@@ -21,24 +21,24 @@ async function testCluster() {
|
|
|
21
21
|
// [ 2 ],
|
|
22
22
|
// [ 0, 1, 3 ]
|
|
23
23
|
// ],
|
|
24
|
-
// "
|
|
24
|
+
// "gmat": [
|
|
25
25
|
// [
|
|
26
|
-
// [
|
|
26
|
+
// [ 31.31672176507748, 0.2183960452169238 ]
|
|
27
27
|
// ],
|
|
28
28
|
// [
|
|
29
|
-
// [
|
|
30
|
-
// [
|
|
31
|
-
// [
|
|
29
|
+
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
30
|
+
// [ -9.12778006150881, 12.303870466192656 ],
|
|
31
|
+
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
32
32
|
// ]
|
|
33
33
|
// ],
|
|
34
|
-
// "
|
|
34
|
+
// "gltdt": [
|
|
35
35
|
// [
|
|
36
|
-
// [
|
|
36
|
+
// [ 80, 70, 90 ]
|
|
37
37
|
// ],
|
|
38
38
|
// [
|
|
39
|
-
// [
|
|
40
|
-
// [ 50
|
|
41
|
-
// [
|
|
39
|
+
// [ 40, 50, 60 ],
|
|
40
|
+
// [ 50, 70, 60 ],
|
|
41
|
+
// [ 50, 60, 80 ]
|
|
42
42
|
// ]
|
|
43
43
|
// ]
|
|
44
44
|
// }
|
|
@@ -65,32 +65,24 @@ async function testCluster() {
|
|
|
65
65
|
// [ 2 ],
|
|
66
66
|
// [ 0, 1, 3 ]
|
|
67
67
|
// ],
|
|
68
|
-
// "
|
|
68
|
+
// "gmat": [
|
|
69
69
|
// [
|
|
70
|
-
//
|
|
71
|
-
// "name": "Paul", "a": 80, "b": 70, "c": 90
|
|
72
|
-
// }
|
|
70
|
+
// [ 31.31672176507748, 0.2183960452169238 ]
|
|
73
71
|
// ],
|
|
74
72
|
// [
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
// {
|
|
79
|
-
// "name": "Buckley", "a": 50, "b": 70, "c": 60
|
|
80
|
-
// },
|
|
81
|
-
// {
|
|
82
|
-
// "name": "Fawcett", "a": 50, "b": 60, "c": 80
|
|
83
|
-
// }
|
|
73
|
+
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
74
|
+
// [ -9.12778006150881, 12.303870466192656 ],
|
|
75
|
+
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
84
76
|
// ]
|
|
85
77
|
// ],
|
|
86
|
-
// "
|
|
78
|
+
// "gltdt": [
|
|
87
79
|
// [
|
|
88
|
-
//
|
|
80
|
+
// { "name": "Paul", "a": 80, "b": 70, "c": 90 }
|
|
89
81
|
// ],
|
|
90
82
|
// [
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
83
|
+
// { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
|
|
84
|
+
// { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
|
|
85
|
+
// { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
|
|
94
86
|
// ]
|
|
95
87
|
// ]
|
|
96
88
|
// }
|
|
@@ -102,4 +94,3 @@ testCluster()
|
|
|
102
94
|
})
|
|
103
95
|
|
|
104
96
|
//node --experimental-modules --es-module-specifier-resolution=node g-cluster.mjs
|
|
105
|
-
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-cluster",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A tool for data PCA(Principle Component Analysis) and cluster(K-Means & K-Medoids).",
|
|
3
|
+
"version": "1.0.12",
|
|
5
4
|
"main": "dist/w-cluster.umd.js",
|
|
6
5
|
"dependencies": {
|
|
7
6
|
"lodash": "^4.17.21",
|
|
8
7
|
"k-medoids": "^1.0.6",
|
|
9
8
|
"ml-kmeans": "^5.0.0",
|
|
10
9
|
"ml-pca": "^4.0.2",
|
|
11
|
-
"wsemi": "^1.6.
|
|
10
|
+
"wsemi": "^1.6.69"
|
|
12
11
|
},
|
|
13
12
|
"devDependencies": {
|
|
14
13
|
"w-package-tools": "^1.0.65"
|
|
@@ -33,9 +32,5 @@
|
|
|
33
32
|
"browser"
|
|
34
33
|
],
|
|
35
34
|
"author": "yuda-lyu(semisphere)",
|
|
36
|
-
"license": "MIT"
|
|
37
|
-
"bugs": {
|
|
38
|
-
"url": "https://github.com/yuda-lyu/w-cluster/issues"
|
|
39
|
-
},
|
|
40
|
-
"homepage": "https://github.com/yuda-lyu/w-cluster#readme"
|
|
35
|
+
"license": "MIT"
|
|
41
36
|
}
|