Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding apyori's output

Tags:

python

apriori

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

like image 686
bluesummers Avatar asked Nov 06 '17 10:11

bluesummers


1 Answers

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).

like image 57
ZaxR Avatar answered Sep 20 '22 17:09

ZaxR