extract transactionID from rules object with apriori()

272 Views Asked by At

Is there any possibility to extract the transactionID from a 'rules' object when you apply the apriori() function?. The eclat() algorithm has the function 'tidLists= TRUE', but I can´t find it in apriori()

I can extract this information with itemsetInfo() from a 'transaction' or 'tidList' object, but I need to know which transactionID was involved in the making of the rules.

I paste a sample of my code for any suggestion.

reglas <- apriori(trans,parameter = list(sup = 0.01,conf = 0.01,minlen=4),appearance = list(rhs=c("Factor_Condiciones Laborales=1")))

My data could be in a binary matrix or basket list, no problem to coerce it.

Please, let me know if you need more details. I just want to know if it is posible. Kind regards.

1

There are 1 best solutions below

1
On

The Apriori algorithm is not based on transaction ID lists and does not give you access to what transactions each rule is related to.

You have two options:

  1. Run eclat to find frequent itemsets (with tidists=TRUE) and then use ruleInduction() to create rules from the frequent itemsets. You will have to match the rules to the frequent itemsets.

  2. Mine rules with Apriori and then find for each rule the matching transactions. You can use the functions generatingItemsets() and subset().