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.
Install the npm package
npm install --save ckmeans
Load into your project
// Using ES6 importsimport ckmeans from 'ckmeans';// Or, using requirevar ckmeans = require('ckmeans');
You can also use something like unpkg.com to include it via
<script> tag in the browser.
This function returns the first value in each cluster
var result = ;// [1, 12, 43, 123, 234, 1244]
Thanks to Haizhou Wang and Mingzhou Song for developing the original Ckmeans 1D clustering algorithm
yarn yarn test # run tests yarn build # build distributable files
- Build distributable file for browser:
- Update CHANGELOG.md with changes in next version bump
- Create new npm version:
npm version [major|minor|patch]
- Push to github with new version tag:
git push origin --tags
- Publish to npm: