Skip to content

pombredanne/apyori

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apyori

Apyori is a simple implementation of Apriori algorithm with Python 2.7 and 3.3 - 3.5, provided as APIs and as commandline interfaces.

image

image

Module Features

  • Consisted of only one file and depends on no other libraries, which enable you to use it portably.
  • Able to used as APIs.

Application Features

  • Supports a JSON output format.
  • Supports a TSV output format for 2-items relations.

Installation

Choose one from the following.

  • Put apyori.py into your project.
  • Run python setup.py install.

API Usage

Here is a basic example:

from apyori import apriori

transactions = [
    ['beer', 'nuts'],
    ['beer', 'cheese'],
]
results = list(apriori(transactions))

For more details, see apyori.apriori pydoc.

CLI Usage

First, prepare input data as tab-separated transactions.

  • Each item is separated with a tab.
  • Each transactions is separated with a line feed code.

Second, run the application. Input data is given as a standard input or file paths.

  • Run with python apyori.py command.
  • If installed, you can also run with apyori-run command.

For more details, use '-h' option.

Samples

Basic usage

apyori-run < data/integration_test_input_1.tsv

Use TSV output

apyori-run -f tsv < data/integration_test_input_1.tsv

Fields of output mean:

  • Base item.
  • Appended item.
  • Support.
  • Confidence.
  • Lift.

Specify the minimum support

apyori-run -s 0.5 < data/integration_test_input_1.tsv

Specify the minimum confidence

apyori-run -c 0.5 < data/integration_test_input_1.tsv

About

A simple implementation of Apriori algorithm by Python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%