@thi.ng/k-means 0.5.6 → 0.5.9
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/CHANGELOG.md +1 -1
- package/README.md +2 -2
- package/kmeans.d.ts +8 -8
- package/kmeans.js +8 -8
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ node --experimental-repl-await
|
|
|
51
51
|
> const kMeans = await import("@thi.ng/k-means");
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Package sizes (gzipped, pre-treeshake): ESM:
|
|
54
|
+
Package sizes (gzipped, pre-treeshake): ESM: 987 bytes
|
|
55
55
|
|
|
56
56
|
## Dependencies
|
|
57
57
|
|
|
@@ -139,4 +139,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
139
139
|
|
|
140
140
|
## License
|
|
141
141
|
|
|
142
|
-
© 2021 Karsten Schmidt // Apache Software License 2.0
|
|
142
|
+
© 2021 - 2022 Karsten Schmidt // Apache Software License 2.0
|
package/kmeans.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ import type { CentroidStrategy, Cluster, KMeansOpts } from "./api.js";
|
|
|
8
8
|
* @remarks
|
|
9
9
|
* https://en.wikipedia.org/wiki/K-medians_clustering
|
|
10
10
|
*
|
|
11
|
-
* @param k
|
|
12
|
-
* @param samples
|
|
13
|
-
* @param opts
|
|
11
|
+
* @param k -
|
|
12
|
+
* @param samples -
|
|
13
|
+
* @param opts -
|
|
14
14
|
*/
|
|
15
15
|
export declare const kmeans: <T extends ReadonlyVec>(k: number, samples: T[], opts?: Partial<KMeansOpts> | undefined) => Cluster[];
|
|
16
16
|
/**
|
|
@@ -28,17 +28,17 @@ export declare const kmeans: <T extends ReadonlyVec>(k: number, samples: T[], op
|
|
|
28
28
|
* - http://ilpubs.stanford.edu:8090/778/1/2006-13.pdf
|
|
29
29
|
* - http://vldb.org/pvldb/vol5/p622_bahmanbahmani_vldb2012.pdf (TODO)
|
|
30
30
|
*
|
|
31
|
-
* @param k
|
|
32
|
-
* @param samples
|
|
33
|
-
* @param dist
|
|
34
|
-
* @param rnd
|
|
31
|
+
* @param k -
|
|
32
|
+
* @param samples -
|
|
33
|
+
* @param dist -
|
|
34
|
+
* @param rnd -
|
|
35
35
|
*/
|
|
36
36
|
export declare const initKmeanspp: <T extends ReadonlyVec>(k: number, samples: T[], dist?: IDistance<ReadonlyVec>, rnd?: import("@thi.ng/random/system").SystemRandom) => number[];
|
|
37
37
|
/**
|
|
38
38
|
* Default centroid strategy forming new centroids by averaging the position of
|
|
39
39
|
* participating samples.
|
|
40
40
|
*
|
|
41
|
-
* @param dim
|
|
41
|
+
* @param dim -
|
|
42
42
|
*/
|
|
43
43
|
export declare const means: CentroidStrategy;
|
|
44
44
|
/**
|
package/kmeans.js
CHANGED
|
@@ -15,9 +15,9 @@ import { zeroes } from "@thi.ng/vectors/setn";
|
|
|
15
15
|
* @remarks
|
|
16
16
|
* https://en.wikipedia.org/wiki/K-medians_clustering
|
|
17
17
|
*
|
|
18
|
-
* @param k
|
|
19
|
-
* @param samples
|
|
20
|
-
* @param opts
|
|
18
|
+
* @param k -
|
|
19
|
+
* @param samples -
|
|
20
|
+
* @param opts -
|
|
21
21
|
*/
|
|
22
22
|
export const kmeans = (k, samples, opts) => {
|
|
23
23
|
let { dist, initial, maxIter, rnd, strategy } = {
|
|
@@ -72,10 +72,10 @@ export const kmeans = (k, samples, opts) => {
|
|
|
72
72
|
* - http://ilpubs.stanford.edu:8090/778/1/2006-13.pdf
|
|
73
73
|
* - http://vldb.org/pvldb/vol5/p622_bahmanbahmani_vldb2012.pdf (TODO)
|
|
74
74
|
*
|
|
75
|
-
* @param k
|
|
76
|
-
* @param samples
|
|
77
|
-
* @param dist
|
|
78
|
-
* @param rnd
|
|
75
|
+
* @param k -
|
|
76
|
+
* @param samples -
|
|
77
|
+
* @param dist -
|
|
78
|
+
* @param rnd -
|
|
79
79
|
*/
|
|
80
80
|
export const initKmeanspp = (k, samples, dist = DIST_SQ, rnd = SYSTEM) => {
|
|
81
81
|
const num = samples.length;
|
|
@@ -128,7 +128,7 @@ const buildClusters = (centroids, clusters) => {
|
|
|
128
128
|
* Default centroid strategy forming new centroids by averaging the position of
|
|
129
129
|
* participating samples.
|
|
130
130
|
*
|
|
131
|
-
* @param dim
|
|
131
|
+
* @param dim -
|
|
132
132
|
*/
|
|
133
133
|
export const means = (dim) => {
|
|
134
134
|
const acc = zeroes(dim);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/k-means",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "Configurable k-means & k-medians (with k-means++ initialization) for n-D vectors",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
38
|
-
"@thi.ng/distance": "^2.1.
|
|
39
|
-
"@thi.ng/errors": "^2.1.
|
|
40
|
-
"@thi.ng/random": "^3.2.
|
|
41
|
-
"@thi.ng/vectors": "^7.
|
|
37
|
+
"@thi.ng/api": "^8.3.5",
|
|
38
|
+
"@thi.ng/distance": "^2.1.9",
|
|
39
|
+
"@thi.ng/errors": "^2.1.5",
|
|
40
|
+
"@thi.ng/random": "^3.2.5",
|
|
41
|
+
"@thi.ng/vectors": "^7.5.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@microsoft/api-extractor": "^7.19.
|
|
45
|
-
"@thi.ng/testament": "^0.2.
|
|
44
|
+
"@microsoft/api-extractor": "^7.19.4",
|
|
45
|
+
"@thi.ng/testament": "^0.2.5",
|
|
46
46
|
"rimraf": "^3.0.2",
|
|
47
47
|
"tools": "^0.0.1",
|
|
48
|
-
"typedoc": "^0.22.
|
|
49
|
-
"typescript": "^4.
|
|
48
|
+
"typedoc": "^0.22.13",
|
|
49
|
+
"typescript": "^4.6.2"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"cluster",
|
|
@@ -69,18 +69,18 @@
|
|
|
69
69
|
],
|
|
70
70
|
"exports": {
|
|
71
71
|
".": {
|
|
72
|
-
"
|
|
72
|
+
"default": "./index.js"
|
|
73
73
|
},
|
|
74
74
|
"./api": {
|
|
75
|
-
"
|
|
75
|
+
"default": "./api.js"
|
|
76
76
|
},
|
|
77
77
|
"./kmeans": {
|
|
78
|
-
"
|
|
78
|
+
"default": "./kmeans.js"
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"thi.ng": {
|
|
82
82
|
"status": "beta",
|
|
83
83
|
"year": 2021
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "5ee1feb590dd935593b1dd4e7f38a3ed3ba64765\n"
|
|
86
86
|
}
|