Git Product home page Git Product logo

chonyy / apriori_python Goto Github PK

View Code? Open in Web Editor NEW
59.0 4.0 33.0 4.37 MB

๐Ÿ”จ Python implementation of Apriori algorithm, new and simple!

Home Page: https://towardsdatascience.com/apriori-association-rule-mining-explanation-and-python-implementation-290b42afdfc6

License: MIT License

Python 100.00%
data-mining algorithms frequent-pattern-mining apriori apriori-algorithm python

apriori_python's Introduction

apriori_python's People

Contributors

chonyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

apriori_python's Issues

how to I infer "rules[0] --> rules[1], confidence = rules[2]" from the rules

First of all, thank you so much for this. This is comparatively computationally faster than the other implementations of Apirori I found on GitHub.

In the README, you have mentioned this sort of pattern

rules[0] --> rules[1], confidence = rules[2]

How do I infer this from the rules set?

Following are the first 3 rules generated from my run of apriori_python on a toy dataset:
[{'Apple'}, {'Orange'}, 0.5008052439747973] #rules[0]
[{'Grapes', 'Orange'}, {'Apple', 'Banana'}, 0.5056131260794473] #rules[1]
[{'Banana', 'Kiwi'}, {'Apple'}, 0.5072046109510087] #rules[2]

Also, what exactly is meant by rules[0] --> rules[1], confidence = rules[2] ?
Does it mean that when rules[0] is the antecedent then rules[1] is the consequent with a confidence mentioned against rules[1] that together forms the rules[2]?

Sorry for so many dumb questions, I'm still new to ARM modelling.

running command error

Hello, I am a newcomer learning python and data science, I don't know if this question is relatively simple and stupid, but I found that the running command of this code is incorrect.

โžœ  apriori_python git:(master) โœ— ls                               
__init__.py apriori.py  utils.py
โžœ  apriori_python git:(master) โœ— python3 apriori.py -f dataset.csv
Traceback (most recent call last):
  File "/Users/juanitahowe/Documents/GitHub/apriori_python/apriori_python/apriori.py", line 87, in <module>
    freqItemSet, rules = aprioriFromFile(options.inputFile, options.minSup, options.minConf)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juanitahowe/Documents/GitHub/apriori_python/apriori_python/apriori.py", line 38, in aprioriFromFile
    C1ItemSet, itemSetList = getFromFile(fname)
                             ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/apriori_python/utils.py", line 32, in getFromFile
    with open(fname, 'r') as file:
         ^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'dataset.csv'
โžœ  apriori_python git:(master) โœ— python3 apriori.py -f tesco2.csv -s 0.5 -c 0.5
Traceback (most recent call last):
  File "/Users/juanitahowe/Documents/GitHub/apriori_python/apriori_python/apriori.py", line 87, in <module>
    freqItemSet, rules = aprioriFromFile(options.inputFile, options.minSup, options.minConf)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/juanitahowe/Documents/GitHub/apriori_python/apriori_python/apriori.py", line 38, in aprioriFromFile
    C1ItemSet, itemSetList = getFromFile(fname)
                             ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/apriori_python/utils.py", line 32, in getFromFile
    with open(fname, 'r') as file:
         ^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'tesco2.csv'

To run program with specific dataset, I think this is the correct command

โžœ  apriori_python git:(master) โœ— python3 apriori.py -f ../dataset/tesco2.csv -s 0.5 -c 0.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.