w-cluster 1.0.12 → 1.0.13
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/README.md +124 -28
- 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 +123 -27
- package/docs/examples/ex-PCA.html +4 -5
- package/docs/examples/ex-cluster-webworker.html +1 -1
- package/docs/examples/ex-cluster.html +1 -1
- package/docs/global.html +3 -3
- package/docs/index.html +1 -1
- package/examples/ex-PCA.html +3 -4
- package/g-PCA-nodeworker.mjs +26 -8
- package/g-PCA.mjs +26 -8
- package/g-cluster-nodeworker.mjs +96 -18
- package/g-cluster.mjs +96 -18
- package/package.json +1 -1
- package/src/WCluster.mjs +122 -26
- package/src/WPCAMat.mjs +1 -1
- package/test/PCA.test.mjs +40 -4
- package/test/cluster.test.mjs +96 -18
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#line280">line 280</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 testPCA() {
|
|
185
184
|
let mat = [
|
|
186
185
|
[40, 50, 60],
|
|
187
186
|
[50, 70, 60],
|
|
188
187
|
[80, 70, 90],
|
|
189
188
|
[50, 60, 80]
|
|
190
189
|
]
|
|
191
190
|
console.log('mat', mat)
|
|
192
191
|
// => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
|
|
193
192
|
let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
194
193
|
console.log(resMat)
|
|
195
194
|
// => [
|
|
196
195
|
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
197
196
|
// [ -9.12778006150881, 12.303870466192656 ],
|
|
198
197
|
// [ 31.31672176507748, 0.2183960452169238 ],
|
|
199
198
|
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
200
199
|
// ]
|
|
201
200
|
let mat2 = [
|
|
202
201
|
[1040, 50, 60],
|
|
203
202
|
[1050, 70, 60],
|
|
204
203
|
[1080, 70, 90],
|
|
205
204
|
[1050, 60, 80]
|
|
206
205
|
]
|
|
207
206
|
console.log('mat2', mat2)
|
|
208
207
|
// => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
|
|
209
208
|
let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
|
|
210
209
|
console.log(resMat2)
|
|
211
210
|
// => [
|
|
212
211
|
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
213
212
|
// [ -9.12778006150881, 12.303870466192656 ],
|
|
214
213
|
// [ 31.31672176507748, 0.2183960452169238 ],
|
|
215
214
|
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
216
215
|
// ]
|
|
217
216
|
.catch((err) => {
|
|
218
217
|
console.log(err)
|
|
219
218
|
})
|
|
220
219
|
let mode = 'k-medoids'
|
|
221
220
|
let mat = [
|
|
222
221
|
[40, 50, 60],
|
|
223
222
|
[50, 70, 60],
|
|
224
223
|
[80, 70, 90],
|
|
225
224
|
[50, 60, 80]
|
|
226
225
|
]
|
|
227
226
|
console.log('mat', mat)
|
|
228
227
|
// => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
|
|
229
228
|
let resMat = await WCluster.cluster(mat, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
230
229
|
console.log(JSON.stringify(resMat, null, 2))
|
|
231
230
|
// => {
|
|
232
231
|
// "keys": null,
|
|
233
232
|
// "ginds": [
|
|
234
233
|
// [ 2 ],
|
|
235
234
|
// [ 0, 1, 3 ]
|
|
236
235
|
// ],
|
|
237
236
|
// "gmat": [
|
|
238
237
|
// [
|
|
239
238
|
// [ 31.31672176507748, 0.2183960452169238 ]
|
|
240
239
|
// ],
|
|
241
240
|
// [
|
|
242
241
|
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
243
242
|
// [ -9.12778006150881, 12.303870466192656 ],
|
|
244
243
|
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
245
244
|
// ]
|
|
246
245
|
// ],
|
|
247
246
|
// "gltdt": [
|
|
248
247
|
// [
|
|
249
248
|
// [ 80, 70, 90 ]
|
|
250
249
|
// ],
|
|
251
250
|
// [
|
|
252
251
|
// [ 40, 50, 60 ],
|
|
253
252
|
// [ 50, 70, 60 ],
|
|
254
253
|
// [ 50, 60, 80 ]
|
|
255
254
|
// ]
|
|
256
255
|
// ]
|
|
257
256
|
// }
|
|
258
257
|
let ltdt = [
|
|
259
258
|
{ name: 'Cameron', a: 40, b: 50, c: 60 },
|
|
260
259
|
{ name: 'Buckley', a: 50, b: 70, c: 60 },
|
|
261
260
|
{ name: 'Paul', a: 80, b: 70, c: 90 },
|
|
262
261
|
{ name: 'Fawcett', a: 50, b: 60, c: 80 },
|
|
263
262
|
]
|
|
264
263
|
console.log('ltdt', ltdt)
|
|
265
264
|
// => ltdt [
|
|
266
265
|
// { name: 'Cameron', a: 40, b: 50, c: 60 },
|
|
267
266
|
// { name: 'Buckley', a: 50, b: 70, c: 60 },
|
|
268
267
|
// { name: 'Paul', a: 80, b: 70, c: 90 },
|
|
269
268
|
// { name: 'Fawcett', a: 50, b: 60, c: 80 }
|
|
270
269
|
// ]
|
|
271
270
|
let resLtdt = await WCluster.cluster(ltdt, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
272
271
|
console.log(JSON.stringify(resLtdt, null, 2))
|
|
273
272
|
// => {
|
|
274
273
|
// "keys": [ "a", "b", "c" ],
|
|
275
274
|
// "ginds": [
|
|
276
275
|
// [ 2 ],
|
|
277
276
|
// [ 0, 1, 3 ]
|
|
278
277
|
// ],
|
|
279
278
|
// "gmat": [
|
|
280
279
|
// [
|
|
281
280
|
// [ 31.31672176507748, 0.2183960452169238 ]
|
|
282
281
|
// ],
|
|
283
282
|
// [
|
|
284
283
|
// [ -22.27637140016484, -4.7649452046492735 ],
|
|
285
284
|
// [ -9.12778006150881, 12.303870466192656 ],
|
|
286
285
|
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
287
286
|
// ]
|
|
288
287
|
// ],
|
|
289
288
|
// "gltdt": [
|
|
290
289
|
// [
|
|
291
290
|
// { "name": "Paul", "a": 80, "b": 70, "c": 90 }
|
|
292
291
|
// ],
|
|
293
292
|
// [
|
|
294
293
|
// { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
|
|
295
294
|
// { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
|
|
296
295
|
// { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
|
|
297
296
|
// ]
|
|
298
297
|
// ]
|
|
299
298
|
// }
|
|
300
299
|
.catch((err) => {
|
|
301
300
|
console.log(err)
|
|
302
301
|
})</code></pre>
|
|
302
|
+
<pre class="prettyprint"><code>async function testPCA() {
|
|
303
303
|
let mat = [
|
|
304
304
|
[40, 50, 60],
|
|
305
305
|
[50, 70, 60],
|
|
306
306
|
[80, 70, 90],
|
|
307
307
|
[50, 60, 80]
|
|
308
308
|
]
|
|
309
309
|
console.log('mat', mat)
|
|
310
310
|
// => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
|
|
311
311
|
let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
312
312
|
console.log(resMat)
|
|
313
313
|
// => [
|
|
314
314
|
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
315
315
|
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
316
316
|
// [ 1.9913098008410954, 0.23244503334983269 ],
|
|
317
317
|
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
318
318
|
// ]
|
|
319
319
|
let mat2 = [
|
|
320
320
|
[1040, 50, 60],
|
|
321
321
|
[1050, 70, 60],
|
|
322
322
|
[1080, 70, 90],
|
|
323
323
|
[1050, 60, 80]
|
|
324
324
|
]
|
|
325
325
|
console.log('mat2', mat2)
|
|
326
326
|
// => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
|
|
327
327
|
let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
|
|
328
328
|
console.log(resMat2)
|
|
329
329
|
// => [
|
|
330
330
|
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
331
331
|
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
332
332
|
// [ 1.9913098008410954, 0.23244503334983269 ],
|
|
333
333
|
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
334
334
|
// ]
|
|
335
335
|
let mat3 = [
|
|
336
336
|
[11040, 50, 60],
|
|
337
337
|
[13050, 70, 60],
|
|
338
338
|
[15080, 70, 90],
|
|
339
339
|
[17050, 60, 80]
|
|
340
340
|
]
|
|
341
341
|
console.log('mat3', mat3)
|
|
342
342
|
// => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
|
|
343
343
|
let resMat3 = await WCluster.PCA(mat3, { nCompNIPALS: 2 })
|
|
344
344
|
console.log(resMat3)
|
|
345
345
|
// => [
|
|
346
346
|
// [ -1.8599655569892897, 0.4908764271508211 ],
|
|
347
347
|
// [ -0.3950941652793108, -1.0977355294143445 ],
|
|
348
348
|
// [ 1.3430199944041517, -0.17213692267477554 ],
|
|
349
349
|
// [ 0.912039727864449, 0.778996024938299 ]
|
|
350
350
|
// ]
|
|
351
351
|
.catch((err) => {
|
|
352
352
|
console.log(err)
|
|
353
353
|
})
|
|
354
354
|
let mode = 'k-medoids'
|
|
355
355
|
let mat = [
|
|
356
356
|
[40, 50, 60],
|
|
357
357
|
[50, 70, 60],
|
|
358
358
|
[80, 70, 90],
|
|
359
359
|
[50, 60, 80]
|
|
360
360
|
]
|
|
361
361
|
console.log('mat', mat)
|
|
362
362
|
// => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
|
|
363
363
|
let resMat = await WCluster.cluster(mat, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
364
364
|
console.log(JSON.stringify(resMat, null, 2))
|
|
365
365
|
// => {
|
|
366
366
|
// "keys": null,
|
|
367
367
|
// "ginds": [
|
|
368
368
|
// [ 0, 1, 3 ],
|
|
369
369
|
// [ 2 ]
|
|
370
370
|
// ],
|
|
371
371
|
// "gmat": [
|
|
372
372
|
// [
|
|
373
373
|
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
374
374
|
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
375
375
|
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
376
376
|
// ],
|
|
377
377
|
// [
|
|
378
378
|
// [ 1.9913098008410954, 0.23244503334983269 ]
|
|
379
379
|
// ]
|
|
380
380
|
// ],
|
|
381
381
|
// "gltdt": [
|
|
382
382
|
// [
|
|
383
383
|
// [ 40, 50, 60 ],
|
|
384
384
|
// [ 50, 70, 60 ],
|
|
385
385
|
// [ 50, 60, 80 ]
|
|
386
386
|
// ],
|
|
387
387
|
// [
|
|
388
388
|
// [ 80, 70, 90 ]
|
|
389
389
|
// ]
|
|
390
390
|
// ]
|
|
391
391
|
// }
|
|
392
392
|
let mat2 = [
|
|
393
393
|
[1040, 50, 60],
|
|
394
394
|
[1050, 70, 60],
|
|
395
395
|
[1080, 70, 90],
|
|
396
396
|
[1050, 60, 80]
|
|
397
397
|
]
|
|
398
398
|
console.log('mat2', mat2)
|
|
399
399
|
// => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
|
|
400
400
|
let resMat2 = await WCluster.cluster(mat2, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
401
401
|
console.log(JSON.stringify(resMat2, null, 2))
|
|
402
402
|
// => {
|
|
403
403
|
// "keys": null,
|
|
404
404
|
// "ginds": [
|
|
405
405
|
// [ 0, 1, 3 ],
|
|
406
406
|
// [ 2 ]
|
|
407
407
|
// ],
|
|
408
408
|
// "gmat": [
|
|
409
409
|
// [
|
|
410
410
|
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
411
411
|
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
412
412
|
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
413
413
|
// ],
|
|
414
414
|
// [
|
|
415
415
|
// [ 1.9913098008410954, 0.23244503334983269 ]
|
|
416
416
|
// ]
|
|
417
417
|
// ],
|
|
418
418
|
// "gltdt": [
|
|
419
419
|
// [
|
|
420
420
|
// [ 1040, 50, 60 ],
|
|
421
421
|
// [ 1050, 70, 60 ],
|
|
422
422
|
// [ 1050, 60, 80 ]
|
|
423
423
|
// ],
|
|
424
424
|
// [
|
|
425
425
|
// [ 1080, 70, 90 ]
|
|
426
426
|
// ]
|
|
427
427
|
// ]
|
|
428
428
|
// }
|
|
429
429
|
let mat3 = [
|
|
430
430
|
[11040, 50, 60],
|
|
431
431
|
[13050, 70, 60],
|
|
432
432
|
[15080, 70, 90],
|
|
433
433
|
[17050, 60, 80]
|
|
434
434
|
]
|
|
435
435
|
console.log('mat3', mat3)
|
|
436
436
|
// => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
|
|
437
437
|
let resMat3 = await WCluster.cluster(mat3, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
438
438
|
console.log(JSON.stringify(resMat3, null, 2))
|
|
439
439
|
// => {
|
|
440
440
|
// "keys": null,
|
|
441
441
|
// "ginds": [
|
|
442
442
|
// [ 1, 2, 3 ],
|
|
443
443
|
// [ 0 ]
|
|
444
444
|
// ],
|
|
445
445
|
// "gmat": [
|
|
446
446
|
// [
|
|
447
447
|
// [ -0.3950941652793108, -1.0977355294143445 ],
|
|
448
448
|
// [ 1.3430199944041517, -0.17213692267477554 ],
|
|
449
449
|
// [ 0.912039727864449, 0.778996024938299 ]
|
|
450
450
|
// ],
|
|
451
451
|
// [
|
|
452
452
|
// [ -1.8599655569892897, 0.4908764271508211 ]
|
|
453
453
|
// ]
|
|
454
454
|
// ],
|
|
455
455
|
// "gltdt": [
|
|
456
456
|
// [
|
|
457
457
|
// [ 13050, 70, 60 ],
|
|
458
458
|
// [ 15080, 70, 90 ],
|
|
459
459
|
// [ 17050, 60, 80 ]
|
|
460
460
|
// ],
|
|
461
461
|
// [
|
|
462
462
|
// [ 11040, 50, 60 ]
|
|
463
463
|
// ]
|
|
464
464
|
// ]
|
|
465
465
|
// }
|
|
466
466
|
let ltdt = [
|
|
467
467
|
{ name: 'Cameron', a: 40, b: 50, c: 60 },
|
|
468
468
|
{ name: 'Buckley', a: 50, b: 70, c: 60 },
|
|
469
469
|
{ name: 'Paul', a: 80, b: 70, c: 90 },
|
|
470
470
|
{ name: 'Fawcett', a: 50, b: 60, c: 80 },
|
|
471
471
|
]
|
|
472
472
|
console.log('ltdt', ltdt)
|
|
473
473
|
// => ltdt [
|
|
474
474
|
// { name: 'Cameron', a: 40, b: 50, c: 60 },
|
|
475
475
|
// { name: 'Buckley', a: 50, b: 70, c: 60 },
|
|
476
476
|
// { name: 'Paul', a: 80, b: 70, c: 90 },
|
|
477
477
|
// { name: 'Fawcett', a: 50, b: 60, c: 80 }
|
|
478
478
|
// ]
|
|
479
479
|
let resLtdt = await WCluster.cluster(ltdt, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
480
480
|
console.log(JSON.stringify(resLtdt, null, 2))
|
|
481
481
|
// => {
|
|
482
482
|
// "keys": [ "a", "b", "c" ],
|
|
483
483
|
// "ginds": [
|
|
484
484
|
// [ 0, 1, 3 ],
|
|
485
485
|
// [ 2 ]
|
|
486
486
|
// ],
|
|
487
487
|
// "gmat": [
|
|
488
488
|
// [
|
|
489
489
|
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
490
490
|
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
491
491
|
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
492
492
|
// ],
|
|
493
493
|
// [
|
|
494
494
|
// [ 1.9913098008410954, 0.23244503334983269 ]
|
|
495
495
|
// ]
|
|
496
496
|
// ],
|
|
497
497
|
// "gltdt": [
|
|
498
498
|
// [
|
|
499
499
|
// { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
|
|
500
500
|
// { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
|
|
501
501
|
// { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
|
|
502
502
|
// ],
|
|
503
503
|
// [
|
|
504
504
|
// { "name": "Paul", "a": 80, "b": 70, "c": 90 }
|
|
505
505
|
// ]
|
|
506
506
|
// ]
|
|
507
507
|
// }
|
|
508
508
|
.catch((err) => {
|
|
509
509
|
console.log(err)
|
|
510
510
|
})</code></pre>
|
|
511
511
|
|
|
512
512
|
|
|
513
513
|
|
|
@@ -902,7 +902,7 @@
|
|
|
902
902
|
<br class="clear">
|
|
903
903
|
|
|
904
904
|
<footer>
|
|
905
|
-
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 Thu Aug 04 2022 08:38:41 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
906
906
|
</footer>
|
|
907
907
|
|
|
908
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 Thu Aug 04 2022 08:38:41 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
72
72
|
</footer>
|
|
73
73
|
|
|
74
74
|
<script>prettyPrint();</script>
|
package/examples/ex-PCA.html
CHANGED
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
</div>
|
|
31
31
|
|
|
32
32
|
<pre id="message"></pre>
|
|
33
|
-
<pre id="error"></pre>
|
|
34
33
|
|
|
35
34
|
<script>
|
|
36
35
|
|
|
@@ -38,6 +37,8 @@
|
|
|
38
37
|
console.log(WCluster)
|
|
39
38
|
|
|
40
39
|
function cls(){
|
|
40
|
+
|
|
41
|
+
document.querySelector('#message').innerHTML = 'analysing...'
|
|
41
42
|
|
|
42
43
|
let nCompNIPALS = wsemi.cint(document.querySelector('#nCompNIPALS option:checked').value)
|
|
43
44
|
console.log('nCompNIPALS',nCompNIPALS)
|
|
@@ -53,12 +54,10 @@
|
|
|
53
54
|
.then(function(res){
|
|
54
55
|
console.log(res)
|
|
55
56
|
document.querySelector('#message').innerHTML = JSON.stringify(res, null, 2)
|
|
56
|
-
document.querySelector('#error').innerHTML = ''
|
|
57
57
|
})
|
|
58
58
|
.catch(function(err){
|
|
59
59
|
console.log(err)
|
|
60
|
-
document.querySelector('#message').innerHTML =
|
|
61
|
-
document.querySelector('#error').innerHTML = JSON.stringify(err.toString(), null, 2)
|
|
60
|
+
document.querySelector('#message').innerHTML = JSON.stringify(err.toString(), null, 2)
|
|
62
61
|
})
|
|
63
62
|
|
|
64
63
|
}
|
package/g-PCA-nodeworker.mjs
CHANGED
|
@@ -16,10 +16,10 @@ async function testPCA() {
|
|
|
16
16
|
let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
17
17
|
console.log(resMat)
|
|
18
18
|
// => [
|
|
19
|
-
// [ -
|
|
20
|
-
// [ -
|
|
21
|
-
// [
|
|
22
|
-
// [ 0.
|
|
19
|
+
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
20
|
+
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
21
|
+
// [ 1.9913098008410954, 0.23244503334983269 ],
|
|
22
|
+
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
23
23
|
// ]
|
|
24
24
|
|
|
25
25
|
let mat2 = [
|
|
@@ -34,10 +34,28 @@ async function testPCA() {
|
|
|
34
34
|
let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
|
|
35
35
|
console.log(resMat2)
|
|
36
36
|
// => [
|
|
37
|
-
// [ -
|
|
38
|
-
// [ -
|
|
39
|
-
// [
|
|
40
|
-
// [ 0.
|
|
37
|
+
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
38
|
+
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
39
|
+
// [ 1.9913098008410954, 0.23244503334983269 ],
|
|
40
|
+
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
41
|
+
// ]
|
|
42
|
+
|
|
43
|
+
let mat3 = [
|
|
44
|
+
[11040, 50, 60],
|
|
45
|
+
[13050, 70, 60],
|
|
46
|
+
[15080, 70, 90],
|
|
47
|
+
[17050, 60, 80]
|
|
48
|
+
]
|
|
49
|
+
console.log('mat3', mat3)
|
|
50
|
+
// => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
|
|
51
|
+
|
|
52
|
+
let resMat3 = await WCluster.PCA(mat3, { nCompNIPALS: 2 })
|
|
53
|
+
console.log(resMat3)
|
|
54
|
+
// => [
|
|
55
|
+
// [ -1.8599655569892897, 0.4908764271508211 ],
|
|
56
|
+
// [ -0.3950941652793108, -1.0977355294143445 ],
|
|
57
|
+
// [ 1.3430199944041517, -0.17213692267477554 ],
|
|
58
|
+
// [ 0.912039727864449, 0.778996024938299 ]
|
|
41
59
|
// ]
|
|
42
60
|
|
|
43
61
|
}
|
package/g-PCA.mjs
CHANGED
|
@@ -15,10 +15,10 @@ async function testPCA() {
|
|
|
15
15
|
let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
16
16
|
console.log(resMat)
|
|
17
17
|
// => [
|
|
18
|
-
// [ -
|
|
19
|
-
// [ -
|
|
20
|
-
// [
|
|
21
|
-
// [ 0.
|
|
18
|
+
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
19
|
+
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
20
|
+
// [ 1.9913098008410954, 0.23244503334983269 ],
|
|
21
|
+
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
22
22
|
// ]
|
|
23
23
|
|
|
24
24
|
let mat2 = [
|
|
@@ -33,10 +33,28 @@ async function testPCA() {
|
|
|
33
33
|
let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
|
|
34
34
|
console.log(resMat2)
|
|
35
35
|
// => [
|
|
36
|
-
// [ -
|
|
37
|
-
// [ -
|
|
38
|
-
// [
|
|
39
|
-
// [ 0.
|
|
36
|
+
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
37
|
+
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
38
|
+
// [ 1.9913098008410954, 0.23244503334983269 ],
|
|
39
|
+
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
40
|
+
// ]
|
|
41
|
+
|
|
42
|
+
let mat3 = [
|
|
43
|
+
[11040, 50, 60],
|
|
44
|
+
[13050, 70, 60],
|
|
45
|
+
[15080, 70, 90],
|
|
46
|
+
[17050, 60, 80]
|
|
47
|
+
]
|
|
48
|
+
console.log('mat3', mat3)
|
|
49
|
+
// => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
|
|
50
|
+
|
|
51
|
+
let resMat3 = await WCluster.PCA(mat3, { nCompNIPALS: 2 })
|
|
52
|
+
console.log(resMat3)
|
|
53
|
+
// => [
|
|
54
|
+
// [ -1.8599655569892897, 0.4908764271508211 ],
|
|
55
|
+
// [ -0.3950941652793108, -1.0977355294143445 ],
|
|
56
|
+
// [ 1.3430199944041517, -0.17213692267477554 ],
|
|
57
|
+
// [ 0.912039727864449, 0.778996024938299 ]
|
|
40
58
|
// ]
|
|
41
59
|
|
|
42
60
|
}
|
package/g-cluster-nodeworker.mjs
CHANGED
|
@@ -19,27 +19,105 @@ async function testCluster() {
|
|
|
19
19
|
// => {
|
|
20
20
|
// "keys": null,
|
|
21
21
|
// "ginds": [
|
|
22
|
-
// [
|
|
23
|
-
// [
|
|
22
|
+
// [ 0, 1, 3 ],
|
|
23
|
+
// [ 2 ]
|
|
24
24
|
// ],
|
|
25
25
|
// "gmat": [
|
|
26
26
|
// [
|
|
27
|
-
// [
|
|
27
|
+
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
28
|
+
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
29
|
+
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
28
30
|
// ],
|
|
29
31
|
// [
|
|
30
|
-
// [
|
|
31
|
-
// [ -9.12778006150881, 12.303870466192656 ],
|
|
32
|
-
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
32
|
+
// [ 1.9913098008410954, 0.23244503334983269 ]
|
|
33
33
|
// ]
|
|
34
34
|
// ],
|
|
35
35
|
// "gltdt": [
|
|
36
36
|
// [
|
|
37
|
-
// [ 80, 70, 90 ]
|
|
38
|
-
// ],
|
|
39
|
-
// [
|
|
40
37
|
// [ 40, 50, 60 ],
|
|
41
38
|
// [ 50, 70, 60 ],
|
|
42
39
|
// [ 50, 60, 80 ]
|
|
40
|
+
// ],
|
|
41
|
+
// [
|
|
42
|
+
// [ 80, 70, 90 ]
|
|
43
|
+
// ]
|
|
44
|
+
// ]
|
|
45
|
+
// }
|
|
46
|
+
|
|
47
|
+
let mat2 = [
|
|
48
|
+
[1040, 50, 60],
|
|
49
|
+
[1050, 70, 60],
|
|
50
|
+
[1080, 70, 90],
|
|
51
|
+
[1050, 60, 80]
|
|
52
|
+
]
|
|
53
|
+
console.log('mat2', mat2)
|
|
54
|
+
// => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
|
|
55
|
+
|
|
56
|
+
let resMat2 = await WCluster.cluster(mat2, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
57
|
+
console.log(JSON.stringify(resMat2, null, 2))
|
|
58
|
+
// => {
|
|
59
|
+
// "keys": null,
|
|
60
|
+
// "ginds": [
|
|
61
|
+
// [ 0, 1, 3 ],
|
|
62
|
+
// [ 2 ]
|
|
63
|
+
// ],
|
|
64
|
+
// "gmat": [
|
|
65
|
+
// [
|
|
66
|
+
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
67
|
+
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
68
|
+
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
69
|
+
// ],
|
|
70
|
+
// [
|
|
71
|
+
// [ 1.9913098008410954, 0.23244503334983269 ]
|
|
72
|
+
// ]
|
|
73
|
+
// ],
|
|
74
|
+
// "gltdt": [
|
|
75
|
+
// [
|
|
76
|
+
// [ 1040, 50, 60 ],
|
|
77
|
+
// [ 1050, 70, 60 ],
|
|
78
|
+
// [ 1050, 60, 80 ]
|
|
79
|
+
// ],
|
|
80
|
+
// [
|
|
81
|
+
// [ 1080, 70, 90 ]
|
|
82
|
+
// ]
|
|
83
|
+
// ]
|
|
84
|
+
// }
|
|
85
|
+
|
|
86
|
+
let mat3 = [
|
|
87
|
+
[11040, 50, 60],
|
|
88
|
+
[13050, 70, 60],
|
|
89
|
+
[15080, 70, 90],
|
|
90
|
+
[17050, 60, 80]
|
|
91
|
+
]
|
|
92
|
+
console.log('mat3', mat3)
|
|
93
|
+
// => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
|
|
94
|
+
|
|
95
|
+
let resMat3 = await WCluster.cluster(mat3, { mode, kNumber: 2, nCompNIPALS: 2 })
|
|
96
|
+
console.log(JSON.stringify(resMat3, null, 2))
|
|
97
|
+
// => {
|
|
98
|
+
// "keys": null,
|
|
99
|
+
// "ginds": [
|
|
100
|
+
// [ 1, 2, 3 ],
|
|
101
|
+
// [ 0 ]
|
|
102
|
+
// ],
|
|
103
|
+
// "gmat": [
|
|
104
|
+
// [
|
|
105
|
+
// [ -0.3950941652793108, -1.0977355294143445 ],
|
|
106
|
+
// [ 1.3430199944041517, -0.17213692267477554 ],
|
|
107
|
+
// [ 0.912039727864449, 0.778996024938299 ]
|
|
108
|
+
// ],
|
|
109
|
+
// [
|
|
110
|
+
// [ -1.8599655569892897, 0.4908764271508211 ]
|
|
111
|
+
// ]
|
|
112
|
+
// ],
|
|
113
|
+
// "gltdt": [
|
|
114
|
+
// [
|
|
115
|
+
// [ 13050, 70, 60 ],
|
|
116
|
+
// [ 15080, 70, 90 ],
|
|
117
|
+
// [ 17050, 60, 80 ]
|
|
118
|
+
// ],
|
|
119
|
+
// [
|
|
120
|
+
// [ 11040, 50, 60 ]
|
|
43
121
|
// ]
|
|
44
122
|
// ]
|
|
45
123
|
// }
|
|
@@ -63,27 +141,27 @@ async function testCluster() {
|
|
|
63
141
|
// => {
|
|
64
142
|
// "keys": [ "a", "b", "c" ],
|
|
65
143
|
// "ginds": [
|
|
66
|
-
// [
|
|
67
|
-
// [
|
|
144
|
+
// [ 0, 1, 3 ],
|
|
145
|
+
// [ 2 ]
|
|
68
146
|
// ],
|
|
69
147
|
// "gmat": [
|
|
70
148
|
// [
|
|
71
|
-
// [
|
|
149
|
+
// [ -1.704002697669786, 0.43087564048799354 ],
|
|
150
|
+
// [ -0.2509699164590232, -1.1519035967558147 ],
|
|
151
|
+
// [ -0.03633718671228592, 0.48858292291798827 ]
|
|
72
152
|
// ],
|
|
73
153
|
// [
|
|
74
|
-
// [
|
|
75
|
-
// [ -9.12778006150881, 12.303870466192656 ],
|
|
76
|
-
// [ 0.08742969659617117, -7.757321306760306 ]
|
|
154
|
+
// [ 1.9913098008410954, 0.23244503334983269 ]
|
|
77
155
|
// ]
|
|
78
156
|
// ],
|
|
79
157
|
// "gltdt": [
|
|
80
158
|
// [
|
|
81
|
-
// { "name": "Paul", "a": 80, "b": 70, "c": 90 }
|
|
82
|
-
// ],
|
|
83
|
-
// [
|
|
84
159
|
// { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
|
|
85
160
|
// { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
|
|
86
161
|
// { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
|
|
162
|
+
// ],
|
|
163
|
+
// [
|
|
164
|
+
// { "name": "Paul", "a": 80, "b": 70, "c": 90 }
|
|
87
165
|
// ]
|
|
88
166
|
// ]
|
|
89
167
|
// }
|