Javascript 中的 k-means 聚类实现?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7370785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
k-means clustering implementation in Javascript?
提问by stephanos
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.
我需要 k-means 聚类算法的 Javascript 实现。我只有一维数据,很少超过100个项目,所以性能不是问题。
PS: I could only find onebut it seems extremely unsteady, resulting in completely different clusters on virtually every call.
PS:我只能找到一个,但它似乎非常不稳定,几乎每次调用都会导致完全不同的集群。
采纳答案by cyborg
k-means in Javascript:
Javascript 中的 k 均值:
http://code.google.com/p/hdict/source/browse/gae/files/kmeans.js
http://code.google.com/p/hdict/source/browse/gae/files/kmeans.js
http://www.mymessedupmind.co.uk/index.php/javascript-k-mean-algorithm
http://www.mymessedupmind.co.uk/index.php/javascript-k-mean-algorithm
Applet:
小程序:
http://www.math.le.ac.uk/people/ag153/homepage/KmeansKmedoids/kmeans.jar
http://www.math.le.ac.uk/people/ag153/homepage/KmeansKmedoids/kmeans.jar
回答by Radek
In node and the browser:
在节点和浏览器中:
https://github.com/harthur/clusterfck
https://github.com/harthur/clusterfck
You have a choice between k-meansor hierarchical clusteringwith these distance functions:
您可以使用这些距离函数在k 均值或层次聚类之间进行选择:
- euclidean
- manhattan
- max
- 欧几里得
- 曼哈顿
- 最大限度
回答by shudima
Simple K-Means implementation: dimas-kmeans
简单的 K-Means 实现: dimas-kmeans
var kmeans = require('dimas-kmeans')
var clusters = kmeans.getClusters(data);