Socket
Socket
Sign inDemoInstall

ckmeans

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ckmeans

Ckmeans Javascript Implementation - Fast Univariate Clustering


Version published
Weekly downloads
2.5K
increased by41.24%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 03 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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