https://github.com/chonyy/apriori_python
🔨 Python implementation of Apriori algorithm, new and simple!
https://github.com/chonyy/apriori_python
algorithms apriori apriori-algorithm data-mining frequent-pattern-mining python
Last synced: 25 days ago
JSON representation
🔨 Python implementation of Apriori algorithm, new and simple!
- Host: GitHub
- URL: https://github.com/chonyy/apriori_python
- Owner: chonyy
- License: mit
- Created: 2020-10-25T15:02:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-22T23:29:12.000Z (over 1 year ago)
- Last Synced: 2025-09-27T05:25:07.480Z (5 months ago)
- Topics: algorithms, apriori, apriori-algorithm, data-mining, frequent-pattern-mining, python
- Language: Python
- Homepage: https://towardsdatascience.com/apriori-association-rule-mining-explanation-and-python-implementation-290b42afdfc6
- Size: 4.27 MB
- Stars: 69
- Watchers: 3
- Forks: 36
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Getting Started
### Install the Pypi package using pip
```
pip install apriori_python
```
Then use it like
```python
from apriori_python import apriori
itemSetList = [['eggs', 'bacon', 'soup'],
['eggs', 'bacon', 'apple'],
['soup', 'bacon', 'banana']]
freqItemSet, rules = apriori(itemSetList, minSup=0.5, minConf=0.5)
print(freqItemSet)
print(rules)
# [[{'beer'}, {'rice'}, 0.6666666666666666], [{'rice'}, {'beer'}, 1.0]]
# rules[0] --> rules[1], confidence = rules[2]
```
### Clone the repo
Get a copy of this repo using git clone
```
git clone https://github.com/chonyy/apriori_python.git
```
Run the program with dataset provided and **default** values for *minSupport* = 0.5 and *minConfidence* = 0.5
```
python apriori.py -f dataset.csv
```
Run program with dataset and min support and min confidence
```
python apriori.py -f ../dataset/tesco2.csv -s 0.5 -c 0.5
```
## Concepts of Apriori
* **Support:** Fraction of transactions that contain an itemset
* **Confidence:** Measures how often items in Y appear in transactions that contain X
* **Frequent itemset:** An itemset whose support is greater than or equal to a minSup threshold