New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/k-means

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/k-means - npm Package Compare versions

Comparing version 0.3.6 to 0.4.0

58

CHANGELOG.md

@@ -6,16 +6,26 @@ # Change Log

## [0.3.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/k-means@0.3.5...@thi.ng/k-means@0.3.6) (2021-09-03)
# [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/k-means@0.3.6...@thi.ng/k-means@0.4.0) (2021-10-12)
**Note:** Version bump only for package @thi.ng/k-means
### Build System
* major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea9fab2a645d6c5f2bf2591459b939c09b6))
### BREAKING CHANGES
# [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/k-means@0.2.5...@thi.ng/k-means@0.3.0) (2021-08-04)
* discontinue CommonJS & UMD versions
- only ESM modules will be published from now on
- CJS obsolete due to ESM support in recent versions of node:
- i.e. launch NodeJS via:
- `node --experimental-specifier-resolution=node --experimental-repl-await`
- in the node REPL use `await import(...)` instead of `require()`
- UMD obsolete due to widespread browser support for ESM
### Features
Also:
- normalize/restructure/reorg all package.json files
- cleanup all build scripts, remove obsolete
- switch from mocha to @thi.ng/testament for all tests
* **k-means:** auto-correct `k` if needed ([d3c3ffa](https://github.com/thi-ng/umbrella/commit/d3c3ffa768bdebe67843c8094af1fe7a9bc524ed))

@@ -26,36 +36,30 @@

## [0.2.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/k-means@0.2.4...@thi.ng/k-means@0.2.5) (2021-08-04)
# [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/k-means@0.2.5...@thi.ng/k-means@0.3.0) (2021-08-04)
### Features
### Bug Fixes
- **k-means:** auto-correct `k` if needed ([d3c3ffa](https://github.com/thi-ng/umbrella/commit/d3c3ffa768bdebe67843c8094af1fe7a9bc524ed))
* **k-means:** update initKmeanspp() ([dd0d965](https://github.com/thi-ng/umbrella/commit/dd0d9654b1aacce8a4bbbd921f2ce44d0eaa276a))
## [0.2.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/k-means@0.2.4...@thi.ng/k-means@0.2.5) (2021-08-04)
### Bug Fixes
- **k-means:** update initKmeanspp() ([dd0d965](https://github.com/thi-ng/umbrella/commit/dd0d9654b1aacce8a4bbbd921f2ce44d0eaa276a))
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/k-means@0.1.0...@thi.ng/k-means@0.2.0) (2021-04-20)
### Features
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/k-means@0.1.0...@thi.ng/k-means@0.2.0) (2021-04-20)
- **k-means:** add meansLatLon centroid strategy, docstrings ([269c11c](https://github.com/thi-ng/umbrella/commit/269c11c10907351d98acfb929af5036a23a2e5c3))
# 0.1.0 (2021-04-19)
### Features
### Bug Fixes
* **k-means:** add meansLatLon centroid strategy, docstrings ([269c11c](https://github.com/thi-ng/umbrella/commit/269c11c10907351d98acfb929af5036a23a2e5c3))
- **k-means:** use dist metric in initKmeanspp() ([37bd6c6](https://github.com/thi-ng/umbrella/commit/37bd6c6ae062f903cea05bd6ce9d42e97aa5dbd9))
### Features
# 0.1.0 (2021-04-19)
### Bug Fixes
* **k-means:** use dist metric in initKmeanspp() ([37bd6c6](https://github.com/thi-ng/umbrella/commit/37bd6c6ae062f903cea05bd6ce9d42e97aa5dbd9))
### Features
* **k-means:** add k-medians support ([6bc450b](https://github.com/thi-ng/umbrella/commit/6bc450b95e1ed93ab18a9045ce1d4ba324a61eb3))
* **k-means:** add kmeans++ initialization, update opts ([fcc2dcc](https://github.com/thi-ng/umbrella/commit/fcc2dcc9624dc77e99dc69bd54c466ea0d1f3988))
* **k-means:** import as new pkg ([a32aaf6](https://github.com/thi-ng/umbrella/commit/a32aaf63b703993adfb61766e36f9817aae1ed62))
- **k-means:** add k-medians support ([6bc450b](https://github.com/thi-ng/umbrella/commit/6bc450b95e1ed93ab18a9045ce1d4ba324a61eb3))
- **k-means:** add kmeans++ initialization, update opts ([fcc2dcc](https://github.com/thi-ng/umbrella/commit/fcc2dcc9624dc77e99dc69bd54c466ea0d1f3988))
- **k-means:** import as new pkg ([a32aaf6](https://github.com/thi-ng/umbrella/commit/a32aaf63b703993adfb61766e36f9817aae1ed62))

@@ -1,3 +0,3 @@

import { IDistance } from "@thi.ng/distance";
import { ReadonlyVec } from "@thi.ng/vectors";
import type { IDistance } from "@thi.ng/distance";
import type { ReadonlyVec } from "@thi.ng/vectors";
import type { CentroidStrategy, Cluster, KMeansOpts } from "./api";

@@ -36,3 +36,3 @@ /**

*/
export declare const initKmeanspp: <T extends ReadonlyVec>(k: number, samples: T[], dist?: IDistance<ReadonlyVec>, rnd?: import("@thi.ng/random").SystemRandom) => number[];
export declare const initKmeanspp: <T extends ReadonlyVec>(k: number, samples: T[], dist?: IDistance<ReadonlyVec>, rnd?: import("@thi.ng/random/system").SystemRandom) => number[];
/**

@@ -39,0 +39,0 @@ * Default centroid strategy forming new centroids by averaging the position of

@@ -1,5 +0,11 @@

import { assert } from "@thi.ng/api";
import { argmin, DIST_SQ } from "@thi.ng/distance";
import { SYSTEM, uniqueIndices, weightedRandom } from "@thi.ng/random";
import { add, median, mulN, zeroes } from "@thi.ng/vectors";
import { argmin } from "@thi.ng/distance/argmin";
import { DIST_SQ } from "@thi.ng/distance/squared";
import { assert } from "@thi.ng/errors/assert";
import { SYSTEM } from "@thi.ng/random/system";
import { uniqueIndices } from "@thi.ng/random/unique-indices";
import { weightedRandom } from "@thi.ng/random/weighted-random";
import { add } from "@thi.ng/vectors/add";
import { median } from "@thi.ng/vectors/median";
import { mulN } from "@thi.ng/vectors/muln";
import { zeroes } from "@thi.ng/vectors/setn";
/**

@@ -17,3 +23,8 @@ * Takes an array of n-dimensional `samples` and attempts to assign them to up

export const kmeans = (k, samples, opts) => {
let { dist, initial, maxIter, rnd, strategy } = Object.assign({ dist: DIST_SQ, maxIter: 32, strategy: means }, opts);
let { dist, initial, maxIter, rnd, strategy } = {
dist: DIST_SQ,
maxIter: 32,
strategy: means,
...opts,
};
const num = samples.length;

@@ -20,0 +31,0 @@ const dim = samples[0].length;

{
"name": "@thi.ng/k-means",
"version": "0.3.6",
"version": "0.4.0",
"description": "Configurable k-means & k-medians (with k-means++ initialization) for n-D vectors",
"type": "module",
"module": "./index.js",
"main": "./lib/index.js",
"umd:main": "./lib/index.umd.js",
"typings": "./index.d.ts",
"sideEffects": false,
"repository": {

@@ -27,26 +27,21 @@ "type": "git",

"scripts": {
"build": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module",
"build:release": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module all",
"build:es6": "tsc --declaration",
"build:test": "rimraf build && tsc -p test/tsconfig.json",
"build:check": "tsc --isolatedModules --noEmit",
"test": "mocha test",
"cover": "nyc mocha test && nyc report --reporter=lcov",
"clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
"build": "yarn clean && tsc --declaration",
"clean": "rimraf *.js *.d.ts *.map doc",
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
"doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
"pub": "yarn build:release && yarn publish --access public"
"doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
"doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
"pub": "yarn build && yarn publish --access public",
"test": "testament test"
},
"dependencies": {
"@thi.ng/api": "^7.2.0",
"@thi.ng/distance": "^1.0.7",
"@thi.ng/random": "^2.4.8",
"@thi.ng/vectors": "^6.2.0"
"@thi.ng/api": "^8.0.0",
"@thi.ng/distance": "^2.0.0",
"@thi.ng/errors": "^2.0.0",
"@thi.ng/random": "^3.0.0",
"@thi.ng/vectors": "^7.0.0"
},
"files": [
"*.js",
"*.d.ts",
"lib"
],
"devDependencies": {
"@thi.ng/testament": "^0.1.0"
},
"keywords": [

@@ -64,8 +59,22 @@ "cluster",

},
"sideEffects": false,
"files": [
"*.js",
"*.d.ts"
],
"exports": {
".": {
"import": "./index.js"
},
"./api": {
"import": "./api.js"
},
"./kmeans": {
"import": "./kmeans.js"
}
},
"thi.ng": {
"status": "alpha",
"status": "beta",
"year": 2021
},
"gitHead": "d971cb3f9b215a95483f78f1a8614015e331146f"
"gitHead": "9ac1344b38b565eb894306fbf72233b6c0b2d115"
}

@@ -27,3 +27,3 @@ <!-- This file is generated - DO NOT EDIT! -->

**ALPHA** - bleeding edge / work-in-progress
**BETA** - possibly breaking changes forthcoming

@@ -38,11 +38,19 @@ [Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bk-means%5D+in%3Atitle)

ES module import:
```html
// ES module
<script type="module" src="https://unpkg.com/@thi.ng/k-means?module" crossorigin></script>
<script type="module" src="https://cdn.skypack.dev/@thi.ng/k-means"></script>
```
// UMD
<script src="https://unpkg.com/@thi.ng/k-means/lib/index.umd.js" crossorigin></script>
[Skypack documentation](https://docs.skypack.dev/)
For NodeJS (v14.6+):
```text
node --experimental-specifier-resolution=node --experimental-repl-await
> const kMeans = await import("@thi.ng/k-means");
```
Package sizes (gzipped, pre-treeshake): ESM: 937 bytes / CJS: 998 bytes / UMD: 1.08 KB
Package sizes (gzipped, pre-treeshake): ESM: 987 bytes

@@ -53,2 +61,3 @@ ## Dependencies

- [@thi.ng/distance](https://github.com/thi-ng/umbrella/tree/develop/packages/distance)
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
- [@thi.ng/random](https://github.com/thi-ng/umbrella/tree/develop/packages/random)

@@ -68,2 +77,3 @@ - [@thi.ng/vectors](https://github.com/thi-ng/umbrella/tree/develop/packages/vectors)

| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/dominant-colors.png" width="240"/> | Color palette generation via dominant color extraction from uploaded images | [Demo](https://demo.thi.ng/umbrella/dominant-colors/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/dominant-colors) |
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/pixel-indexed.jpg" width="240"/> | Image dithering and remapping using indexed palettes | [Demo](https://demo.thi.ng/umbrella/pixel-indexed/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/pixel-indexed) |

@@ -70,0 +80,0 @@ ## API

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc