Machine Learning : Association Rule- Eclat (Part 22)

Previously we saw this example in priori

for folks who watched movie 1 also watched 2 and etc...

here, we just have support vector

Here M or l is a set of 2 movie or food item.

using this, we can understand the relation.

Steps:

So, if you have gone through apiori, this coding will be mostly the same.

the difference is we have set of products to get support

Check Apiori blog

Problem statement:

We are looking for products which a customer buys one with another. So that, we can offer buy 1 get 1 with increased price of one

so, importing and date pre-processing will be same

Training the model & visualizing the result is exactly the same

Putting the results well organised into a Pandas DataFrame

Here we remove the confidence and lift as these are missing in eclat

Note: We did use those in training as we used the apriori function

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 = ['Product 1', 'Product 2', 'Support'])

we can now see the table in a order descending supports

That's it!

So, if a person buys herb & paper , he has a very high chance to buy ground beef.

Code this from the repository