{ "info": { "author": "Daniel Steinberg", "author_email": "ds@dannyadam.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Operating System :: Unix", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Information Analysis" ], "description": "kmeans1d\n========\n\nA Python library with an implementation of *k*-means clustering on 1D data, based on the algorithm\nin (Xiaolin 1991), as presented in section 2.2 of (Gronlund et al., 2017).\n\nGlobally optimal *k*-means clustering is NP-hard for multi-dimensional data. LLoyd's algorithm is a\npopular approach for finding a locally optimal solution. For 1-dimensional data, there are polynomial time\nalgorithms. The algorithm implemented here is a *O(kn + n log n)* dynamic programming algorithm for finding\nthe globally optimal *k* clusters for *n* 1D data points.\n\nThe code is written in C++, and wrapped with Python.\n\nRequirements\n------------\n\n*kmeans1d* supports Python 3.x.\n\nInstallation\n------------\n\n[kmeans1d](https://pypi.python.org/pypi/kmeans1d) is available on PyPI, the Python Package Index.\n\n```sh\n$ pip3 install kmeans1d\n```\n\nExample Usage\n-------------\n\n```python\nimport kmeans1d\n\nx = [4.0, 4.1, 4.2, -50, 200.2, 200.4, 200.9, 80, 100, 102]\nk = 4\n\nclusters, centroids = kmeans1d.cluster(x, k)\n\nprint(clusters) # [1, 1, 1, 0, 3, 3, 3, 2, 2, 2]\nprint(centroids) # [-50.0, 4.1, 94.0, 200.5]\n\n```\n\nLicense\n-------\n\nThe code in this repository has an [MIT License](https://en.wikipedia.org/wiki/MIT_License).\n\nSee [LICENSE](https://github.com/dstein64/kmeans1d/blob/master/LICENSE).\n\nReferences\n----------\n\n[1] Wu, Xiaolin. \"Optimal Quantization by Matrix Searching.\" Journal of Algorithms 12, no. 4\n(December 1, 1991): 663\n\n[2] Gronlund, Allan, Kasper Green Larsen, Alexander Mathiasen, Jesper Sindahl Nielsen, Stefan Schneider,\nand Mingzhou Song. \"Fast Exact K-Means, k-Medians and Bregman Divergence Clustering in 1D.\"\nArXiv:1701.07204 [Cs], January 25, 2017. http://arxiv.org/abs/1701.07204.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dstein64/kmeans1d", "keywords": "k-means,machine learning,optimization", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "kmeans1d", "package_url": "https://pypi.org/project/kmeans1d/", "platform": "", "project_url": "https://pypi.org/project/kmeans1d/", "project_urls": { "Homepage": "https://github.com/dstein64/kmeans1d" }, "release_url": "https://pypi.org/project/kmeans1d/0.2.0/", "requires_dist": null, "requires_python": ">=3.6", "summary": "A Python package for optimal 1D k-means clustering", "version": "0.2.0" }, "last_serial": 5504669, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "c8179906d1e099183b36ac77d438dafa", "sha256": "34a4b8fdd30a696f048f3dc991e47d815967526529a78f870c5b1528ee1cf0a0" }, "downloads": -1, "filename": "kmeans1d-0.0.3.tar.gz", "has_sig": false, "md5_digest": "c8179906d1e099183b36ac77d438dafa", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5047, "upload_time": "2019-07-04T04:45:01", "url": "https://files.pythonhosted.org/packages/dd/ee/a134ecb0d0d90cfbe36e92e78f65dd9f9613304593cd9647ad4345f4b0f4/kmeans1d-0.0.3.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "7fe69ed8b585acb27bed692ed1c268d9", "sha256": "e3137881fc159a60d3880ea785c4462650db5c18aa840a64be87dc307f0093f3" }, "downloads": -1, "filename": "kmeans1d-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7fe69ed8b585acb27bed692ed1c268d9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5373, "upload_time": "2019-07-05T04:44:15", "url": "https://files.pythonhosted.org/packages/da/b1/1a7cb25494dddefbe58ca8a434fac56f4909bc2e048fcaeef318a8172c62/kmeans1d-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "d0bffc3c2f1a1d486f62c17207045910", "sha256": "bed2bc9f0aabcaf2ad8f6c0cfc45c4d921ff48fe8cd9811bb63d6eb8d2a673a4" }, "downloads": -1, "filename": "kmeans1d-0.2.0.tar.gz", "has_sig": false, "md5_digest": "d0bffc3c2f1a1d486f62c17207045910", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5408, "upload_time": "2019-07-09T04:37:34", "url": "https://files.pythonhosted.org/packages/5d/60/2c6e5c7bc3be3bc81458248d78aba650414b55a1141e273201246c0b00ee/kmeans1d-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d0bffc3c2f1a1d486f62c17207045910", "sha256": "bed2bc9f0aabcaf2ad8f6c0cfc45c4d921ff48fe8cd9811bb63d6eb8d2a673a4" }, "downloads": -1, "filename": "kmeans1d-0.2.0.tar.gz", "has_sig": false, "md5_digest": "d0bffc3c2f1a1d486f62c17207045910", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5408, "upload_time": "2019-07-09T04:37:34", "url": "https://files.pythonhosted.org/packages/5d/60/2c6e5c7bc3be3bc81458248d78aba650414b55a1141e273201246c0b00ee/kmeans1d-0.2.0.tar.gz" } ] }