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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "allowUnknownTags": false
4
4
  },
5
5
  "source": {
6
- "include": ["src/"],
6
+ "include": ["src/", "server/"],
7
7
  "includePattern": ".+\\.(js(doc|x)?|mjs|vue)$",
8
8
  "excludePattern": "(node_modules/|docs)"
9
9
  },
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 semisphere(呂昱達)
3
+ Copyright (c) 2022 semisphere(yu-da, lyu 呂昱達)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -11,6 +11,15 @@ A tool for data PCA(Principle Component Analysis) and cluster(K-Means & K-Medoid
11
11
  ## Documentation
12
12
  To view documentation or get support, visit [docs](https://yuda-lyu.github.io/w-cluster/global.html).
13
13
 
14
+ ## Example
15
+ To view some examples for more understanding, visit examples:
16
+
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
+
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
+
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.
22
+
14
23
  ## Installation
15
24
  ### Using npm(ES6 module):
16
25
  > **Note:** w-cluster is mainly dependent on `ml-pca`, `ml-kmeans` and `k-medoids`.
@@ -36,10 +45,28 @@ async function testPCA() {
36
45
  let resMat = await WCluster.PCA(mat, { nCompNIPALS: 2 })
37
46
  console.log(resMat)
38
47
  // => [
39
- // [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
40
- // [ 50.520478881706346, 69.86935352609807, 59.679283942385844 ],
41
- // [ 77.39502404588043, 70.65388036857387, 91.60517102143689 ],
42
- // [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
48
+ // [ -22.27637140016484, -4.7649452046492735 ],
49
+ // [ -9.12778006150881, 12.303870466192656 ],
50
+ // [ 31.31672176507748, 0.2183960452169238 ],
51
+ // [ 0.08742969659617117, -7.757321306760306 ]
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
+ // [ -22.27637140016484, -4.7649452046492735 ],
67
+ // [ -9.12778006150881, 12.303870466192656 ],
68
+ // [ 31.31672176507748, 0.2183960452169238 ],
69
+ // [ 0.08742969659617117, -7.757321306760306 ]
43
70
  // ]
44
71
 
45
72
  }
@@ -74,24 +101,24 @@ async function testCluster() {
74
101
  // [ 2 ],
75
102
  // [ 0, 1, 3 ]
76
103
  // ],
77
- // "gltdt": [
104
+ // "gmat": [
78
105
  // [
79
- // [ 80, 70, 90 ]
106
+ // [ 31.31672176507748, 0.2183960452169238 ]
80
107
  // ],
81
108
  // [
82
- // [ 40, 50, 60 ],
83
- // [ 50, 70, 60 ],
84
- // [ 50, 60, 80 ],
109
+ // [ -22.27637140016484, -4.7649452046492735 ],
110
+ // [ -9.12778006150881, 12.303870466192656 ],
111
+ // [ 0.08742969659617117, -7.757321306760306 ]
85
112
  // ]
86
113
  // ],
87
- // "dmat": [
114
+ // "gltdt": [
88
115
  // [
89
- // [77.39502404588043, 70.65388036857387, 91.60517102143689]
116
+ // [ 80, 70, 90 ]
90
117
  // ],
91
118
  // [
92
- // [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
93
- // [ 50.520478881706346, 69.86935352609807, 59.679283942385844],
94
- // [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
119
+ // [ 40, 50, 60 ],
120
+ // [ 50, 70, 60 ],
121
+ // [ 50, 60, 80 ]
95
122
  // ]
96
123
  // ]
97
124
  // }
@@ -118,32 +145,24 @@ async function testCluster() {
118
145
  // [ 2 ],
119
146
  // [ 0, 1, 3 ]
120
147
  // ],
121
- // "gltdt": [
148
+ // "gmat": [
122
149
  // [
123
- // {
124
- // "name": "Paul", "a": 80, "b": 70, "c": 90
125
- // }
150
+ // [ 31.31672176507748, 0.2183960452169238 ]
126
151
  // ],
127
152
  // [
128
- // {
129
- // "name": "Cameron", "a": 40, "b": 50, "c": 60
130
- // },
131
- // {
132
- // "name": "Buckley", "a": 50, "b": 70, "c": 60
133
- // },
134
- // {
135
- // "name": "Fawcett", "a": 50, "b": 60, "c": 80
136
- // }
153
+ // [ -22.27637140016484, -4.7649452046492735 ],
154
+ // [ -9.12778006150881, 12.303870466192656 ],
155
+ // [ 0.08742969659617117, -7.757321306760306 ]
137
156
  // ]
138
157
  // ],
139
- // "dmat": [
158
+ // "gltdt": [
140
159
  // [
141
- // [77.39502404588043, 70.65388036857387, 91.60517102143689]
160
+ // { "name": "Paul", "a": 80, "b": 70, "c": 90 }
142
161
  // ],
143
162
  // [
144
- // [ 36.76572825085965, 50.81184119955175, 61.992939427698765 ],
145
- // [ 50.520478881706346, 69.86935352609807, 59.679283942385844],
146
- // [ 55.318768821553576, 58.66492490577632, 76.7226056084785 ]
163
+ // { "name": "Cameron", "a": 40, "b": 50, "c": 60 },
164
+ // { "name": "Buckley", "a": 50, "b": 70, "c": 60 },
165
+ // { "name": "Fawcett", "a": 50, "b": 60, "c": 80 }
147
166
  // ]
148
167
  // ]
149
168
  // }
@@ -163,17 +182,9 @@ testCluster()
163
182
  ```alias
164
183
 
165
184
  <!-- for basic -->
166
- <script src="https://cdn.jsdelivr.net/npm/w-cluster@1.0.9/dist/w-cluster.umd.js"></script>
185
+ <script src="https://cdn.jsdelivr.net/npm/w-cluster@1.0.12/dist/w-cluster.umd.js"></script>
167
186
 
168
187
  <!-- for web workers -->
169
- <script src="https://cdn.jsdelivr.net/npm/w-cluster@1.0.9/dist/w-cluster.wk.umd.js"></script>
188
+ <script src="https://cdn.jsdelivr.net/npm/w-cluster@1.0.12/dist/w-cluster.wk.umd.js"></script>
170
189
 
171
190
  ```
172
-
173
- > **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)]
174
-
175
- > **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)]
176
-
177
- > **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)]
178
-
179
- > **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.