w-cluster 1.0.42 → 1.0.44
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 +2 -2
- 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/DenseMatrix.html +1 -1
- package/docs/DistancePair.html +1 -1
- package/docs/LowerTriangle.html +1 -1
- package/docs/Rec.html +1 -1
- package/docs/Reco.html +1 -1
- package/docs/WCluster.mjs.html +19 -1
- package/docs/examples/ex-PCA.html +1 -1
- package/docs/examples/ex-cluster-webworker.html +1 -1
- package/docs/examples/ex-cluster.html +1 -1
- package/docs/global.html +172 -15
- package/docs/index.html +1 -1
- package/docs/k-medoids_alternating.mjs.html +1 -1
- package/docs/k-medoids_arrayadapter.mjs.html +1 -1
- package/docs/k-medoids_dynmsc.mjs.html +1 -1
- package/docs/k-medoids_fastermsc.mjs.html +1 -1
- package/docs/k-medoids_fasterpam.mjs.html +3 -3
- package/docs/k-medoids_fastmsc.mjs.html +1 -1
- package/docs/k-medoids_fastpam1.mjs.html +1 -1
- package/docs/k-medoids_initialization.mjs.html +1 -1
- package/docs/k-medoids_pam.mjs.html +4 -4
- package/docs/k-medoids_pammedsil.mjs.html +1 -1
- package/docs/k-medoids_pamsil.mjs.html +2 -2
- package/docs/k-medoids_par_fasterpam.mjs.html +2 -2
- package/docs/k-medoids_par_silhouette.mjs.html +1 -1
- package/docs/k-medoids_silhouette.mjs.html +3 -3
- package/docs/k-medoids_util.mjs.html +1 -1
- package/package.json +3 -3
- package/src/WCluster.mjs +18 -0
- package/src/k-medoids/fasterpam.mjs +2 -2
- package/src/k-medoids/pam.mjs +3 -3
- package/src/k-medoids/pamsil.mjs +1 -1
- package/src/k-medoids/par_fasterpam.mjs +1 -1
- package/src/k-medoids/silhouette.mjs +2 -2
- package/toolg/gDistRollup.mjs +6 -0
|
@@ -242,7 +242,7 @@ export function remove_med(mat, med, data, b) {
|
|
|
242
242
|
<br class="clear">
|
|
243
243
|
|
|
244
244
|
<footer>
|
|
245
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
245
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
246
246
|
</footer>
|
|
247
247
|
|
|
248
248
|
<script>prettyPrint();</script>
|
|
@@ -398,7 +398,7 @@ export function do_swap_k2(mat, med, assi, data, b, j) {
|
|
|
398
398
|
<br class="clear">
|
|
399
399
|
|
|
400
400
|
<footer>
|
|
401
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
401
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
402
402
|
</footer>
|
|
403
403
|
|
|
404
404
|
<script>prettyPrint();</script>
|
|
@@ -60,7 +60,7 @@ import { shuffle } from './initialization.mjs';
|
|
|
60
60
|
* @param mat - a pairwise distance matrix
|
|
61
61
|
* @param med - the list of medoids (mutated in place)
|
|
62
62
|
* @param maxiter - the maximum number of iterations allowed
|
|
63
|
-
* @returns { loss, assi, nIter, nSwaps }
|
|
63
|
+
* @returns {Object} { loss, assi, nIter, nSwaps }
|
|
64
64
|
*
|
|
65
65
|
* Panics (throws) when the dissimilarity matrix is not square, or k is 0 or larger than N.
|
|
66
66
|
*/
|
|
@@ -114,7 +114,7 @@ export function fasterpam(mat, med, maxiter) {
|
|
|
114
114
|
* @param med - the list of medoids (mutated in place)
|
|
115
115
|
* @param maxiter - the maximum number of iterations allowed
|
|
116
116
|
* @param rng - random number generator for shuffling the input data
|
|
117
|
-
* @returns { loss, assi, nIter, nSwaps }
|
|
117
|
+
* @returns {Object} { loss, assi, nIter, nSwaps }
|
|
118
118
|
*/
|
|
119
119
|
export function rand_fasterpam(mat, med, maxiter, rng = Math.random) {
|
|
120
120
|
mat = arrayAdapter(mat);
|
|
@@ -292,7 +292,7 @@ export function do_swap(mat, med, data, b, j) {
|
|
|
292
292
|
<br class="clear">
|
|
293
293
|
|
|
294
294
|
<footer>
|
|
295
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
295
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
296
296
|
</footer>
|
|
297
297
|
|
|
298
298
|
<script>prettyPrint();</script>
|
|
@@ -153,7 +153,7 @@ function fastmsc_k2(mat, med, maxiter) {
|
|
|
153
153
|
<br class="clear">
|
|
154
154
|
|
|
155
155
|
<footer>
|
|
156
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
156
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
157
157
|
</footer>
|
|
158
158
|
|
|
159
159
|
<script>prettyPrint();</script>
|
|
@@ -119,7 +119,7 @@ export function fastpam1(mat, med, maxiter) {
|
|
|
119
119
|
<br class="clear">
|
|
120
120
|
|
|
121
121
|
<footer>
|
|
122
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
122
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
123
123
|
</footer>
|
|
124
124
|
|
|
125
125
|
<script>prettyPrint();</script>
|
|
@@ -94,7 +94,7 @@ export function shuffle(rng, n) {
|
|
|
94
94
|
<br class="clear">
|
|
95
95
|
|
|
96
96
|
<footer>
|
|
97
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
97
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
98
98
|
</footer>
|
|
99
99
|
|
|
100
100
|
<script>prettyPrint();</script>
|
|
@@ -58,7 +58,7 @@ import { initial_assignment, do_swap } from './fasterpam.mjs';
|
|
|
58
58
|
* @param mat - a pairwise distance matrix
|
|
59
59
|
* @param med - the list of medoids (mutated in place)
|
|
60
60
|
* @param maxiter - the maximum number of iterations allowed
|
|
61
|
-
* @returns { loss, assi, nIter, nSwaps }
|
|
61
|
+
* @returns {Object} { loss, assi, nIter, nSwaps }
|
|
62
62
|
*/
|
|
63
63
|
export function pam_swap(mat, med, maxiter) {
|
|
64
64
|
mat = arrayAdapter(mat);
|
|
@@ -74,7 +74,7 @@ export function pam_swap(mat, med, maxiter) {
|
|
|
74
74
|
*
|
|
75
75
|
* @param mat - a pairwise distance matrix
|
|
76
76
|
* @param k - the number of medoids to pick
|
|
77
|
-
* @returns { loss, assi, meds }
|
|
77
|
+
* @returns {Object} { loss, assi, meds }
|
|
78
78
|
*/
|
|
79
79
|
export function pam_build(mat, k) {
|
|
80
80
|
mat = arrayAdapter(mat);
|
|
@@ -98,7 +98,7 @@ export function pam_build(mat, k) {
|
|
|
98
98
|
* @param mat - a pairwise distance matrix
|
|
99
99
|
* @param k - the number of medoids to pick
|
|
100
100
|
* @param maxiter - the maximum number of iterations allowed
|
|
101
|
-
* @returns { loss, assi, meds, nIter, nSwaps }
|
|
101
|
+
* @returns {Object} { loss, assi, meds, nIter, nSwaps }
|
|
102
102
|
*/
|
|
103
103
|
export function pam(mat, k, maxiter) {
|
|
104
104
|
mat = arrayAdapter(mat);
|
|
@@ -262,7 +262,7 @@ export function pam_build_initialize(mat, meds, data, k) {
|
|
|
262
262
|
<br class="clear">
|
|
263
263
|
|
|
264
264
|
<footer>
|
|
265
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
265
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
266
266
|
</footer>
|
|
267
267
|
|
|
268
268
|
<script>prettyPrint();</script>
|
|
@@ -294,7 +294,7 @@ function pammedsil_build_initialize(mat, meds, data, k) {
|
|
|
294
294
|
<br class="clear">
|
|
295
295
|
|
|
296
296
|
<footer>
|
|
297
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
297
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
298
298
|
</footer>
|
|
299
299
|
|
|
300
300
|
<script>prettyPrint();</script>
|
|
@@ -94,7 +94,7 @@ export function pamsil_swap(mat, med, maxiter) {
|
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Main optimization function of PAMSIL, not exposed (use pamsil_swap or pamsil).
|
|
97
|
-
* @returns {
|
|
97
|
+
* @returns {Array<number>} [loss, n_iter, n_swaps]
|
|
98
98
|
*/
|
|
99
99
|
function pamsil_optimize(mat, med, assi, maxiter) {
|
|
100
100
|
const n = mat.len(), k = med.length;
|
|
@@ -212,7 +212,7 @@ function pamsil_build_initialize(mat, meds, assi, k) {
|
|
|
212
212
|
<br class="clear">
|
|
213
213
|
|
|
214
214
|
<footer>
|
|
215
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
215
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
216
216
|
</footer>
|
|
217
217
|
|
|
218
218
|
<script>prettyPrint();</script>
|
|
@@ -62,7 +62,7 @@ import { shuffle } from './initialization.mjs';
|
|
|
62
62
|
* @param med - the list of medoids (mutated in place)
|
|
63
63
|
* @param maxiter - the maximum number of iterations allowed
|
|
64
64
|
* @param rng - random number generator for shuffling the input data
|
|
65
|
-
* @returns { loss, assi, nIter, nSwaps }
|
|
65
|
+
* @returns {Object} { loss, assi, nIter, nSwaps }
|
|
66
66
|
*
|
|
67
67
|
* Panics (throws) when the dissimilarity matrix is not square, or k is 0 or larger than N.
|
|
68
68
|
*/
|
|
@@ -121,7 +121,7 @@ export function par_fasterpam(mat, med, maxiter, rng = Math.random) {
|
|
|
121
121
|
<br class="clear">
|
|
122
122
|
|
|
123
123
|
<footer>
|
|
124
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
124
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
125
125
|
</footer>
|
|
126
126
|
|
|
127
127
|
<script>prettyPrint();</script>
|
|
@@ -113,7 +113,7 @@ export function par_silhouette(mat, assi) {
|
|
|
113
113
|
<br class="clear">
|
|
114
114
|
|
|
115
115
|
<footer>
|
|
116
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
116
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
117
117
|
</footer>
|
|
118
118
|
|
|
119
119
|
<script>prettyPrint();</script>
|
|
@@ -57,7 +57,7 @@ import { arrayAdapter } from './arrayadapter.mjs';
|
|
|
57
57
|
* @param mat - a pairwise distance matrix
|
|
58
58
|
* @param assi - the cluster assignment
|
|
59
59
|
* @param samples - whether to keep the individual samples, or not
|
|
60
|
-
* @returns { sil, samples } where sil is the average silhouette and samples are
|
|
60
|
+
* @returns {Object} { sil, samples } where sil is the average silhouette and samples are
|
|
61
61
|
* the individual silhouette values (empty [] if samples = false)
|
|
62
62
|
*/
|
|
63
63
|
export function silhouette(mat, assi, samples = false) {
|
|
@@ -121,7 +121,7 @@ export function silhouette(mat, assi, samples = false) {
|
|
|
121
121
|
* @param mat - a pairwise distance matrix
|
|
122
122
|
* @param meds - the medoid list
|
|
123
123
|
* @param samples - whether to keep the individual samples, or not
|
|
124
|
-
* @returns { sil, samples } where sil is the average medoid silhouette and
|
|
124
|
+
* @returns {Object} { sil, samples } where sil is the average medoid silhouette and
|
|
125
125
|
* samples are the individual values (empty [] if samples = false)
|
|
126
126
|
*/
|
|
127
127
|
export function medoid_silhouette(mat, meds, samples = false) {
|
|
@@ -180,7 +180,7 @@ export function checked_div(x, y) {
|
|
|
180
180
|
<br class="clear">
|
|
181
181
|
|
|
182
182
|
<footer>
|
|
183
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
183
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
184
184
|
</footer>
|
|
185
185
|
|
|
186
186
|
<script>prettyPrint();</script>
|
|
@@ -122,7 +122,7 @@ export function choose_medoid_within_partition(mat, assi, med, m) {
|
|
|
122
122
|
<br class="clear">
|
|
123
123
|
|
|
124
124
|
<footer>
|
|
125
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
125
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Oct 20 2026 01:19:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
126
126
|
</footer>
|
|
127
127
|
|
|
128
128
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-cluster",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.44",
|
|
4
4
|
"main": "dist/w-cluster.umd.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"k-medoids": "^1.0.8",
|
|
7
7
|
"ml-kmeans": "^7.0.1",
|
|
8
8
|
"ml-pca": "^4.1.1",
|
|
9
|
-
"wsemi": "^1.9.
|
|
9
|
+
"wsemi": "^1.9.21"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"w-package-tools": "^1.1.
|
|
12
|
+
"w-package-tools": "^1.1.21"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"test": "mocha --parallel \"test/*.test.mjs\" --timeout 180000",
|
package/src/WCluster.mjs
CHANGED
|
@@ -11,6 +11,15 @@ import WClusterCore from './WClusterCore.mjs'
|
|
|
11
11
|
* @param {Number} [opt.nCompNIPALS=2] 輸入指定降維的維度整數,不能超過數據的維度(各列有效元素數量),預設2
|
|
12
12
|
* @return {Promise} 回傳Promise,resolve回傳指定維數數值的陣列,reject回傳錯誤訊息
|
|
13
13
|
* @example
|
|
14
|
+
*
|
|
15
|
+
* let mat = [
|
|
16
|
+
* [40, 50, 60],
|
|
17
|
+
* [50, 70, 60],
|
|
18
|
+
* [80, 70, 90],
|
|
19
|
+
* [50, 60, 80]
|
|
20
|
+
* ]
|
|
21
|
+
* let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
|
|
22
|
+
* console.log(resMat)
|
|
14
23
|
*/
|
|
15
24
|
async function PCA(data, opt = {}) {
|
|
16
25
|
return WPCAMat(data, opt)
|
|
@@ -31,6 +40,15 @@ async function PCA(data, opt = {}) {
|
|
|
31
40
|
* @param {Number} [opt.seed] 輸入k-means隨機初始化種子整數,僅於mode為'k-means'時生效,給定則分群結果可重現,未提供時為隨機初始化
|
|
32
41
|
* @return {Promise} 回傳Promise,resolve回傳分群後結果物件,keys代表分群有使用到的欄位,ginds代表分群後的指標陣列,gltdt代表分群後的物件陣列,gmat代表分群後的數據陣列(usePCA為true時為PCA降維後數據,可例如取最左2欄代表x,y繪製二維分佈圖;usePCA為false時為原始數據),reject回傳錯誤訊息
|
|
33
42
|
* @example
|
|
43
|
+
*
|
|
44
|
+
* let mat = [
|
|
45
|
+
* [40, 50, 60],
|
|
46
|
+
* [50, 70, 60],
|
|
47
|
+
* [80, 70, 90],
|
|
48
|
+
* [50, 60, 80]
|
|
49
|
+
* ]
|
|
50
|
+
* let res = await WCluster.cluster(mat, { mode: 'k-medoids', kNumber: 2, nCompNIPALS: 2 })
|
|
51
|
+
* console.log(res.ginds)
|
|
34
52
|
*/
|
|
35
53
|
async function cluster(data, opt = {}) {
|
|
36
54
|
try {
|
|
@@ -13,7 +13,7 @@ import { shuffle } from './initialization.mjs';
|
|
|
13
13
|
* @param mat - a pairwise distance matrix
|
|
14
14
|
* @param med - the list of medoids (mutated in place)
|
|
15
15
|
* @param maxiter - the maximum number of iterations allowed
|
|
16
|
-
* @returns { loss, assi, nIter, nSwaps }
|
|
16
|
+
* @returns {Object} { loss, assi, nIter, nSwaps }
|
|
17
17
|
*
|
|
18
18
|
* Panics (throws) when the dissimilarity matrix is not square, or k is 0 or larger than N.
|
|
19
19
|
*/
|
|
@@ -67,7 +67,7 @@ export function fasterpam(mat, med, maxiter) {
|
|
|
67
67
|
* @param med - the list of medoids (mutated in place)
|
|
68
68
|
* @param maxiter - the maximum number of iterations allowed
|
|
69
69
|
* @param rng - random number generator for shuffling the input data
|
|
70
|
-
* @returns { loss, assi, nIter, nSwaps }
|
|
70
|
+
* @returns {Object} { loss, assi, nIter, nSwaps }
|
|
71
71
|
*/
|
|
72
72
|
export function rand_fasterpam(mat, med, maxiter, rng = Math.random) {
|
|
73
73
|
mat = arrayAdapter(mat);
|
package/src/k-medoids/pam.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { initial_assignment, do_swap } from './fasterpam.mjs';
|
|
|
11
11
|
* @param mat - a pairwise distance matrix
|
|
12
12
|
* @param med - the list of medoids (mutated in place)
|
|
13
13
|
* @param maxiter - the maximum number of iterations allowed
|
|
14
|
-
* @returns { loss, assi, nIter, nSwaps }
|
|
14
|
+
* @returns {Object} { loss, assi, nIter, nSwaps }
|
|
15
15
|
*/
|
|
16
16
|
export function pam_swap(mat, med, maxiter) {
|
|
17
17
|
mat = arrayAdapter(mat);
|
|
@@ -27,7 +27,7 @@ export function pam_swap(mat, med, maxiter) {
|
|
|
27
27
|
*
|
|
28
28
|
* @param mat - a pairwise distance matrix
|
|
29
29
|
* @param k - the number of medoids to pick
|
|
30
|
-
* @returns { loss, assi, meds }
|
|
30
|
+
* @returns {Object} { loss, assi, meds }
|
|
31
31
|
*/
|
|
32
32
|
export function pam_build(mat, k) {
|
|
33
33
|
mat = arrayAdapter(mat);
|
|
@@ -51,7 +51,7 @@ export function pam_build(mat, k) {
|
|
|
51
51
|
* @param mat - a pairwise distance matrix
|
|
52
52
|
* @param k - the number of medoids to pick
|
|
53
53
|
* @param maxiter - the maximum number of iterations allowed
|
|
54
|
-
* @returns { loss, assi, meds, nIter, nSwaps }
|
|
54
|
+
* @returns {Object} { loss, assi, meds, nIter, nSwaps }
|
|
55
55
|
*/
|
|
56
56
|
export function pam(mat, k, maxiter) {
|
|
57
57
|
mat = arrayAdapter(mat);
|
package/src/k-medoids/pamsil.mjs
CHANGED
|
@@ -47,7 +47,7 @@ export function pamsil_swap(mat, med, maxiter) {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Main optimization function of PAMSIL, not exposed (use pamsil_swap or pamsil).
|
|
50
|
-
* @returns {
|
|
50
|
+
* @returns {Array<number>} [loss, n_iter, n_swaps]
|
|
51
51
|
*/
|
|
52
52
|
function pamsil_optimize(mat, med, assi, maxiter) {
|
|
53
53
|
const n = mat.len(), k = med.length;
|
|
@@ -15,7 +15,7 @@ import { shuffle } from './initialization.mjs';
|
|
|
15
15
|
* @param med - the list of medoids (mutated in place)
|
|
16
16
|
* @param maxiter - the maximum number of iterations allowed
|
|
17
17
|
* @param rng - random number generator for shuffling the input data
|
|
18
|
-
* @returns { loss, assi, nIter, nSwaps }
|
|
18
|
+
* @returns {Object} { loss, assi, nIter, nSwaps }
|
|
19
19
|
*
|
|
20
20
|
* Panics (throws) when the dissimilarity matrix is not square, or k is 0 or larger than N.
|
|
21
21
|
*/
|
|
@@ -10,7 +10,7 @@ import { arrayAdapter } from './arrayadapter.mjs';
|
|
|
10
10
|
* @param mat - a pairwise distance matrix
|
|
11
11
|
* @param assi - the cluster assignment
|
|
12
12
|
* @param samples - whether to keep the individual samples, or not
|
|
13
|
-
* @returns { sil, samples } where sil is the average silhouette and samples are
|
|
13
|
+
* @returns {Object} { sil, samples } where sil is the average silhouette and samples are
|
|
14
14
|
* the individual silhouette values (empty [] if samples = false)
|
|
15
15
|
*/
|
|
16
16
|
export function silhouette(mat, assi, samples = false) {
|
|
@@ -74,7 +74,7 @@ export function silhouette(mat, assi, samples = false) {
|
|
|
74
74
|
* @param mat - a pairwise distance matrix
|
|
75
75
|
* @param meds - the medoid list
|
|
76
76
|
* @param samples - whether to keep the individual samples, or not
|
|
77
|
-
* @returns { sil, samples } where sil is the average medoid silhouette and
|
|
77
|
+
* @returns {Object} { sil, samples } where sil is the average medoid silhouette and
|
|
78
78
|
* samples are the individual values (empty [] if samples = false)
|
|
79
79
|
*/
|
|
80
80
|
export function medoid_silhouette(mat, meds, samples = false) {
|
package/toolg/gDistRollup.mjs
CHANGED
|
@@ -22,7 +22,9 @@ async function rp() {
|
|
|
22
22
|
],
|
|
23
23
|
})
|
|
24
24
|
.catch((err) => {
|
|
25
|
+
//建置失敗須以非0結束, 使發布流程得知
|
|
25
26
|
console.log(err)
|
|
27
|
+
process.exitCode = 1
|
|
26
28
|
})
|
|
27
29
|
|
|
28
30
|
await rollupWorker({
|
|
@@ -45,12 +47,16 @@ async function rp() {
|
|
|
45
47
|
],
|
|
46
48
|
})
|
|
47
49
|
.catch((err) => {
|
|
50
|
+
//建置失敗須以非0結束, 使發布流程得知
|
|
48
51
|
console.log(err)
|
|
52
|
+
process.exitCode = 1
|
|
49
53
|
})
|
|
50
54
|
|
|
51
55
|
}
|
|
52
56
|
rp()
|
|
53
57
|
.catch((err) => {
|
|
58
|
+
//建置失敗須以非0結束, 使發布流程得知
|
|
54
59
|
console.log(err)
|
|
60
|
+
process.exitCode = 1
|
|
55
61
|
})
|
|
56
62
|
|