Giter Site home page Giter Site logo

jeffrichardchemistry / pyeclat Goto Github PK

View Code? Open in Web Editor NEW
25.0 3.0 6.0 62 KB

A package for association analysis using the ECLAT method.

License: BSD 2-Clause "Simplified" License

Python 100.00%
artificial-intelligence statistics python eclat-algorithm

pyeclat's Introduction

DOI PyPI version PyPI Downloads

pyECLAT

Unlike the a priori method, the ECLAT method is not based on the calculation of confidence and lift, therefore the ECLAT method is based on the calculation of the support conjunctions of the variables.

pyECLAT is a simple package for associating variables based on the support of the different items of a dataframe.This method returns two dictionaries, one with the frequency of occurrence of the items conjunctions and the other with the support of the items conjunctions.

Install

Via pip

pip3 install pyECLAT

Via github

git clone https://github.com/jeffrichardchemistry/pyECLAT
cd pyECLAT
python3 setup.py install

Dependencies

numpy>=1.17.4, pandas>=0.25.3, tqdm>=4.41.1

How to use

This package has two dataframes as example, its possible to use:

from pyECLAT import Example1, Example2
ex1 = Example1().get()
ex2 = Example2().get()

The working dataframe should look like the one below. In this case, each line represents a customer's purchase at a supermarket.

0 1 2 3
0 milk beer bread butter
1 coffe bread butter NaN
2 coffe bread butter NaN
3 milk coffe bread butter
4 beer NaN NaN NaN
5 butter NaN NaN NaN
6 bread NaN NaN NaN
7 bean NaN NaN NaN
8 rice bean NaN NaN
9 rice NaN NaN NaN

This package works directly with a pandas dataframe without column's name. Example: Making your dataframe

import pandas as pd
dataframe = pd.read_csv('dir/of/file.csv', header=None)  

Run ECLAT method:

from pyECLAT import ECLAT
eclat_instance = ECLAT(data=dataframe, verbose=True) #verbose=True to see the loading bar

After getting eclat_instance, a binary dataframe is automatically generated, among other resources that can be accessed:

eclat_instance.df_bin   #generate a binary dataframe, that can be used for other analyzes.
eclat_instance.uniq_    #a list with all the names of the different items

eclat_instance.support, eclat_instance.fit and eclat_instance.fit_all are the functions to perform the calculations. Example:

get_ECLAT_indexes, get_ECLAT_supports = eclat_instance.fit(min_support=0.08,
                                                           min_combination=1,
                                                           max_combination=3,
                                                           separator=' & ',
                                                           verbose=True)

It is possible to access the documentation, as well as the description, of each method using:

help(eclat_instance.fit)
help(eclat_instance.fit_all)
help(eclat_instance.support)

pyeclat's People

Contributors

jeffrichardchemistry 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

Watchers

 avatar  avatar  avatar

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.