k-means clustering in TypeScript
Library can be installed via npm.
$ npm install kmeans-clust
import {kmeans} from "kmeans-clust";
const points = [[0], [1], [9], [10]];
kmeans(points, 2)
//=> [ { centroid: [ 0.5 ], points: [ [Array], [Array] ], error: 1 },
//=> { centroid: [ 9.5 ], points: [ [Array], [Array] ], error: 1 } ]
$ npm run example
Live example is available https://mleko.gitlab.io/kmeans-clust/