Package Exports
- ml-kmeans
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ml-kmeans) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
clustering
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 ofclusters
andcentroids
calculated during each iteration. It's optional, only included whenwithIter
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
: Iftrue
it adds aniterations
property in the returned object. Its default is false.
Test
$ npm install
$ npm test