Skip to main content

A Python library that implements smooth and easy apriori for association rule mining. Currently limited for maximum 4 items/transaction.

Project description

apriorib

apriorib is a Python library that applies the very famous unsupervised learning algorithm, apriori, for Association Rule Mining(ARM) on a dataset of transaction/purchase logs and shows the accepted association rules.

Currently, this version is limited to a maximum of 4 items in a certain transaction.

Demo

New in this version

  1. Displays stage-wise final itemset as pandas DataFrames.

Demo 2

Installation

Use the package manager pip to install apriorib.

pip install apriorib

Quick Start

from apriorib.apriorib import Apriori

data = [['MILK', 'BREAD', 'BISCUIT'],
    ['BREAD', 'MILK', 'BISCUIT', 'CORNFLAKES'],
    ['BREAD', 'TEA', 'BOURNVITA'],
    ['JAM', 'MAGGI', 'BREAD', 'MILK'],
    ['MAGGI', 'TEA', 'BISCUIT'],
    ['BREAD', 'TEA', 'BOURNVITA'],
    ['MAGGI', 'TEA', 'CORNFLAKES'],
    ['MAGGI', 'BREAD', 'TEA', 'BISCUIT'],
    ['JAM', 'MAGGI', 'BREAD', 'TEA'],
    ['BREAD', 'MILK'],
    ['COFFEE', 'COCK', 'BISCUIT', 'CORNFLAKES'],
    ['COFFEE', 'COCK', 'BISCUIT', 'CORNFLAKES'],
    ['COFFEE', 'SUGER', 'BOURNVITA'],
    ['BREAD', 'COFFEE', 'COCK'],
    ['BREAD', 'SUGER', 'BISCUIT'],
    ['COFFEE', 'SUGER', 'CORNFLAKES'],
    ['BREAD', 'SUGER', 'BOURNVITA'],
    ['BREAD', 'COFFEE', 'SUGER'],
    ['BREAD', 'COFFEE', 'SUGER'],
    ['TEA', 'MILK', 'COFFEE', 'CORNFLAKES']]

# Testing the Apriori class
apr = Apriori(records=data,min_sup=2,min_conf=50)
df1,df2,df3,df4 = apr.show_as_df(stage=1),apr.show_as_df(stage=2),apr.show_as_df(stage=3),apr.show_as_df(stage=4)
print("VIEWING THE ITEMSET DATAFRAMES AT THE DIFFERENT STAGES :\nSTAGE 1\n{}\nSTAGE 2\n{}\nSTAGE 3\n{}\nSTAGE 4\n{}".format(df1,df2,df3,df4))
apr.checkAssc()

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apriorib-1.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

apriorib-1.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file apriorib-1.0.1.tar.gz.

File metadata

  • Download URL: apriorib-1.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for apriorib-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0e6dd2a8abe219289a00c299c36e03db1ee28339d75df088f1cc29402f619646
MD5 ba377629cb5de808f4e183d82da060a8
BLAKE2b-256 9f12749015e858c39f24dfe900b595d52b27f8c38d02629a3414225b632e3747

See more details on using hashes here.

File details

Details for the file apriorib-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: apriorib-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for apriorib-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 548e819887168b57f99f67ff3f2dd3bfb67a90ad1a0bf6ce7b7f8ed5ae49d1a3
MD5 80f25a4ac256f942c2da738cb1696c03
BLAKE2b-256 8a358eeb57f534b0ea611258764da3c7d414a1f98eb24ce99f96850566635aa7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page