{ "info": { "author": "source{d}", "author_email": "machine-learning@sourced.tech", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": "# seriate\nOptimal ordering of elements in a set given their distance matrix.\n\n[![Travis build status](https://travis-ci.com/src-d/seriate.svg?branch=master)](https://travis-ci.com/src-d/seriate)\n[![Code coverage](https://codecov.io/github/src-d/seriate/coverage.svg)](https://codecov.io/github/src-d/seriate)\n[![PyPi package status](https://img.shields.io/pypi/v/seriate.svg)](https://pypi.python.org/pypi/seriate)\n![stability: stable](https://svg-badge.appspot.com/badge/stability/stable?color=007ec6)\n[![Apache 2.0 license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n![example](doc/example.png)\n\n[Overview](#overview) \u2022 [How To Use](#how-to-use) \u2022 [Contributions](#contributions) \u2022 [License](#license)\n\n## Overview\n\nThis is a Python implementation of [Seriation](http://nicolas.kruchten.com/content/2018/02/seriation/)\nalgorithm. Seriation is an approach for ordering elements in a set so that the\nsum of the sequential pairwise distances is minimal. We state this task\nas a Travelling Salesman Problem (TSP) and leverage the powerful [Google's or-tools](https://github.com/google/or-tools)\nto do heavy-lifting. Since TSP is NP-hard, it is not possible to calculate\nthe precise solution for a big number of elements. However, the or-tools'\nheuristics work very well in practice, and they are used in e.g. Google Maps.\n\nAny [`numpy.roll`-ed](https://docs.scipy.org/doc/numpy-1.16.0/reference/generated/numpy.roll.html)\nresult is equivalent.\n\n## How To Use\n\n```python\nimport numpy\nfrom scipy.spatial.distance import pdist\nfrom seriate import seriate\n\nelements = numpy.array([\n [3, 3, 3],\n [5, 5, 5],\n [4, 4, 4],\n [2, 2, 2],\n [1, 1, 1]\n])\n\nprint(seriate(pdist(elements)))\n\n# Output: [4, 3, 0, 2, 1]\n```\n\nThe example above shows how we order 5 elements: `[3, 3, 3]`,\n`[5, 5, 5]`, `[4, 4, 4]`, `[2, 2, 2]` and `[1, 1, 1]`. The result\nis expected:\n\n1. `[1, 1, 1]` \n2. `[2, 2, 2]` \n3. `[3, 3, 3]` \n4. `[4, 4, 4]` \n5. `[5, 5, 5]`\n\n`pdist` from [`scipy.spatial.distance`](https://docs.scipy.org/doc/scipy/reference/spatial.distance.html)\nuses Euclidean (L2) dstance metric by default, so the distance between\n`[x, x, x]` and `[x + 1, x + 1, x + 1]` is constant: \u221a3. Any other distance\nis bigger, so the optimal ordering is to list our elements in the increasing\nnorm order.\n\n## Contributions\n\nContributions are very welcome and desired! Please follow the [code of conduct](doc/code_of_conduct.md)\nand read the [contribution guidelines](doc/contributing.md).\n\n## License\n\nApache-2.0, see [LICENSE.md](LICENSE.md).\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/src-d/seriate", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/src-d/seriate", "keywords": "seriation", "license": "Apache-2.0", "maintainer": "", "maintainer_email": "", "name": "seriate", "package_url": "https://pypi.org/project/seriate/", "platform": "", "project_url": "https://pypi.org/project/seriate/", "project_urls": { "Download": "https://github.com/src-d/seriate", "Homepage": "https://github.com/src-d/seriate" }, "release_url": "https://pypi.org/project/seriate/1.1.1/", "requires_dist": [ "numpy (>=1.0)", "ortools (<8,>=6.7.4973)", "packaging (>=16.0)" ], "requires_python": "", "summary": "Implementation of the Seriation sequence ordering algorithm.", "version": "1.1.1" }, "last_serial": 5971621, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "e272bc7a165e56760dc9791e30d30809", "sha256": "53260de229c8a381db12b20dcb1eed5f6529a33c0b8c0bd6ec336b2c940be935" }, "downloads": -1, "filename": "seriate-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e272bc7a165e56760dc9791e30d30809", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7760, "upload_time": "2019-03-22T16:32:20", "url": "https://files.pythonhosted.org/packages/92/cf/daa128c0df2d021620599ccd4d83d98983b1c616e25bfbf9f113c12cee62/seriate-1.0.0-py3-none-any.whl" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "ced6dba237df1f4a7ccaf5c509497c45", "sha256": "f6b1ed795a38a9679c70c3b5e38ea657c49d451e6a066c43da505eae156ea84a" }, "downloads": -1, "filename": "seriate-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ced6dba237df1f4a7ccaf5c509497c45", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7960, "upload_time": "2019-03-29T10:43:03", "url": "https://files.pythonhosted.org/packages/39/23/6d80c46ac228ccf781c4bce160a715839c0bfb5f54dbb683eced2795beca/seriate-1.0.1-py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "3bf75715802cdc224dae64f3b8d6db96", "sha256": "41a9bd8ce24861175020d9a75a5e173c6c0267047d0539d7b391a07697282305" }, "downloads": -1, "filename": "seriate-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3bf75715802cdc224dae64f3b8d6db96", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8410, "upload_time": "2019-09-24T20:28:20", "url": "https://files.pythonhosted.org/packages/f5/26/e52be1d4166a28ecaf806a2b1a8b2b75a9dcf7bb4eba1c6ee6577d6d4721/seriate-1.1.0-py3-none-any.whl" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "9f86b316d6d1b6eab9fd59f82beb02fa", "sha256": "430687475eebbd12cd9676c6dd9c6981374fb25fd52189f3fb6e4fd73afa7afd" }, "downloads": -1, "filename": "seriate-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "9f86b316d6d1b6eab9fd59f82beb02fa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8548, "upload_time": "2019-10-14T13:39:29", "url": "https://files.pythonhosted.org/packages/03/a7/07ccfc3a4ecbd338962b1b5b9e35d69d89c7ca94d8a31a6889dd758730df/seriate-1.1.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9f86b316d6d1b6eab9fd59f82beb02fa", "sha256": "430687475eebbd12cd9676c6dd9c6981374fb25fd52189f3fb6e4fd73afa7afd" }, "downloads": -1, "filename": "seriate-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "9f86b316d6d1b6eab9fd59f82beb02fa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8548, "upload_time": "2019-10-14T13:39:29", "url": "https://files.pythonhosted.org/packages/03/a7/07ccfc3a4ecbd338962b1b5b9e35d69d89c7ca94d8a31a6889dd758730df/seriate-1.1.1-py3-none-any.whl" } ] }