{"id":24667423,"url":"https://github.com/emagtechlabs/go-apriori","last_synced_at":"2025-10-08T04:31:15.135Z","repository":{"id":91444471,"uuid":"201243370","full_name":"eMAGTechLabs/go-apriori","owner":"eMAGTechLabs","description":"Go-Apriori is a simple go implementation of the Apriori algorithm.","archived":false,"fork":false,"pushed_at":"2022-10-31T21:52:49.000Z","size":20,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-06-20T01:52:01.424Z","etag":null,"topics":["apriori","apriori-algorithm","go","golang"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/eMAGTechLabs/go-apriori","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMAGTechLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-08T11:23:13.000Z","updated_at":"2024-03-09T07:03:04.000Z","dependencies_parsed_at":"2024-06-20T01:26:46.760Z","dependency_job_id":"312ce2eb-2a3f-4ebc-a708-9dca2f8bd908","html_url":"https://github.com/eMAGTechLabs/go-apriori","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMAGTechLabs%2Fgo-apriori","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMAGTechLabs%2Fgo-apriori/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMAGTechLabs%2Fgo-apriori/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMAGTechLabs%2Fgo-apriori/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMAGTechLabs","download_url":"https://codeload.github.com/eMAGTechLabs/go-apriori/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235679171,"owners_count":19028323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apriori","apriori-algorithm","go","golang"],"created_at":"2025-01-26T08:17:05.003Z","updated_at":"2025-10-08T04:31:09.822Z","avatar_url":"https://github.com/eMAGTechLabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go-Apriori\nGo-Apriori is a simple go implementation of the Apriori algorithm for finding frequent sets and association rules \n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/eMAGTechLabs/go-apriori)](https://pkg.go.dev/github.com/eMAGTechLabs/go-apriori)\n[![Build Status](https://travis-ci.com/eMAGTechLabs/go-apriori.svg?branch=master)](https://travis-ci.com/eMAGTechLabs/go-apriori)\n[![](http://gocover.io/_badge/github.com/eMAGTechLabs/go-apriori)](github.com/eMAGTechLabs/go-apriori)\n[![Go Report Card](https://goreportcard.com/badge/github.com/eMAGTechLabs/go-apriori)](https://goreportcard.com/report/github.com/eMAGTechLabs/go-apriori)\n\n## Short Apriori Algorithm description \nApriori is a classic algorithm for learning association rules. Apriori is designed to operate on databases / data sets \ncontaining transactions (for example, collections of items bought by customers)\n\nThe algorithm extracts useful information from large amounts of data. For example, the information that a customer who \npurchases 'butter' also tends to buy 'jam' at the same time is acquired from the association rule below:\n- Support: The percentage of task-relevant data transactions for which the pattern is true. \n```\nSupport (Butter-\u003eJam) = ( No of transactions containing both 'butter' and 'jam' ) / ( Total no of transactions )\n```\n- Confidence: The measure of certainty or trustworthiness associated with each discovered pattern.\n```\nConfidence (Butter-\u003eJam) = ( No of transactions containing both 'butter' and 'jam' ) / ( No of transactions containing 'butter' )\n```\n- Lift: This measure of how likely item 'jam' is purchased when item 'butter' is purchased, while controlling for how \npopular item 'butter' is\n```.\nLift (Butter-\u003eJam) =  ( No of transactions containing both 'butter' and 'jam' ) / ( No of transactions containing 'butter' ) * ( No of transactions containing 'jam' )\n```\n\nThe algorithm aims to find the rules which satisfy both a minimum support threshold and a minimum confidence threshold.\n- Item: article in the basket.\n- Itemset: a group of items purchased together in a single transaction.\n\n### How it works\n- Find all frequent itemsets:\n    - Get frequent items:\n        - Items whose occurrence is greater than or equal to the minimum support threshold.\n    - Get frequent itemsets:\n        - Generate candidates from frequent items.\n        - Prune the results to find the frequent itemsets.\n- Generate association rules from frequent itemsets:\n    - Rules which satisfy the minimum support, minimum confidence and minimum lift thresholds.\n\n## Usage\n\n### How to get\n```\ngo get github.com/eMAGTechLabs/go-apriori\n```\n\n### Options\n```go\ntype Options struct {\n    minSupport    float64 // The minimum support of relations (float).\n    minConfidence float64 // The minimum confidence of relations (float).\n    minLift       float64 // The minimum lift of relations (float).\n    maxLength     int     // The maximum length of the relation (integer).\n}\n```\n**Note:** If maxLength is set to 0, no max length will be taken into consideration\n\n### How to use\n```go\nimport \"github.com/eMAGTechLabs/go-apriori\"\n\ntransactions := [][]string{\n    {\"beer\", \"nuts\", \"cheese\"},\n    {\"beer\", \"nuts\", \"jam\"},\n    {\"beer\", \"butter\"},\n    {\"nuts\", \"cheese\"},\n    {\"beer\", \"nuts\", \"cheese\", \"jam\"},\n    {\"butter\"},\n    {\"beer\", \"nuts\", \"jam\", \"butter\"},\n    {\"jam\"},\n}\napriori := NewApriori(transactions)\nresults := apriori.Calculate(NewOptions(0.1, 0.5, 0.0, 0))\n```\n\n### Sample Output\n```\n[\n...\n    {\n        supportRecord: {items: [beer cheese jam nuts] support:0.125 } \n        orderedStatistic: [\n            { base: [beer cheese jam] add: [nuts] confidence: 1 lift: 1.6 }\n            { base: [beer cheese nuts] add: [jam] confidence: 0.5 lift: 1 }\n            { base: [cheese jam nuts] add: [beer] confidence: 1 lift: 1.6 }\n        ]\n    }\n...\n]\n```\n\n## Inspiration\n- [Association Rules and the Apriori Algorithm](https://www.kdnuggets.com/2016/04/association-rules-apriori-algorithm-tutorial.html)\n- [Apyori](https://github.com/ymoch/apyori) - Apriori python implementation\n- [Apriori-Algorithm](https://github.com/Omar-Salem/Apriori-Algorithm) - Apriori C# implementation\n\n## Contributing\nThanks for your interest in contributing! There are many ways to contribute to this project. Get started [here](CONTRIBUTING.md).\n\n#### Tags\n\n\\#apriori-algorithm \\#go ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femagtechlabs%2Fgo-apriori","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femagtechlabs%2Fgo-apriori","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femagtechlabs%2Fgo-apriori/lists"}