w-cluster 1.0.10 → 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/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#line166">line 166</a>
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
  // [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
197
196
  // [ 50.520478881706346, 69.86935352609807, 59.679283942385844 ],
198
197
  // [ 77.39502404588043, 70.65388036857387, 91.60517102143689 ],
199
198
  // [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
200
199
  // ]
201
200
  .catch((err) => {
202
201
  console.log(err)
203
202
  })
204
203
  let mode = 'k-medoids'
205
204
  let mat = [
206
205
  [40, 50, 60],
207
206
  [50, 70, 60],
208
207
  [80, 70, 90],
209
208
  [50, 60, 80]
210
209
  ]
211
210
  console.log('mat', mat)
212
211
  // => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
213
212
  let resMat = await WCluster.cluster(mat, { mode, kNumber: 2, nCompNIPALS: 2 })
214
213
  console.log(JSON.stringify(resMat, null, 2))
215
214
  // => {
216
215
  // "keys": null,
217
216
  // "ginds": [
218
217
  // [ 2 ],
219
218
  // [ 0, 1, 3 ]
220
219
  // ],
221
220
  // "gmat": [
222
221
  // [
223
222
  // [ 77.39502404588043, 70.65388036857387 ]
224
223
  // ],
225
224
  // [
226
225
  // [ 36.76572825085965, 50.81184119955175 ],
227
226
  // [ 50.520478881706346, 69.86935352609807 ],
228
227
  // [ 55.318768821553576, 58.66492490577632 ]
229
228
  // ]
230
229
  // ],
231
230
  // "gltdt": [
232
231
  // [
233
232
  // [ 80, 70, 90 ]
234
233
  // ],
235
234
  // [
236
235
  // [ 40, 50, 60 ],
237
236
  // [ 50, 70, 60 ],
238
237
  // [ 50, 60, 80 ]
239
238
  // ]
240
239
  // ]
241
240
  // }
242
241
  let ltdt = [
243
242
  { name: 'Cameron', a: 40, b: 50, c: 60 },
244
243
  { name: 'Buckley', a: 50, b: 70, c: 60 },
245
244
  { name: 'Paul', a: 80, b: 70, c: 90 },
246
245
  { name: 'Fawcett', a: 50, b: 60, c: 80 },
247
246
  ]
248
247
  console.log('ltdt', ltdt)
249
248
  // => ltdt [
250
249
  // { name: 'Cameron', a: 40, b: 50, c: 60 },
251
250
  // { name: 'Buckley', a: 50, b: 70, c: 60 },
252
251
  // { name: 'Paul', a: 80, b: 70, c: 90 },
253
252
  // { name: 'Fawcett', a: 50, b: 60, c: 80 }
254
253
  // ]
255
254
  let resLtdt = await WCluster.cluster(ltdt, { mode, kNumber: 2, nCompNIPALS: 2 })
256
255
  console.log(JSON.stringify(resLtdt, null, 2))
257
256
  // => {
258
257
  // "keys": [ "a", "b", "c" ],
259
258
  // "ginds": [
260
259
  // [ 2 ],
261
260
  // [ 0, 1, 3 ]
262
261
  // ],
263
262
  // "gmat": [
264
263
  // [
265
264
  // [ 77.39502404588043, 70.65388036857387 ]
266
265
  // ],
267
266
  // [
268
267
  // [ 36.76572825085965, 50.81184119955175 ],
269
268
  // [ 50.520478881706346, 69.86935352609807 ],
270
269
  // [ 55.318768821553576, 58.66492490577632 ]
271
270
  // ]
272
271
  // ],
273
272
  // "gltdt": [
274
273
  // [
275
274
  // { "name": "Paul", "a": 80, "b": 70, "c": 90 }
276
275
  // ],
277
276
  // [
278
277
  // { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
279
278
  // { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
280
279
  // { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
281
280
  // ]
282
281
  // ]
283
282
  // }
284
283
  .catch((err) => {
285
284
  console.log(err)
286
285
  })</code></pre>
286
+ <pre class="prettyprint"><code>async function testPCA() {
287
287
  let mat = [
288
288
  [40, 50, 60],
289
289
  [50, 70, 60],
290
290
  [80, 70, 90],
291
291
  [50, 60, 80]
292
292
  ]
293
293
  console.log('mat', mat)
294
294
  // => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
295
295
  let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
296
296
  console.log(resMat)
297
297
  // => [
298
298
  // [ -1.704002697669786, 0.43087564048799354 ],
299
299
  // [ -0.2509699164590232, -1.1519035967558147 ],
300
300
  // [ 1.9913098008410954, 0.23244503334983269 ],
301
301
  // [ -0.03633718671228592, 0.48858292291798827 ]
302
302
  // ]
303
303
  let mat2 = [
304
304
  [1040, 50, 60],
305
305
  [1050, 70, 60],
306
306
  [1080, 70, 90],
307
307
  [1050, 60, 80]
308
308
  ]
309
309
  console.log('mat2', mat2)
310
310
  // => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
311
311
  let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
312
312
  console.log(resMat2)
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 mat3 = [
320
320
  [11040, 50, 60],
321
321
  [13050, 70, 60],
322
322
  [15080, 70, 90],
323
323
  [17050, 60, 80]
324
324
  ]
325
325
  console.log('mat3', mat3)
326
326
  // => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
327
327
  let resMat3 = await WCluster.PCA(mat3, { nCompNIPALS: 2 })
328
328
  console.log(resMat3)
329
329
  // => [
330
330
  // [ -1.8599655569892897, 0.4908764271508211 ],
331
331
  // [ -0.3950941652793108, -1.0977355294143445 ],
332
332
  // [ 1.3430199944041517, -0.17213692267477554 ],
333
333
  // [ 0.912039727864449, 0.778996024938299 ]
334
334
  // ]
335
335
  .catch((err) => {
336
336
  console.log(err)
337
337
  })
338
338
  let mode = 'k-medoids'
339
339
  let mat = [
340
340
  [40, 50, 60],
341
341
  [50, 70, 60],
342
342
  [80, 70, 90],
343
343
  [50, 60, 80]
344
344
  ]
345
345
  console.log('mat', mat)
346
346
  // => mat [ [ 40, 50, 60 ], [ 50, 70, 60 ], [ 80, 70, 90 ], [ 50, 60, 80 ] ]
347
347
  let resMat = await WCluster.cluster(mat, { mode, kNumber: 2, nCompNIPALS: 2 })
348
348
  console.log(JSON.stringify(resMat, null, 2))
349
349
  // => {
350
350
  // "keys": null,
351
351
  // "ginds": [
352
352
  // [ 0, 1, 3 ],
353
353
  // [ 2 ]
354
354
  // ],
355
355
  // "gmat": [
356
356
  // [
357
357
  // [ -1.704002697669786, 0.43087564048799354 ],
358
358
  // [ -0.2509699164590232, -1.1519035967558147 ],
359
359
  // [ -0.03633718671228592, 0.48858292291798827 ]
360
360
  // ],
361
361
  // [
362
362
  // [ 1.9913098008410954, 0.23244503334983269 ]
363
363
  // ]
364
364
  // ],
365
365
  // "gltdt": [
366
366
  // [
367
367
  // [ 40, 50, 60 ],
368
368
  // [ 50, 70, 60 ],
369
369
  // [ 50, 60, 80 ]
370
370
  // ],
371
371
  // [
372
372
  // [ 80, 70, 90 ]
373
373
  // ]
374
374
  // ]
375
375
  // }
376
376
  let mat2 = [
377
377
  [1040, 50, 60],
378
378
  [1050, 70, 60],
379
379
  [1080, 70, 90],
380
380
  [1050, 60, 80]
381
381
  ]
382
382
  console.log('mat2', mat2)
383
383
  // => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
384
384
  let resMat2 = await WCluster.cluster(mat2, { mode, kNumber: 2, nCompNIPALS: 2 })
385
385
  console.log(JSON.stringify(resMat2, null, 2))
386
386
  // => {
387
387
  // "keys": null,
388
388
  // "ginds": [
389
389
  // [ 0, 1, 3 ],
390
390
  // [ 2 ]
391
391
  // ],
392
392
  // "gmat": [
393
393
  // [
394
394
  // [ -1.704002697669786, 0.43087564048799354 ],
395
395
  // [ -0.2509699164590232, -1.1519035967558147 ],
396
396
  // [ -0.03633718671228592, 0.48858292291798827 ]
397
397
  // ],
398
398
  // [
399
399
  // [ 1.9913098008410954, 0.23244503334983269 ]
400
400
  // ]
401
401
  // ],
402
402
  // "gltdt": [
403
403
  // [
404
404
  // [ 1040, 50, 60 ],
405
405
  // [ 1050, 70, 60 ],
406
406
  // [ 1050, 60, 80 ]
407
407
  // ],
408
408
  // [
409
409
  // [ 1080, 70, 90 ]
410
410
  // ]
411
411
  // ]
412
412
  // }
413
413
  let mat3 = [
414
414
  [11040, 50, 60],
415
415
  [13050, 70, 60],
416
416
  [15080, 70, 90],
417
417
  [17050, 60, 80]
418
418
  ]
419
419
  console.log('mat3', mat3)
420
420
  // => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
421
421
  let resMat3 = await WCluster.cluster(mat3, { mode, kNumber: 2, nCompNIPALS: 2 })
422
422
  console.log(JSON.stringify(resMat3, null, 2))
423
423
  // => {
424
424
  // "keys": null,
425
425
  // "ginds": [
426
426
  // [ 1, 2, 3 ],
427
427
  // [ 0 ]
428
428
  // ],
429
429
  // "gmat": [
430
430
  // [
431
431
  // [ -0.3950941652793108, -1.0977355294143445 ],
432
432
  // [ 1.3430199944041517, -0.17213692267477554 ],
433
433
  // [ 0.912039727864449, 0.778996024938299 ]
434
434
  // ],
435
435
  // [
436
436
  // [ -1.8599655569892897, 0.4908764271508211 ]
437
437
  // ]
438
438
  // ],
439
439
  // "gltdt": [
440
440
  // [
441
441
  // [ 13050, 70, 60 ],
442
442
  // [ 15080, 70, 90 ],
443
443
  // [ 17050, 60, 80 ]
444
444
  // ],
445
445
  // [
446
446
  // [ 11040, 50, 60 ]
447
447
  // ]
448
448
  // ]
449
449
  // }
450
450
  let ltdt = [
451
451
  { name: 'Cameron', a: 40, b: 50, c: 60 },
452
452
  { name: 'Buckley', a: 50, b: 70, c: 60 },
453
453
  { name: 'Paul', a: 80, b: 70, c: 90 },
454
454
  { name: 'Fawcett', a: 50, b: 60, c: 80 },
455
455
  ]
456
456
  console.log('ltdt', ltdt)
457
457
  // => ltdt [
458
458
  // { name: 'Cameron', a: 40, b: 50, c: 60 },
459
459
  // { name: 'Buckley', a: 50, b: 70, c: 60 },
460
460
  // { name: 'Paul', a: 80, b: 70, c: 90 },
461
461
  // { name: 'Fawcett', a: 50, b: 60, c: 80 }
462
462
  // ]
463
463
  let resLtdt = await WCluster.cluster(ltdt, { mode, kNumber: 2, nCompNIPALS: 2 })
464
464
  console.log(JSON.stringify(resLtdt, null, 2))
465
465
  // => {
466
466
  // "keys": [ "a", "b", "c" ],
467
467
  // "ginds": [
468
468
  // [ 0, 1, 3 ],
469
469
  // [ 2 ]
470
470
  // ],
471
471
  // "gmat": [
472
472
  // [
473
473
  // [ -1.704002697669786, 0.43087564048799354 ],
474
474
  // [ -0.2509699164590232, -1.1519035967558147 ],
475
475
  // [ -0.03633718671228592, 0.48858292291798827 ]
476
476
  // ],
477
477
  // [
478
478
  // [ 1.9913098008410954, 0.23244503334983269 ]
479
479
  // ]
480
480
  // ],
481
481
  // "gltdt": [
482
482
  // [
483
483
  // { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
484
484
  // { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
485
485
  // { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
486
486
  // ],
487
487
  // [
488
488
  // { "name": "Paul", "a": 80, "b": 70, "c": 90 }
489
489
  // ]
490
490
  // ]
491
491
  // }
492
492
  .catch((err) => {
493
493
  console.log(err)
494
494
  })</code></pre>
495
495
 
496
496
 
497
497
 
@@ -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 Wed Aug 03 2022 18:39:23 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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 Wed Aug 03 2022 18:39:23 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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>
@@ -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 = 'done'
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
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  <head>
5
5
  <meta http-equiv="content-type" content="text/html charset=UTF-8" />
6
- <title>w-cluster cluster for k-medoids with web worker</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: 'k-medoids' })
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>w-cluster cluster for k-means</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: 'k-means' })
75
+ WCluster.cluster(dataIris, { kNumber: kNumber, nCompNIPALS: nCompNIPALS, mode: method })
68
76
  .then(function(res){
69
77
  console.log('res',res)
70
78
 
@@ -16,10 +16,46 @@ async function testPCA() {
16
16
  let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
17
17
  console.log(resMat)
18
18
  // => [
19
- // [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
20
- // [ 50.520478881706346, 69.86935352609807, 59.679283942385844 ],
21
- // [ 77.39502404588043, 70.65388036857387, 91.60517102143689 ],
22
- // [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
19
+ // [ -1.704002697669786, 0.43087564048799354 ],
20
+ // [ -0.2509699164590232, -1.1519035967558147 ],
21
+ // [ 1.9913098008410954, 0.23244503334983269 ],
22
+ // [ -0.03633718671228592, 0.48858292291798827 ]
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
+ // [ -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 ]
23
59
  // ]
24
60
 
25
61
  }
@@ -29,4 +65,3 @@ testPCA()
29
65
  })
30
66
 
31
67
  //node --experimental-modules --es-module-specifier-resolution=node g-PCA-nodeworker.mjs
32
-
package/g-PCA.mjs CHANGED
@@ -15,10 +15,46 @@ async function testPCA() {
15
15
  let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
16
16
  console.log(resMat)
17
17
  // => [
18
- // [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
19
- // [ 50.520478881706346, 69.86935352609807, 59.679283942385844 ],
20
- // [ 77.39502404588043, 70.65388036857387, 91.60517102143689 ],
21
- // [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
18
+ // [ -1.704002697669786, 0.43087564048799354 ],
19
+ // [ -0.2509699164590232, -1.1519035967558147 ],
20
+ // [ 1.9913098008410954, 0.23244503334983269 ],
21
+ // [ -0.03633718671228592, 0.48858292291798827 ]
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
+ // [ -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 ]
22
58
  // ]
23
59
 
24
60
  }
@@ -28,4 +64,3 @@ testPCA()
28
64
  })
29
65
 
30
66
  //node --experimental-modules --es-module-specifier-resolution=node g-PCA.mjs
31
-