{ "info": { "author": "tommyod", "author_email": "tod001@uib.no", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# Efficient-Apriori [![Build Status](https://travis-ci.com/tommyod/Efficient-Apriori.svg?branch=master)](https://travis-ci.com/tommyod/Efficient-Apriori) [![PyPI version](https://badge.fury.io/py/efficient-apriori.svg)](https://pypi.org/project/efficient-apriori/) [![Documentation Status](https://readthedocs.org/projects/efficient-apriori/badge/?version=latest)](https://efficient-apriori.readthedocs.io/en/latest/?badge=latest) [![Downloads](https://pepy.tech/badge/efficient-apriori)](https://pepy.tech/project/efficient-apriori) [![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\nAn efficient pure Python implementation of the Apriori algorithm. Works with Python 3.6+.\n\nThe apriori algorithm uncovers hidden structures in categorical data.\nThe classical example is a database containing purchases from a supermarket.\nEvery purchase has a number of items associated with it.\nWe would like to uncover association rules such as `{bread, eggs} -> {bacon}` from the data.\nThis is the goal of [association rule learning](https://en.wikipedia.org/wiki/Association_rule_learning), and the [Apriori algorithm](https://en.wikipedia.org/wiki/Apriori_algorithm) is arguably the most famous algorithm for this problem.\nThis repository contains an efficient, well-tested implementation of the apriori algorithm as descriped in the [original paper](https://www.macs.hw.ac.uk/~dwcorne/Teaching/agrawal94fast.pdf) by Agrawal et al, published in 1994.\n\n## Example\n\nHere's a minimal working example.\nNotice that in every transaction with `eggs` present, `bacon` is present too.\nTherefore, the rule `{eggs} -> {bacon}` is returned with 100 % confidence.\n\n```python\nfrom efficient_apriori import apriori\ntransactions = [('eggs', 'bacon', 'soup'),\n ('eggs', 'bacon', 'apple'),\n ('soup', 'bacon', 'banana')]\nitemsets, rules = apriori(transactions, min_support=0.5, min_confidence=1)\nprint(rules) # [{eggs} -> {bacon}, {soup} -> {bacon}]\n```\nMore examples are included below.\n\n## Installation\n\nThe software is available through GitHub, and through [PyPI](https://pypi.org/project/efficient-apriori/).\nYou may install the software using `pip`.\n\n```bash\npip install efficient-apriori\n```\n\n## Contributing\n\nYou are very welcome to scrutinize the code and make pull requests if you have suggestions and improvements.\nYour submitted code must be PEP8 compliant, and all tests must pass.\n\n## More examples\n\n### Filtering and sorting association rules\n\nIt's possible to filter and sort the returned list of association rules.\n\n```python\nfrom efficient_apriori import apriori\ntransactions = [('eggs', 'bacon', 'soup'),\n ('eggs', 'bacon', 'apple'),\n ('soup', 'bacon', 'banana')]\nitemsets, rules = apriori(transactions, min_support=0.2, min_confidence=1)\n\n# Print out every rule with 2 items on the left hand side,\n# 1 item on the right hand side, sorted by lift\nrules_rhs = filter(lambda rule: len(rule.lhs) == 2 and len(rule.rhs) == 1, rules)\nfor rule in sorted(rules_rhs, key=lambda rule: rule.lift):\n print(rule) # Prints the rule and its confidence, support, lift, ...\n```\n\n### Working with large datasets\n\nIf you have data that is too large to fit into memory, you may pass a function returning a generator instead of a list.\nThe `min_support` will most likely have to be a large value, or the algorithm will take very long before it terminates.\nIf you have massive amounts of data, this Python implementation is likely not fast enough, and you should consult more specialized implementations.\n\n```python\ndef data_generator(filename):\n \"\"\"\n Data generator, needs to return a generator to be called several times.\n \"\"\"\n def data_gen():\n with open(filename) as file:\n for line in file:\n yield tuple(k.strip() for k in line.split(',')) \n\n return data_gen\n\ntransactions = data_generator('dataset.csv')\nitemsets, rules = apriori(transactions, min_support=0.9, min_confidence=0.6)\n```\n\n\n", "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/tommyod/Efficient-Apriori", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "efficient-apriori", "package_url": "https://pypi.org/project/efficient-apriori/", "platform": "", "project_url": "https://pypi.org/project/efficient-apriori/", "project_urls": { "Homepage": "https://github.com/tommyod/Efficient-Apriori" }, "release_url": "https://pypi.org/project/efficient-apriori/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "An efficient Python implementation of the Apriori algorithm.", "version": "1.0.0" }, "last_serial": 5292424, "releases": { "0.4": [ { "comment_text": "", "digests": { "md5": "efb03e03d52965b4d7ad30c09e90fe38", "sha256": "31bf15995852f59a43156bfb0e344d51f8dd3a811171e7a97474d1c9244ab97e" }, "downloads": -1, "filename": "efficient_apriori-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "efb03e03d52965b4d7ad30c09e90fe38", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12314, "upload_time": "2018-06-18T16:16:13", "url": "https://files.pythonhosted.org/packages/65/e2/f4f424e3ce73ff1e7bf77dd1f85d89cb0b19b3589461bbeceb6b8bdb4d28/efficient_apriori-0.4.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2a2281b8c680fa0e133e4c9960a220f1", "sha256": "353e09bf44e09c382446cf19dbba73ed688c2e416e4355ed5c9eba11d9f34f3e" }, "downloads": -1, "filename": "efficient_apriori-0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "2a2281b8c680fa0e133e4c9960a220f1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12314, "upload_time": "2018-06-18T16:03:34", "url": "https://files.pythonhosted.org/packages/be/6f/75acab60a102de6bb3b9c0d27ef823fcaee90b88b3698288181f390b5217/efficient_apriori-0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b51256a5deb7cddf4ccea6432e6afc79", "sha256": "8dcd7f73ed1e8a9220d3a3443e476af487139b1e8c913342bef2559731fc2aa6" }, "downloads": -1, "filename": "efficient_apriori-0.4.tar.gz", "has_sig": false, "md5_digest": "b51256a5deb7cddf4ccea6432e6afc79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11637, "upload_time": "2018-06-18T16:03:36", "url": "https://files.pythonhosted.org/packages/7a/dc/f826e5224484df8924e21d5933e6f33e6e74fe16ad13f39a44033791b76f/efficient_apriori-0.4.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "fc92bde624c6ce5cc96a7027229e2032", "sha256": "2ce44535ff1dc9cea021b34b84ab5da256487951917c4a6683f85a13d127fd9a" }, "downloads": -1, "filename": "efficient_apriori-0.4.2-py3-none-any.whl", "has_sig": false, "md5_digest": "fc92bde624c6ce5cc96a7027229e2032", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12332, "upload_time": "2018-06-18T16:22:34", "url": "https://files.pythonhosted.org/packages/9c/27/42deae293343e559f78168c919dd951b8287d4f7747d98e85edde4ed593d/efficient_apriori-0.4.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "90fab1d736d752b8f67c465d11d34a4b", "sha256": "b11c9de2132abf20d21732bb67a7783f9c13541a28704eb25699d98c5faf6672" }, "downloads": -1, "filename": "efficient_apriori-0.4.2.tar.gz", "has_sig": false, "md5_digest": "90fab1d736d752b8f67c465d11d34a4b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11637, "upload_time": "2018-06-18T16:22:35", "url": "https://files.pythonhosted.org/packages/c3/81/3c4de681e682d923205e8170622b1847640d3cf0dfd01db9d42b9b0fd535/efficient_apriori-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "d7eb0d901d5961025e282482cb4aa834", "sha256": "2ef9d7ab32b136cb1c49a1b388a7d8237a135a1d460229efaaad04923366daf0" }, "downloads": -1, "filename": "efficient_apriori-0.4.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d7eb0d901d5961025e282482cb4aa834", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12426, "upload_time": "2018-06-20T17:37:32", "url": "https://files.pythonhosted.org/packages/0d/1a/e305972fd3edd80a7ae534c35d89f5ed437665fc1db0627f590a48ea16e8/efficient_apriori-0.4.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7beefcc0491f2756b7c3d5c72a90a4bc", "sha256": "1a281ff8ed7ea291454c2d62c9967df9ba5db028b66fa2020e6dd0b2a3b62872" }, "downloads": -1, "filename": "efficient_apriori-0.4.3.tar.gz", "has_sig": false, "md5_digest": "7beefcc0491f2756b7c3d5c72a90a4bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11695, "upload_time": "2018-06-20T17:37:34", "url": "https://files.pythonhosted.org/packages/08/a0/7ae6f52006272ac334e7a4411639915862496cc62dc4ee1254f57283b60f/efficient_apriori-0.4.3.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "56a7483c54d290e8bd825c240f6a0217", "sha256": "ee8ba0692c312d33cf3b2c9a62ae3f0f985b0c27ac0bf2fac218330e91755e5b" }, "downloads": -1, "filename": "efficient_apriori-0.4.4-py3-none-any.whl", "has_sig": false, "md5_digest": "56a7483c54d290e8bd825c240f6a0217", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12481, "upload_time": "2018-06-20T18:27:33", "url": "https://files.pythonhosted.org/packages/fc/64/2768b3c9550dbcd504c03161ca77b71301c51b436e27f9a1bd9599303ba9/efficient_apriori-0.4.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "75d9a4737ed4dcd493032f5754c125ee", "sha256": "08197a94772e691c2effe9e84d7af3c625b1eb4221e8ab2fcddbfccf18e7cf2e" }, "downloads": -1, "filename": "efficient_apriori-0.4.4.tar.gz", "has_sig": false, "md5_digest": "75d9a4737ed4dcd493032f5754c125ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11758, "upload_time": "2018-06-20T18:27:35", "url": "https://files.pythonhosted.org/packages/f0/3e/3687858b2fe45aa090b5ec4e095556303f4fab4dfe263b690a094ec513ef/efficient_apriori-0.4.4.tar.gz" } ], "0.4.5": [ { "comment_text": "", "digests": { "md5": "b4c257bcb8463aa356e7ae96637318a9", "sha256": "b3c5b77d16a58c5d4fb8b2c8721b5c7a3067894304b27a38a6f442caa19e5841" }, "downloads": -1, "filename": "efficient_apriori-0.4.5-py3-none-any.whl", "has_sig": false, "md5_digest": "b4c257bcb8463aa356e7ae96637318a9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13459, "upload_time": "2018-11-04T16:35:43", "url": "https://files.pythonhosted.org/packages/13/ab/a8def875902610558395242a147b8490372f031561902c534ebbf5db14ca/efficient_apriori-0.4.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6f0eb6bbb2b02786a3fec303dd97a0c7", "sha256": "142f7f824d564d40799798461f552ab87f957c7b70be2b225fc0b001b89c3ca8" }, "downloads": -1, "filename": "efficient_apriori-0.4.5.tar.gz", "has_sig": false, "md5_digest": "6f0eb6bbb2b02786a3fec303dd97a0c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11914, "upload_time": "2018-11-04T16:35:45", "url": "https://files.pythonhosted.org/packages/d2/7b/71c12582b2e1b561e76cf52239bcece4ced6aac9c93974b7fdede5f407e7/efficient_apriori-0.4.5.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "ada9cf17326e6fdd0e6104b0e019c0cc", "sha256": "bc987a3fc08fd6eb749504aa2f5bffb2266a9e76b53f9a821d2bf5b4978f65e2" }, "downloads": -1, "filename": "efficient_apriori-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ada9cf17326e6fdd0e6104b0e019c0cc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13640, "upload_time": "2019-05-20T13:40:46", "url": "https://files.pythonhosted.org/packages/5b/cb/cd06eb983e4a67d9b127df6e3ece87dd7ebea145daa4250929531315bbff/efficient_apriori-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4acb4c89bb15213740d7b4398b73d3b9", "sha256": "d25de60bd7c2540515da83838ec9446e97d88bb8e6d78ade9baa7db7e99b8d64" }, "downloads": -1, "filename": "efficient_apriori-1.0.0.tar.gz", "has_sig": false, "md5_digest": "4acb4c89bb15213740d7b4398b73d3b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13712, "upload_time": "2019-05-20T13:40:47", "url": "https://files.pythonhosted.org/packages/a1/fe/938543de87aca9ac8f681a4fc940e604d1010cf7936f6014bdca1924a166/efficient_apriori-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ada9cf17326e6fdd0e6104b0e019c0cc", "sha256": "bc987a3fc08fd6eb749504aa2f5bffb2266a9e76b53f9a821d2bf5b4978f65e2" }, "downloads": -1, "filename": "efficient_apriori-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ada9cf17326e6fdd0e6104b0e019c0cc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13640, "upload_time": "2019-05-20T13:40:46", "url": "https://files.pythonhosted.org/packages/5b/cb/cd06eb983e4a67d9b127df6e3ece87dd7ebea145daa4250929531315bbff/efficient_apriori-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4acb4c89bb15213740d7b4398b73d3b9", "sha256": "d25de60bd7c2540515da83838ec9446e97d88bb8e6d78ade9baa7db7e99b8d64" }, "downloads": -1, "filename": "efficient_apriori-1.0.0.tar.gz", "has_sig": false, "md5_digest": "4acb4c89bb15213740d7b4398b73d3b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13712, "upload_time": "2019-05-20T13:40:47", "url": "https://files.pythonhosted.org/packages/a1/fe/938543de87aca9ac8f681a4fc940e604d1010cf7936f6014bdca1924a166/efficient_apriori-1.0.0.tar.gz" } ] }