Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-kmeans

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-kmeans

K-means in Javascript

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44K
increased by4.01%
Maintainers
2
Weekly downloads
 
Created
Source

clustering

NPM version build status David deps npm download

K-means in JavaScript

Installation

npm install ml-kmeans

Methods

kmeans(data, centers, [props])

Returns an object containing the following:

  • clusters: array of cluster indexes for the training dots.
  • centroids: array of calculated centroids.
  • iterations: array of clusters and centroids calculated during each iteration. It's optional, only included when withIter is set to true (see below).

Arguments

  • data: An array of the (x,y) points to cluster, represented also as an array.
  • centers: An array of the K centers in format (x,y), represented also as an array.
  • props: A property object that can be used to set some parameters:
    • maxIter: Maximum number of iterations allowed. Its default is 100.
    • tol: The numerical error tolerance. Its default is 1e-6.
    • withIter: If true it adds an iterations property in the returned object. Its default is false.

Test

$ npm install
$ npm test

Authors

License

MIT

Keywords

FAQs

Package last updated on 22 Jul 2015

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