ckmeans

2.1.0 • Public • Published

ckmeans

A javascript implementation of the ckmeans algorithm. It's effectively a 1-dimensional version of kmeans, where a set of values are clustered into discrete groups. The algorithm has an O(kn log(n)) runtime.

There is also a native version of this package if you need faster performance in node environments, see ckmeans-native

For an alternative API used commonly in data visualization applications, check out d3-scale-cluster.

Getting Started

Using npm

Install the npm package

npm install --save ckmeans

Load into your project

// Using ES6 imports
import ckmeans from 'ckmeans';
 
// Or, using require
var ckmeans = require('ckmeans');

You can also use something like unpkg.com to include it via <script> tag in the browser.

Example Usage

This function returns the first value in each cluster

var result = ckmeans([1, 2, 4, 5, 12, 43, 52, 123, 234, 1244], 6);
// [1, 12, 43, 123, 234, 1244]

Thanks

Thanks to Haizhou Wang and Mingzhou Song for developing the original Ckmeans 1D clustering algorithm

Contributing

yarn
yarn test  # run tests
yarn build # build distributable files

Publishing

  1. Build distributable file for browser: yarn build
  2. Update CHANGELOG.md with changes in next version bump
  3. Create new npm version: npm version [major|minor|patch]
  4. Push to github with new version tag: git push origin --tags
  5. Publish to npm: npm publish

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.1.0
    1,952
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.1.0
    1,952
  • 2.0.1
    0
  • 2.0.0
    0
  • 1.0.1
    243
  • 1.0.0
    0

Package Sidebar

Install

npm i ckmeans

Weekly Downloads

2,195

Version

2.1.0

License

MIT

Unpacked Size

219 kB

Total Files

7

Last publish

Collaborators

  • dschnurr