type Input = {
data: Point[]; // data sample
k: number; // number of clusters
limit?: number; // max times to run kMeans iteration until convergence, defaults to Infinity
centroids?: Point[], // predefined centroids
// precision?: number, // TODO add float point precision option
};
type Result = {
clusters: Point[][], // data separated into clusters
centroids: Point[], // final centroids
iterations: number, // number of times kMeans did reclusterization
totalDistance: number, // sum of distances from examples to each cluster center
};
type Point = number[];
/**
* @throws error if invalid data provided
*/
function clusterize({k, data, centroids, limit = Infinity}: Input): Result
-
Notifications
You must be signed in to change notification settings - Fork 0
givehug/k-means-ts
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
K-Means implementation in TypeScript
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published