Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Data Science by (17.6k points)
edited by

Excuse me for my english, I'm trying to recognize properties that come up frequently in a set of data to deduce a categorization using the apyori package of python. i'm practicing on a dataframe of 20772 transactions and the largest transaction is 543 items.


I converted this DataFrame into a list :

liste = df.astype(str).values.tolist()

I got this list


I used the apriori function of the library apyori to generate the association rules:

from apyori import apriori

rules = apriori(liste, min_support= 0.01, min_confidence= 0.2)

to display the result I converted the rules variable to a list :

MB = list(rules)

The problem is that instead of showing me the rules but it shows the RelationRecord "RelationRecord object of apyori module".

like here


1 Answer

0 votes
by (41.4k points)

Convert RelationRecord to list for getting list of rules from RelationRecord:

listRules = [list(MB[i][0]) for i in range(0,len(MB))]

If you wish to Learn more about Python visit this Python Online Training.

Browse Categories