0

I am using fpgrowth module from Orange3-Associate to find the rules from transactions in a file. I am using this script:

from orangecontrib.associate.fpgrowth import *

transactions = [[1, 2, 5],
                [2, 4],
                [2, 3],
                [1, 2, 4],
                [1, 3],
                [2, 3],
                [1, 3],
                [1, 2, 3, 5],
                [1, 2, 3]]

itemsets = dict(frequent_itemsets(transactions, .2))
rules = [(list(P), list(Q), supp, conf) for P, Q, supp, conf in association_rules(itemsets, .5)]

However, when I print(rules), Consequent Q shows as list of 2 or more items. Output:

[3, 5], [1, 2], 1, 1.0

Why is this occurring? Isn't the Consequent supposed to be only 1 item?

Snow
  • 1,058
  • 2
  • 19
  • 47

1 Answers1

1

No, the consequent is not restricted to a single item.

If all your transactions contain A, B, then the rule emptyset -> A, B is the desired output to indicate that "no matter what the transaction contains A and B".

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
  • I ran Apriori on the same datasets, and I never got an output where the consequent consists of more than one item. Don't apriori and FP-growth have the same output? – Snow Jan 14 '19 at 12:16
  • Maybe the Apriori implementation is bad? – Has QUIT--Anony-Mousse Jan 15 '19 at 22:48
  • I'm using the [apyori](https://pypi.org/project/apyori/) package, which doesn't seem to have a bad implementation. – Snow Jan 16 '19 at 14:11
  • Actually that is so bad, it's not even Apriori. It's a naive interpretation of Apriori that missed all the clever ideas. – Has QUIT--Anony-Mousse Jan 16 '19 at 23:57
  • thank you for pointing that out, I should have checked the source code. Do you know of any package which has a right implementation of it, so that I don't resort to reinventing the wheel (so that I can compare the results with fpgrowth)? – Snow Jan 17 '19 at 12:22
  • 1
    Pyfim looked very thorough to me. – Has QUIT--Anony-Mousse Jan 17 '19 at 19:48
  • just for clarification, the library that you suggest also restricts the consequent to a single item. http://www.borgelt.net/doc/apriori/apriori.html#conseq – Snow May 23 '19 at 15:25