{"name":"skmeans","version":"0.9.8","description":"Super fast simple k-means and k-means++ clustering for unidimiensional and multidimensional data. Works in node and browser","author":{"name":"David Gómez Matarrodona","email":"solzimer@gmail.com"},"url":"https://github.com/owner/project/issues","email":"solzimer@gmail.com","main":"dist/node/main.js","license":"MIT","repository":{"type":"git","url":"git+https://github.com/solzimer/skmeans.git"},"keywords":["math","k-means","k-means++","kmeans++","kmeans","simple","cluster","fast","unidimiensional","multidimensional"],"dependencies":{},"devDependencies":{"babel-preset-es2015":"^6.24.1","grunt":"^1.0.1","grunt-babel":"^6.0.0","grunt-browserify":"^5.0.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-uglify":"^3.0.1","load-grunt-tasks":"^3.5.2","uglify":"^0.1.5"},"gitHead":"0b512a79d90f8db1549cccb52ba6a1d67f57cdf0","bugs":{"url":"https://github.com/solzimer/skmeans/issues"},"homepage":"https://github.com/solzimer/skmeans#readme","_id":"skmeans@0.9.8","_npmVersion":"6.1.0","_nodeVersion":"10.6.0","_npmUser":{"name":"solzimer","email":"solzimer@gmail.com"},"dist":{"integrity":"sha512-GMq7S1yLAxPX8SyBTKniaSYEj76/PBwwcIisMAdbeFooaBrveJ/S4h0eYRestvFn+aqruVtJI/K7JfAuJxb2JQ==","shasum":"4b04b31f1b465df8b340d08adc6fd8610a13ae85","tarball":"http://registry-npm.ywwl.com/skmeans/download/skmeans-0.9.8.tgz","fileCount":30,"unpackedSize":91416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbSgxDCRA9TVsSAnZWagAA9XgP/2wlZKOA2MNrHE7UDQ5G\nYAF3/KehPOPUvF880erMZAwdPBH7aNjlZRhVKmju0t9T9mTjNc3DSUbrlfQv\n4JnuHZ1oWfx63wdYV0Wp76+KeenP+pNMMg4Z+5yQa80hx7HJKhNaccVHTE/R\nwxKrg7UVBE9o8EugGJbaQrZrzmoJm7yCzZYcYSJRuQ5z/+rggSV/NDBGtGWF\ndXlpHgNNiIPGhytiGQaHtfv1hLxNZcrO5LordyyKuBOLVgtq3bjw4QXP66Zr\n3XOcUM+DYalbQQKHRp2KUzSlvHcPul+9Hf014xBVCkRXtI9UGkkjks5TyYGz\ndHUZ1wZm59tSOG6JMXq6L4c2EejGgnIQ2wmxYagIEBxDCxXH+TsTaGOpRY+F\nZZK+MQu9QMwuWFe7apMv5B3NyaUZUQUcJsSZpSH8B6CwM4OsIQ/OVADzuwTa\n0sldvIgAmawh/Uxx4/alyqez4uvukkLRhDYYpKNCOd949kZYZi/kHrXxG589\n2HKEH5g57fjdGxH3hGTacTqWAx1BUSafLK8N9RHOjTFv1HaFh01T4rsWfEeZ\nUZsHwevsF7F5343WJMBy9eiSFWMOKNRKN8kGXtabUPZAzEa6CMxvqJxsg7Ht\nSC6zUnQVX1qyFGM+L0JUdcvzIvC3fqX5JJiJidE2D5sGHkLSJnfG9PXAhq4R\nmIUs\r\n=gMjs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICuCDEf/d0jNgNV9Vb9ZCb4QN4HLX+lZsiMv3lQT3qtoAiEAuxT08HWEPOkclJAhNfz8lP+eSgaRBj+3OaQwIL2PJ+8="}],"size":30806,"noattachment":false,"key":"/skmeans/-/skmeans-0.9.8.tgz"},"maintainers":[{"name":"solzimer","email":"solzimer@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/skmeans_0.9.8_1531579459209_0.711293508899806"},"_hasShrinkwrap":false,"readme":"# skmeans\r\n\r\nSuper fast simple k-means and [k-means++](https://en.wikipedia.org/wiki/K-means%2B%2B) implementation for unidimiensional and multidimensional data. Works on nodejs and browser.\r\n\r\n## Installation\r\n```\r\nnpm install skmeans\r\n```\r\n\r\n## Usage\r\n### NodeJS\r\n```javascript\r\nconst skmeans = require(\"skmeans\");\r\n\r\nvar data = [1,12,13,4,25,21,22,3,14,5,11,2,23,24,15];\r\nvar res = skmeans(data,3);\r\n```\r\n\r\n### Browser\r\n```html\r\n<!doctype html>\r\n<html>\r\n<head>\r\n\t<script src=\"skmeans.js\"></script>\r\n</head>\r\n<body>\r\n\t<script>\r\n\t\tvar data = [1,12,13,4,25,21,22,3,14,5,11,2,23,24,15];\r\n\t\tvar res = skmeans(data,3);\r\n\r\n\t\tconsole.log(res);\r\n\t</script>\r\n</body>\r\n</html>\r\n```\r\n\r\n## Results\r\n```javascript\r\n{\r\n\tit: 2,\r\n\tk: 3,\r\n\tidxs: [ 2, 0, 0, 2, 1, 1, 1, 2, 0, 2, 0, 2, 1, 1, 0 ],\r\n\tcentroids: [ 13, 23, 3 ]\r\n}\r\n```\r\n\r\n## API\r\n### skmeans(data,k,[centroids],[iterations])\r\nCalculates unidimiensional and multidimensional k-means clustering on *data*. Parameters are:\r\n* **data** Unidimiensional or multidimensional array of values to be clustered. for unidimiensional data, takes the form of a simple array *[1,2,3.....,n]*. For multidimensional data, takes a\r\nNxM array *[[1,2],[2,3]....[n,m]]*\r\n* **k** Number of clusters\r\n* **centroids** Optional. Initial centroid values. If not provided, the algorith will try to choose an apropiate ones. Alternative values can be:\r\n  * **\"kmrand\"** Cluster initialization will be random, but with extra checking, so there will no be two equal initial centroids.\r\n  * **\"kmpp\"** The algorythm will use the [k-means++](https://en.wikipedia.org/wiki/K-means%2B%2B) cluster initialization method.\r\n* **iterations** Optional. Maximum number of iterations. If not provided, it will be set to 10000.\r\n* **distance function** Optional. Custom distance function. Takes two points as arguments and returns a scalar number.\r\n\r\nThe function will return an object with the following data:\r\n* **it** The number of iterations performed until the algorithm has converged\r\n* **k** The cluster size\r\n* **centroids** The value for each centroid of the cluster\r\n* **idxs** The index to the centroid corresponding to each value of the data array\r\n* **test** Function to test new point membership\r\n\r\n## Examples\r\n```javascript\r\n// k-means with 3 clusters. Random initialization\r\nvar res = skmeans(data,3);\r\n\r\n// k-means with 3 clusters. Initial centroids provided\r\nvar res = skmeans(data,3,[1,5,9]);\r\n\r\n// k-means with 3 clusters. k-means++ cluster initialization\r\nvar res = skmeans(data,3,\"kmpp\");\r\n\r\n// k-means with 3 clusters. Random initialization. 10 max iterations\r\nvar res = skmeans(data,3,null,10);\r\n\r\n// k-means with 3 clusters. Custom distance function\r\nvar res = skmeans(data,3,null,null,(x1,x2)=>Math.abs(x1-x2));\r\n\r\n// Test new point\r\nvar res = skmeans(data,3,null,10);\r\nres.test(6);\r\n\r\n// Test new point with custom distance\r\nvar res = skmeans(data,3,null,10);\r\nres.test(6,(x1,x2)=>Math.abs(x1-x2));\r\n```\r\n","publish_time":1531579459278,"_cnpm_publish_time":1531579459278,"dist-tags":{"latest":"0.11.3"}}