@thi.ng/k-means 0.6.87 → 0.6.88

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/kmeans.js +5 -10
  3. package/package.json +11 -11
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-04-23T07:02:18Z
3
+ - **Last updated**: 2024-05-08T18:24:32Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/kmeans.js CHANGED
@@ -24,16 +24,14 @@ const kmeans = (k, samples, opts) => {
24
24
  let update = true;
25
25
  while (update && maxIter-- > 0) {
26
26
  update = assign(samples, centroids, clusters, dist);
27
- if (!update)
28
- break;
27
+ if (!update) break;
29
28
  for (let i = 0; i < k; i++) {
30
29
  const impl = strategy(dim);
31
30
  for (let j = 0; j < num; j++) {
32
31
  i === clusters[j] && impl.update(samples[j]);
33
32
  }
34
33
  const centroid = impl.finish();
35
- if (centroid)
36
- centroids[i] = centroid;
34
+ if (centroid) centroids[i] = centroid;
37
35
  }
38
36
  }
39
37
  return buildClusters(centroids, clusters);
@@ -53,8 +51,7 @@ const initKmeanspp = (k, samples, dist = DIST_SQ, rnd = SYSTEM) => {
53
51
  psum += d;
54
52
  return d;
55
53
  });
56
- if (!psum)
57
- break;
54
+ if (!psum) break;
58
55
  let id;
59
56
  do {
60
57
  id = weightedRandom(indices, probs, rnd)();
@@ -116,11 +113,9 @@ const meansLatLon = () => {
116
113
  n++;
117
114
  },
118
115
  finish: () => {
119
- if (!n)
120
- return;
116
+ if (!n) return;
121
117
  lat /= n;
122
- if (lat > 180)
123
- lat -= 360;
118
+ if (lat > 180) lat -= 360;
124
119
  lon /= n;
125
120
  return [lat, lon];
126
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/k-means",
3
- "version": "0.6.87",
3
+ "version": "0.6.88",
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",
@@ -36,17 +36,17 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.1",
40
- "@thi.ng/distance": "^2.4.72",
41
- "@thi.ng/errors": "^2.5.6",
42
- "@thi.ng/random": "^3.7.5",
43
- "@thi.ng/vectors": "^7.10.30"
39
+ "@thi.ng/api": "^8.11.2",
40
+ "@thi.ng/distance": "^2.4.73",
41
+ "@thi.ng/errors": "^2.5.7",
42
+ "@thi.ng/random": "^3.8.0",
43
+ "@thi.ng/vectors": "^7.10.31"
44
44
  },
45
45
  "devDependencies": {
46
- "@microsoft/api-extractor": "^7.43.0",
47
- "esbuild": "^0.20.2",
48
- "typedoc": "^0.25.12",
49
- "typescript": "^5.4.3"
46
+ "@microsoft/api-extractor": "^7.43.2",
47
+ "esbuild": "^0.21.1",
48
+ "typedoc": "^0.25.13",
49
+ "typescript": "^5.4.5"
50
50
  },
51
51
  "keywords": [
52
52
  "cluster",
@@ -83,5 +83,5 @@
83
83
  "status": "beta",
84
84
  "year": 2021
85
85
  },
86
- "gitHead": "aed3421c21044c005fbcb7cc37965ccf85a870d2\n"
86
+ "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
87
87
  }