{"_id":"k-means-pp","_rev":"9-e91f5af930b2af571412bdcfaa534dc8","name":"k-means-pp","dist-tags":{"latest":"4.0.0"},"versions":{"1.0.0":{"name":"k-means-pp","version":"1.0.0","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@1.0.0","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"fe6afb26f5f13b5289ddbac864c43063faa2e3b3","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-1.0.0.tgz","fileCount":22,"integrity":"sha512-7QSeAFsPQjYxzh9BDFaZxvpemS66xGyEhAZO9jHRGlh1NxybBP6PSlTlPVNPRMsp+SMKrsCddMBcMvLqPRtd0Q==","signatures":[{"sig":"MEYCIQC0uuMTGQzwiekaYBeiLrZEJgVvCkWDuKhaK0lVQwUGggIhAOWirc/nJx3IdTiQ3Imz7il+1f5P9qJhxYl8GS+ogTGN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14512},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"5a1826658722b9e6ca6b9f8cf2f2d203f0d1185c","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_1.0.0_1725619842158_0.11882011999151021","host":"s3://npm-registry-packages"}},"2.0.1":{"name":"k-means-pp","version":"2.0.1","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@2.0.1","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"4e2cfaff6c96d54d510b33388b514290b4f211e4","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-2.0.1.tgz","fileCount":22,"integrity":"sha512-eNUPj8B6dT+GA/hvdGLdmKLzy0+UIYaP8He6e182NdOwiUqbFLP7OHMf/Q1I25zHrkojUcChXCRporx6BemDJQ==","signatures":[{"sig":"MEQCIF85g86TlSkgY9k3j3rqX5qPfvMe9MB2qJyZe6eUpLdKAiBsp5BismG8p9rXxqFFgS+jVwwSowbi22yAQzp7kka8Fg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19958},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"0f44bf6f45504d32a78fe65a7d7eb89929b0a7e7","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_2.0.1_1725680692725_0.8543715433713137","host":"s3://npm-registry-packages"}},"2.1.0":{"name":"k-means-pp","version":"2.1.0","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@2.1.0","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"3a21f378859124c45b8d63fba6f40f9766149e8e","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-2.1.0.tgz","fileCount":22,"integrity":"sha512-8QfwdvXq5ZLZCU+nmuLGZ/49XhmONdiaO43G80mvy+PTfYaWOHRzQBSKohOlwVSQV/iHq/f+2YyTkP9gkofUQg==","signatures":[{"sig":"MEQCIEupOhPmWIwFwPZzWxZAeZDx//xkqGOU9rXVNUM2NrOcAiA/IGNfY+KXo3fiQmrvqg/SAX3cm3LIJ4c5khQ0372GwA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21106},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"f191efa7b10b59c32354b4e277e192f39c7df797","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_2.1.0_1725692262061_0.3920566811218771","host":"s3://npm-registry-packages"}},"2.2.0":{"name":"k-means-pp","version":"2.2.0","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@2.2.0","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"db5bce2c41f8bf748f3b62696bf08489af73f5f3","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-2.2.0.tgz","fileCount":22,"integrity":"sha512-E/HNDux90Sd6YRdS+L5eX9p7SYD0X02EjJTUy4/70LhGf4F8QUj1i0xCresy3eUJNskl1nUxD8dGn2CGbZO8dQ==","signatures":[{"sig":"MEUCIQDz1VLzKRTjoaLu9CyG0wCnhQ/k4oatEA35UElZnibY3wIgZfup0Vdy9G+TOECuKz6SQGqZzmDFo6ult+NBYKBEtuk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21455},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"f191efa7b10b59c32354b4e277e192f39c7df797","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_2.2.0_1726125154684_0.9690077079658603","host":"s3://npm-registry-packages"}},"2.2.1":{"name":"k-means-pp","version":"2.2.1","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@2.2.1","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"7114ea719e1cd1228189288f2ee58728092619df","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-2.2.1.tgz","fileCount":22,"integrity":"sha512-mOx2i+dw0+mRMlFm3OOhzDtlGx7HzAtEsol8oM98lWYatqocFLH9zx0f+QdzvmJNsUpoFvjJHTeDoxhc9WBdrg==","signatures":[{"sig":"MEYCIQDOEZmTvjwoTv4gD/Q747plqRp6ep6Ex6pbJGfCOpiq6AIhAM2pOQ4gaEjACfpz0PjUmKvzLkHf+YbFRAS+ADhTmwJf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21503},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"c5749716b1b7a2444639bec43898813529e229a3","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_2.2.1_1726221723680_0.9164235982429978","host":"s3://npm-registry-packages"}},"2.3.1":{"name":"k-means-pp","version":"2.3.1","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@2.3.1","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"2f9244f9d4f8c9a8f8c3a4ee22ee84821e23d324","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-2.3.1.tgz","fileCount":22,"integrity":"sha512-CuSc3HDVE9h2WO5J+bvW3LukDKCiON00sg9M2pNZIG4YlFfRczWeVpUZmvtfPw42l94gF22GEcpdyOkTv7a47g==","signatures":[{"sig":"MEQCIErp5DEvqfx1fw9ahFcQjcUaaYWTpkP3AujN2KYzhL2uAiAX16XLkKS8sVtwvyA0KigJdzUBzAPAWZ7RpdO3u7i9vw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22574},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"c5749716b1b7a2444639bec43898813529e229a3","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_2.3.1_1726715643703_0.8728725704930631","host":"s3://npm-registry-packages"}},"3.0.1":{"name":"k-means-pp","version":"3.0.1","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@3.0.1","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"7ce7486744897139a8830064df23922af1f537ba","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-3.0.1.tgz","fileCount":19,"integrity":"sha512-x+XeLpCv3Thvkn0KfQMgRAyprdgmfNT4jw3Va8JvbFXIWPCiPxzlRMC8EgkrcTEdt9pcLIVQnv6WUn8rcq78nQ==","signatures":[{"sig":"MEQCIHpw4SCQUTgMy7iPcTozOyPnS68c4Y7p+X3gGp/NByv8AiAEiqauAcMEV6lC0RQRcRtks5rkp6N2CTH35XtNYcaXAA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14140},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"9012d5b8c7c154959821575b2fd73bde34444f37","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_3.0.1_1739785873808_0.5833381227557868","host":"s3://npm-registry-packages-npm-production"}},"3.1.0":{"name":"k-means-pp","version":"3.1.0","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@3.1.0","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"5fc57c67910ecfb2acbc1897bd55a67181a456e5","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-3.1.0.tgz","fileCount":19,"integrity":"sha512-88k/iu2IF6Y+YLt7Y2ng34MsNYVghAHJl2X7W76M+ibm8o4eIAv4ApQ28INXG4qVnqH9b7vxyP2WKTFV7PgD2g==","signatures":[{"sig":"MEYCIQDgi2A4FARR9Q0baRoElR8HNqAJWwQMkOTtzrErB5PwFgIhAKRDN3/r3LKhSX1as0/PKot31whItR+JZy6gX57aRy8N","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13843},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"68f8b1f0c299287bae6b8844c4360aff6da6b0aa","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_3.1.0_1739786860496_0.9042969456087935","host":"s3://npm-registry-packages-npm-production"}},"3.2.0":{"name":"k-means-pp","version":"3.2.0","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"license":"Unlicense","_id":"k-means-pp@3.2.0","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"dist":{"shasum":"7d62906ec4f9411d0576042f71917164a29016ff","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-3.2.0.tgz","fileCount":19,"integrity":"sha512-lP7kVOHynrFV4Y+ID8f0XPnorMKjR/bIcXQuGbq2qPBgYxz92XCkUwIMUwf9odbZyMSHBpLK9ZkftjXBFhnlxA==","signatures":[{"sig":"MEUCIQCAGzJ5yIKItD+AknnBJgTxrDPrp2hJLdxF3WpGGMfCVAIgQ54xvg/Cj27EjMShFtehqyW0XtWB9nIQT48SCU72ChQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13908},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"gitHead":"68f8b1f0c299287bae6b8844c4360aff6da6b0aa","_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"repository":{"url":"git+https://github.com/ppzreboot/k-means-pp.js.git","type":"git"},"_npmVersion":"10.7.0","description":"A JS/TS implementation of the k-means algorithm.","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/k-means-pp_3.2.0_1740464781337_0.5819420500343853","host":"s3://npm-registry-packages-npm-production"}},"4.0.0":{"name":"k-means-pp","version":"4.0.0","description":"A JS/TS implementation of the k-means algorithm.","keywords":["k-means++","k-means","kmeans"],"author":{"name":"ppz"},"repository":{"type":"git","url":"git+https://github.com/ppzreboot/k-means-pp.js.git"},"license":"Unlicense","bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js"}},"_id":"k-means-pp@4.0.0","gitHead":"584b07e88928afa3d0840db07a90d7405de80fe7","homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","_nodeVersion":"22.2.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-f7j7Uvjo9Tz4P5ibc18E1Q46wC7FU38EnmHLV8LjQtpp/7k/aqR4OfLNgvuGwPTjxgIIzJAHCPiiyXKdaroWhg==","shasum":"ebaf436e66d82e4a85fc88ce50aa825782b753a5","tarball":"https://registry.npmjs.org/k-means-pp/-/k-means-pp-4.0.0.tgz","fileCount":19,"unpackedSize":15562,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEIaZ3uexndS+XB2GKesEij/QZ9TBFiAkLm/EKZPQXx3AiEAqtGfCZSNRjajblrbekujnsaGmDN8Z1jddZZgi58IT80="}]},"_npmUser":{"name":"ppzreboot","email":"ppzreboot@qq.com"},"directories":{},"maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/k-means-pp_4.0.0_1741060162567_0.2026368040754003"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-06T10:50:42.037Z","modified":"2025-03-04T03:49:22.931Z","1.0.0":"2024-09-06T10:50:42.318Z","2.0.1":"2024-09-07T03:44:52.920Z","2.1.0":"2024-09-07T06:57:42.187Z","2.2.0":"2024-09-12T07:12:34.804Z","2.2.1":"2024-09-13T10:02:03.840Z","2.3.1":"2024-09-19T03:14:03.897Z","3.0.1":"2025-02-17T09:51:14.026Z","3.1.0":"2025-02-17T10:07:40.678Z","3.2.0":"2025-02-25T06:26:21.517Z","4.0.0":"2025-03-04T03:49:22.744Z"},"bugs":{"url":"https://github.com/ppzreboot/k-means-pp.js/issues"},"author":{"name":"ppz"},"license":"Unlicense","homepage":"https://github.com/ppzreboot/k-means-pp.js#readme","keywords":["k-means++","k-means","kmeans"],"repository":{"type":"git","url":"git+https://github.com/ppzreboot/k-means-pp.js.git"},"description":"A JS/TS implementation of the k-means algorithm.","maintainers":[{"name":"ppzreboot","email":"ppzreboot@qq.com"}],"readme":"# k-means-pp.js\nA JS/TS implementation of the k-means and k-means++ clustering algorithm.\n\n+ Implements both k-means and k-means++ algorithms\n+ Supports multi-dimensional data points\n+ Works in any JavaScript environment, including browsers, Node.js, Deno and more\n\n## Installation\n\n##### deno\n``` bash\ndeno add @ppz/k-means-pp\n```\n\n##### npm\n```bash\nnpm install k-means-pp\n```\n\n## Usage\n\n##### basic\n\n```ts\n// import { k_means_pp, k_means } from '@ppz/k-means-pp' // install from deno\nimport { k_means_pp, k_means } from 'k-means-pp' // install from npm\n\nconst dimension = 3\nconst points = [\n  [1,2,3],\n  [0, 270, 103],\n  [3,4,5],\n  [0,0,0],\n  [100, 200, 1],\n  [0, 310, 120],\n  [10, 320, 90],\n  [100, 201, 3],\n  [0, 300, 100],\n  [1000, 2000, 1],\n]\n\nconst range = calc_range(dimension, points)\n\nconst [clusters, count] = k_means_pp({\n  dimension,\n  points,\n  k: 8,\n  range,\n})\nconsole.log(clusters.map(c => c.mean), count)\n\nconst [clusters_pp, count_pp] = k_means({\n  dimension,\n  points,\n  k: 8,\n  range,\n})\nconsole.log(clusters_pp.map(c => c.mean), count_pp)\n```\n\n##### customize distance quantification\n\n``` ts\nimport { k_means_pp } from 'k-means-pp' // install from npm\n\nconst dimension = 3\nconst points = [\n  [1,2,3],\n  [0, 270, 103],\n  [3,4,5],\n  [0,0,0],\n  [100, 200, 1],\n  // ...\n]\n\nconst [clusters, count] = k_means_pp({\n  dimension,\n  points,\n  k: 3,\n  range,\n  quantify(dimension, a_point, b_point) {\n    let squared = 0\n    for(let i=0; i<dimension; i++)\n      squared += (a_point[i] - b_point[i]) **2\n    return squared\n  },\n})\n```\n\n## API\n+ [k_means](https://jsr.io/@ppz/k-means-pp/doc/~/k_means)\n+ [k_means_pp](https://jsr.io/@ppz/k-means-pp/doc/~/k_means_pp)\n+ [types](https://jsr.io/@ppz/k-means-pp/doc)\n\n## DEV\n\n##### test\n``` bash\ndeno test\n```\n\n##### build for npm\n``` bash\ndeno task npm\ncd npm\nnpm publish --access public\n```\n","readmeFilename":"readme.md"}