No account yet ?
The ECLAT algorithm stands for "Equivalence Class Clustering and bottom-up Lattice Traversal".
This is one of the popular methods for extracting association rules.
It is a more efficient and scalable version of the Apriori algorithm.
Tested in Anaconda and Python 3.7
# Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Data Preprocessing dataset = pd.read_csv('Market_Basket_Optimisation.csv', header = None) transactions = [] for i in range(0, 7501): transactions.append([str(dataset.values[i,j]) for j in range(0, 20)]) # Training the Eclat model on the dataset from apyori import apriori rules = apriori(transactions = transactions, min_support = 0.003, min_confidence = 0.2, min_lift = 3, min_length = 2, max_length = 2) # Visualising the results results = list(rules) print(results) # Putting the results well organised into a Pandas DataFrame def inspect(results): lhs = [tuple(result[2][0][0])[0] for result in results] rhs = [tuple(result[2][0][1])[0] for result in results] supports = [result[1] for result in results] return list(zip(lhs, rhs, supports)) resultsinDataFrame = pd.DataFrame(inspect(results), columns = ['Product1', 'Product2', 'Support']) resultsinDataFrame.nlargest(n = 10, columns = 'Support') print(resultsinDataFrame)
ECLAT-algorithm - GitHub
Result
| Product1 | Product2 | Support | ||||
| 0 | light cream | chicken | 0.004533 | |||
| 1 | mushroom cream sauce | escalope | 0.005733 | |||
| 2 | pasta | escalope | 0.005866 | |||
| 3 | fromage blanc | honey | 0.003333 | |||
| 4 | herb & pepper | ground beef | 0.015998 | |||
| 5 | tomato sauce | ground beef | 0.005333 | |||
| 6 | light cream | olive oil | 0.003200 | |||
| 7 | whole wheat pasta | olive oil | 0.007999 | |||
| 8 | pasta | shrimp | 0.005066 |
Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !
Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License