-->

k-means clustering implementation in Javascript?

2020-07-06 06:11发布

问题:

I'm in need for a Javascript implementation of the k-means clustering algorithm. I only have 1-dimensional data and rarely more than 100 items, so performance is not an issue.

PS: I could only find one but it seems extremely unsteady, resulting in completely different clusters on virtually every call.

回答1:

k-means in Javascript:

http://code.google.com/p/hdict/source/browse/gae/files/kmeans.js

http://www.mymessedupmind.co.uk/index.php/javascript-k-mean-algorithm

Applet:

http://www.math.le.ac.uk/people/ag153/homepage/KmeansKmedoids/kmeans.jar



回答2:

In node and the browser:

https://github.com/harthur/clusterfck

You have a choice between k-means or hierarchical clustering with these distance functions:

  1. euclidean
  2. manhattan
  3. max


回答3:

Simple K-Means implementation: dimas-kmeans

var kmeans = require('dimas-kmeans')

var clusters = kmeans.getClusters(data);