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/README.md CHANGED
@@ -16,11 +16,9 @@ To view some examples for more understanding, visit examples:
16
16
 
17
17
  > **PCA:** [ex-PCA.html](https://yuda-lyu.github.io/w-cluster/examples/ex-PCA.html) [[source code](https://github.com/yuda-lyu/w-cluster/blob/master/docs/examples/ex-PCA.html)]
18
18
 
19
- > **cluster for k-means:** [ex-cluster-k-means.html](https://yuda-lyu.github.io/w-cluster/examples/ex-cluster-k-means.html) [[source code](https://github.com/yuda-lyu/w-cluster/blob/master/docs/examples/ex-cluster-k-means.html)]
19
+ > **cluster:** [ex-cluster.html](https://yuda-lyu.github.io/w-cluster/examples/ex-cluster.html) [[source code](https://github.com/yuda-lyu/w-cluster/blob/master/docs/examples/ex-cluster.html)]
20
20
 
21
- > **cluster for k-medoids:** [ex-cluster-k-medoids.html](https://yuda-lyu.github.io/w-cluster/examples/ex-cluster-k-medoids.html) [[source code](https://github.com/yuda-lyu/w-cluster/blob/master/docs/examples/ex-cluster-k-medoids.html)]
22
-
23
- > **cluster for k-medoids with web worker:** [ex-cluster-webworker-k-medoids.html](https://yuda-lyu.github.io/w-cluster/examples/ex-cluster-webworker-k-medoids.html) [[source code](https://github.com/yuda-lyu/w-cluster/blob/master/docs/examples/ex-cluster-webworker-k-medoids.html)] * WebWorkers(from blob) does not support IE11.
21
+ > **cluster with web worker:** [ex-cluster-webworker.html](https://yuda-lyu.github.io/w-cluster/examples/ex-cluster-webworker.html) [[source code](https://github.com/yuda-lyu/w-cluster/blob/master/docs/examples/ex-cluster-webworker.html)] * WebWorkers(from blob) does not support IE11.
24
22
 
25
23
  ## Installation
26
24
  ### Using npm(ES6 module):
@@ -47,10 +45,46 @@ async function testPCA() {
47
45
  let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
48
46
  console.log(resMat)
49
47
  // => [
50
- // [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
51
- // [ 50.520478881706346, 69.86935352609807, 59.679283942385844 ],
52
- // [ 77.39502404588043, 70.65388036857387, 91.60517102143689 ],
53
- // [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
48
+ // [ -1.704002697669786, 0.43087564048799354 ],
49
+ // [ -0.2509699164590232, -1.1519035967558147 ],
50
+ // [ 1.9913098008410954, 0.23244503334983269 ],
51
+ // [ -0.03633718671228592, 0.48858292291798827 ]
52
+ // ]
53
+
54
+ let mat2 = [
55
+ [1040, 50, 60],
56
+ [1050, 70, 60],
57
+ [1080, 70, 90],
58
+ [1050, 60, 80]
59
+ ]
60
+ console.log('mat2', mat2)
61
+ // => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
62
+
63
+ let resMat2 = await WCluster.PCA(mat2, { nCompNIPALS: 2 })
64
+ console.log(resMat2)
65
+ // => [
66
+ // [ -1.704002697669786, 0.43087564048799354 ],
67
+ // [ -0.2509699164590232, -1.1519035967558147 ],
68
+ // [ 1.9913098008410954, 0.23244503334983269 ],
69
+ // [ -0.03633718671228592, 0.48858292291798827 ]
70
+ // ]
71
+
72
+ let mat3 = [
73
+ [11040, 50, 60],
74
+ [13050, 70, 60],
75
+ [15080, 70, 90],
76
+ [17050, 60, 80]
77
+ ]
78
+ console.log('mat3', mat3)
79
+ // => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
80
+
81
+ let resMat3 = await WCluster.PCA(mat3, { nCompNIPALS: 2 })
82
+ console.log(resMat3)
83
+ // => [
84
+ // [ -1.8599655569892897, 0.4908764271508211 ],
85
+ // [ -0.3950941652793108, -1.0977355294143445 ],
86
+ // [ 1.3430199944041517, -0.17213692267477554 ],
87
+ // [ 0.912039727864449, 0.778996024938299 ]
54
88
  // ]
55
89
 
56
90
  }
@@ -82,27 +116,105 @@ async function testCluster() {
82
116
  // => {
83
117
  // "keys": null,
84
118
  // "ginds": [
85
- // [ 2 ],
86
- // [ 0, 1, 3 ]
119
+ // [ 0, 1, 3 ],
120
+ // [ 2 ]
87
121
  // ],
88
122
  // "gmat": [
89
123
  // [
90
- // [ 77.39502404588043, 70.65388036857387 ]
124
+ // [ -1.704002697669786, 0.43087564048799354 ],
125
+ // [ -0.2509699164590232, -1.1519035967558147 ],
126
+ // [ -0.03633718671228592, 0.48858292291798827 ]
91
127
  // ],
92
128
  // [
93
- // [ 36.76572825085965, 50.81184119955175 ],
94
- // [ 50.520478881706346, 69.86935352609807 ],
95
- // [ 55.318768821553576, 58.66492490577632 ]
129
+ // [ 1.9913098008410954, 0.23244503334983269 ]
96
130
  // ]
97
131
  // ],
98
132
  // "gltdt": [
99
133
  // [
100
- // [ 80, 70, 90 ]
101
- // ],
102
- // [
103
134
  // [ 40, 50, 60 ],
104
135
  // [ 50, 70, 60 ],
105
136
  // [ 50, 60, 80 ]
137
+ // ],
138
+ // [
139
+ // [ 80, 70, 90 ]
140
+ // ]
141
+ // ]
142
+ // }
143
+
144
+ let mat2 = [
145
+ [1040, 50, 60],
146
+ [1050, 70, 60],
147
+ [1080, 70, 90],
148
+ [1050, 60, 80]
149
+ ]
150
+ console.log('mat2', mat2)
151
+ // => mat [ [ 1040, 50, 60 ], [ 1050, 70, 60 ], [ 1080, 70, 90 ], [ 1050, 60, 80 ] ]
152
+
153
+ let resMat2 = await WCluster.cluster(mat2, { mode, kNumber: 2, nCompNIPALS: 2 })
154
+ console.log(JSON.stringify(resMat2, null, 2))
155
+ // => {
156
+ // "keys": null,
157
+ // "ginds": [
158
+ // [ 0, 1, 3 ],
159
+ // [ 2 ]
160
+ // ],
161
+ // "gmat": [
162
+ // [
163
+ // [ -1.704002697669786, 0.43087564048799354 ],
164
+ // [ -0.2509699164590232, -1.1519035967558147 ],
165
+ // [ -0.03633718671228592, 0.48858292291798827 ]
166
+ // ],
167
+ // [
168
+ // [ 1.9913098008410954, 0.23244503334983269 ]
169
+ // ]
170
+ // ],
171
+ // "gltdt": [
172
+ // [
173
+ // [ 1040, 50, 60 ],
174
+ // [ 1050, 70, 60 ],
175
+ // [ 1050, 60, 80 ]
176
+ // ],
177
+ // [
178
+ // [ 1080, 70, 90 ]
179
+ // ]
180
+ // ]
181
+ // }
182
+
183
+ let mat3 = [
184
+ [11040, 50, 60],
185
+ [13050, 70, 60],
186
+ [15080, 70, 90],
187
+ [17050, 60, 80]
188
+ ]
189
+ console.log('mat3', mat3)
190
+ // => mat [ [ 11040, 50, 60 ], [ 13050, 70, 60 ], [ 15080, 70, 90 ], [ 17050, 60, 80 ] ]
191
+
192
+ let resMat3 = await WCluster.cluster(mat3, { mode, kNumber: 2, nCompNIPALS: 2 })
193
+ console.log(JSON.stringify(resMat3, null, 2))
194
+ // => {
195
+ // "keys": null,
196
+ // "ginds": [
197
+ // [ 1, 2, 3 ],
198
+ // [ 0 ]
199
+ // ],
200
+ // "gmat": [
201
+ // [
202
+ // [ -0.3950941652793108, -1.0977355294143445 ],
203
+ // [ 1.3430199944041517, -0.17213692267477554 ],
204
+ // [ 0.912039727864449, 0.778996024938299 ]
205
+ // ],
206
+ // [
207
+ // [ -1.8599655569892897, 0.4908764271508211 ]
208
+ // ]
209
+ // ],
210
+ // "gltdt": [
211
+ // [
212
+ // [ 13050, 70, 60 ],
213
+ // [ 15080, 70, 90 ],
214
+ // [ 17050, 60, 80 ]
215
+ // ],
216
+ // [
217
+ // [ 11040, 50, 60 ]
106
218
  // ]
107
219
  // ]
108
220
  // }
@@ -126,27 +238,27 @@ async function testCluster() {
126
238
  // => {
127
239
  // "keys": [ "a", "b", "c" ],
128
240
  // "ginds": [
129
- // [ 2 ],
130
- // [ 0, 1, 3 ]
241
+ // [ 0, 1, 3 ],
242
+ // [ 2 ]
131
243
  // ],
132
244
  // "gmat": [
133
245
  // [
134
- // [ 77.39502404588043, 70.65388036857387 ]
246
+ // [ -1.704002697669786, 0.43087564048799354 ],
247
+ // [ -0.2509699164590232, -1.1519035967558147 ],
248
+ // [ -0.03633718671228592, 0.48858292291798827 ]
135
249
  // ],
136
250
  // [
137
- // [ 36.76572825085965, 50.81184119955175 ],
138
- // [ 50.520478881706346, 69.86935352609807 ],
139
- // [ 55.318768821553576, 58.66492490577632 ]
251
+ // [ 1.9913098008410954, 0.23244503334983269 ]
140
252
  // ]
141
253
  // ],
142
254
  // "gltdt": [
143
255
  // [
144
- // { "name": "Paul", "a": 80, "b": 70, "c": 90 }
145
- // ],
146
- // [
147
256
  // { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
148
257
  // { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
149
258
  // { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
259
+ // ],
260
+ // [
261
+ // { "name": "Paul", "a": 80, "b": 70, "c": 90 }
150
262
  // ]
151
263
  // ]
152
264
  // }
@@ -166,9 +278,9 @@ testCluster()
166
278
  ```alias
167
279
 
168
280
  <!-- for basic -->
169
- <script src="https://cdn.jsdelivr.net/npm/w-cluster@1.0.10/dist/w-cluster.umd.js"></script>
281
+ <script src="https://cdn.jsdelivr.net/npm/w-cluster@1.0.13/dist/w-cluster.umd.js"></script>
170
282
 
171
283
  <!-- for web workers -->
172
- <script src="https://cdn.jsdelivr.net/npm/w-cluster@1.0.10/dist/w-cluster.wk.umd.js"></script>
284
+ <script src="https://cdn.jsdelivr.net/npm/w-cluster@1.0.13/dist/w-cluster.wk.umd.js"></script>
173
285
 
174
286
  ```