Understanding apyori's output
Asked Answered
S

1

15

I'm well familiar with the apriori algorithm, and the meaning of support/confidence/lift.

I'm currently using the apyori apriori implementation, and I'm not sure I understand the output of an apyori.apriori() call.

It comes out like this

> RelationRecord(items=frozenset({'item1', 'item2'}),
> support=0.15365410803449842,
> ordered_statistics=[OrderedStatistic(items_base=frozenset({'item1'}),
> items_add=frozenset({'item2'}), confidence=0.6203420891875382,
> lift=2.2233410344037092),
> OrderedStatistic(items_base=frozenset({'item2'}),
> items_add=frozenset({'item1'}), confidence=0.5507049891540131,
> lift=2.2233410344037097)])

What is the rule? There are multiple support/confidence/lift, what each one denotes?

I'd appreciate a dictionary style explanation of each part of the output

Surrounding answered 6/11, 2017 at 10:0 Comment(0)
S
15

The RelationRecord reflects a subset of items, while ordered_statistics is a list of OrderedStatistics, which reflect the rules. Each OrderedStatistics' items_base is the antecedent and the items_add is the consequent. The support is stored in the RelationRecord, since it's the same for the contained rules.

In your example:

item1 -> item2 with 0.62 confidence and 2.2233410344037092x lift

item2 -> item1 with 0.55 confidence and 2.2233410344037097x lift

Both have support=0.15365410803449842.

For what it's worth, I ended up switching to using PyFIM for relative feature richness and other bundled algorithms (e.g. fp-growth).

Slipstream answered 16/11, 2017 at 19:40 Comment(6)
Just wanted to follow up and see if my answer was helpful/you continued using apyori. If you found this helpful, please select it as the correct answer. Thanks!Slipstream
do you know if the rules returned from the algorithm is by default sorted in some order? rules = apriori(transactions, min_support = 0.003, min_confidence = 0.2, min_lift = 3, min_length = 2)Ralaigh
Thanks for this. I really wish apyori had a proper documentation.Congius
@Ralaigh note that there's no keyword arg min_length.Congius
@timegeb - Just whipped these unofficial docs together. Hope they help! zaxrosenberg.com/unofficial-apyori-documentationSlipstream
By the way, how do I interpret a rule of the type: frozenset({}) -> fronzenset({item}) What does an empty frozenset mean?Ho

© 2022 - 2024 — McMap. All rights reserved.