Skip to content
JavaScript HTML
Latest commit 7b8c4e4 May 18, 2015 @tmcw Rename for publishing
Failed to load latest commit information.
demo Finalish touches Sep 11, 2012
examples Churn. testing Sep 9, 2012
test More tests Sep 13, 2012
.DS_Store Progress Aug 24, 2012
LICENSE Create LICENSE Dec 11, 2012
README.md Rename for publishing May 18, 2015
kmeans.js More tests Sep 13, 2012
package.json Rename for publishing May 19, 2015

README.md

k-means-cluster

k-means clustering in configurable dimensions, in-browser and with node.js.

In order to support learning about the algorithm, this library is split into very small bits, so you can use each step separately.

var kmeans = require('k-means-cluster');

var d = [1, 2, 3];
// take a random sample of the array d
var s = kmeans.sample(d, 1);

console.log(s);
// [1]

// Get the euclidean distance between two points represented as
// arrays
console.log(kmeans.dist([0, 0], [0, 1]), 1);
// 1

In order to support a variety of data, accessors are used in functions like means_clusters(x, means, distance, val) (though with good defaults - distance defaults to euclidean, val defaults to function(x) { return x; }).

var c = kmeans.means_clusters([3], [3, 4])
console.log(c.length);
// 1

Usage

npm install --save k-means-cluster

Testing

npm test

License is WTFPL

Something went wrong with that request. Please try again.