kMeansCluster
kMeansCluster(
points,numCluster,randomSource?):object
Defined in: src/k_means_cluster.js:17
Perform k-means clustering.
Parameters
Section titled “Parameters”points
Section titled “points”number[][]
N-dimensional coordinates of points to be clustered.
numCluster
Section titled “numCluster”number
How many clusters to create.
randomSource?
Section titled “randomSource?”Function = Math.random
An optional entropy source that generates uniform values in [0, 1).
Returns
Section titled “Returns”object
Labels (same length as data) and centroids (same length as numCluster).
centroids
Section titled “centroids”centroids:
number[][]
labels
Section titled “labels”labels:
number[]
Throws
Section titled “Throws”If any centroids wind up friendless (i.e., without associated points).
Example
Section titled “Example”kMeansCluster([[0.0, 0.5], [1.0, 0.5]], 2); // => {labels: [0, 1], centroids: [[0.0, 0.5], [1.0, 0.5]]}