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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 23:53:42  来源:igfitidea点击:

k-means clustering implementation in Javascript?

javascriptcluster-analysisk-means

提问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 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 均值层次聚类之间进行选择:

  1. euclidean
  2. manhattan
  3. max
  1. 欧几里得
  2. 曼哈顿
  3. 最大限度

回答by shudima

Simple K-Means implementation: dimas-kmeans

简单的 K-Means 实现: dimas-kmeans

var kmeans = require('dimas-kmeans')

var clusters = kmeans.getClusters(data);