{"id":14111186,"url":"https://github.com/mljs/kmeans","last_synced_at":"2025-04-06T11:07:49.476Z","repository":{"id":33923250,"uuid":"37644016","full_name":"mljs/kmeans","owner":"mljs","description":"K-Means clustering","archived":false,"fork":false,"pushed_at":"2023-02-27T13:33:05.000Z","size":1457,"stargazers_count":87,"open_issues_count":6,"forks_count":14,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-30T10:06:45.688Z","etag":null,"topics":["clustering","kmeans"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mljs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-18T07:17:58.000Z","updated_at":"2025-03-14T14:09:13.000Z","dependencies_parsed_at":"2024-06-18T13:57:15.915Z","dependency_job_id":"3365ed39-b96c-4498-8b5d-9a0d46f39260","html_url":"https://github.com/mljs/kmeans","commit_stats":{"total_commits":87,"total_committers":10,"mean_commits":8.7,"dds":0.5977011494252873,"last_synced_commit":"291cce0d0e939bc8a22c58b879f81ff3503198a8"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fkmeans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fkmeans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fkmeans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fkmeans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/kmeans/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471518,"owners_count":20944158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clustering","kmeans"],"created_at":"2024-08-14T10:03:10.980Z","updated_at":"2025-04-06T11:07:49.458Z","avatar_url":"https://github.com/mljs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# ml-kmeans\n\n[K-means clustering][] aims to partition n observations into k clusters in which\neach observation belongs to the cluster with the nearest mean.\n\n\u003ch3 align=\"center\"\u003e\n\n  \u003ca href=\"https://www.zakodium.com\"\u003e\n    \u003cimg src=\"https://www.zakodium.com/brand/zakodium-logo-white.svg\" width=\"50\" alt=\"Zakodium logo\" /\u003e\n  \u003c/a\u003e\n\n  \u003cp\u003e\n    Maintained by \u003ca href=\"https://www.zakodium.com\"\u003eZakodium\u003c/a\u003e\n  \u003c/p\u003e\n\n[![NPM version][npm-image]][npm-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n\n\u003c/h3\u003e\n\n## Installation\n\n`npm i ml-kmeans`\n\n## [API Documentation](https://mljs.github.io/kmeans/)\n\n## Example\n\n```js\nconst { kmeans } = require('ml-kmeans');\n\nlet data = [\n  [1, 1, 1],\n  [1, 2, 1],\n  [-1, -1, -1],\n  [-1, -1, -1.5],\n];\nlet centers = [\n  [1, 2, 1],\n  [-1, -1, -1],\n];\n\nlet ans = kmeans(data, 2, { initialization: centers });\nconsole.log(ans);\n/*\nKMeansResult {\n  clusters: [ 0, 0, 1, 1 ],\n  centroids: [ [ 1, 1.5, 1 ], [ -1, -1, -1.25 ] ],\n  converged: true,\n  iterations: 2,\n  distance: [Function: squaredEuclidean]\n}\n*/\n\nconsole.log(ans.computeInformation(data));\n/*\n[\n  { centroid: [ 1, 1.5, 1 ], error: 0.5, size: 2 },\n  { centroid: [ -1, -1, -1.25 ], error: 0.125, size: 2 }\n]\n*/\n```\n\n## Authors\n\n- [Miguel Asencio](https://github.com/maasencioh)\n\n## Sources\n\nD. Arthur, S. Vassilvitskii, k-means++: The Advantages of Careful Seeding, in: Proc. of the 18th Annual\nACM-SIAM Symposium on Discrete Algorithms, 2007, pp. 1027–1035.\n[Link to article](http://ilpubs.stanford.edu:8090/778/1/2006-13.pdf)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-kmeans.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/ml-kmeans\n[codecov-image]: https://img.shields.io/codecov/c/github/mljs/kmeans.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/mljs/kmeans\n[download-image]: https://img.shields.io/npm/dm/ml-kmeans.svg?style=flat-square\n[download-url]: https://npmjs.org/package/ml-kmeans\n[k-means clustering]: https://en.wikipedia.org/wiki/K-means_clustering\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fkmeans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Fkmeans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fkmeans/lists"}