0% found this document useful (0 votes)
171 views2 pages

Exercise 10: Apriori Algorithm, Solution

The document describes applying the Apriori algorithm to a transactional dataset containing grocery items to find frequent itemsets and generate association rules. It finds all frequent itemsets of size 1, then uses these to generate and test itemsets of size 2 and 3. This results in 6 frequent itemsets. It then generates 3 association rules from the most frequent itemset of size 3, all of which meet the minimum confidence threshold.

Uploaded by

José Germán
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views2 pages

Exercise 10: Apriori Algorithm, Solution

The document describes applying the Apriori algorithm to a transactional dataset containing grocery items to find frequent itemsets and generate association rules. It finds all frequent itemsets of size 1, then uses these to generate and test itemsets of size 2 and 3. This results in 6 frequent itemsets. It then generates 3 association rules from the most frequent itemset of size 3, all of which meet the minimum confidence threshold.

Uploaded by

José Germán
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise 10: Apriori algorithm, solution

1.

We start by finding all the itemsets of size 1 and their support.

{bread} – 3/5, support 0.6


{butter} – 4/5, support 0.8
{beer} – 3/5, support 0.6
{milk} – 2/5, support 0.4
{water} – 2/5, support 0.4
{jam} – 2/5, support 0.4
{diapers} – 2/5, support 0.4
{juice} – 2/5, support 0.4

We then keep only the itemsets with support 0.6

{bread} – 3/5, support 0.6


{butter} – 4/5, support 0.8
{beer} – 3/5, support 0.6

Based on frequent itemsets of size 1 we generate itemsets of size 2


and compute their support.

{bread, butter} – 3/5, support 0.6


{butter, beer} – 3/5, support 0.6
{bread, beer} – 3/5, support 0.6

All of these sets have the minimal support of 0.6, they all become the
basis for generating the itemsets of size 3. There is only one such set.

{bread, beer, butter} – 3/5, support 0.6

This ends the process of generating all frequent itemsets:

{bread} – 3/5, support 0.6


{butter} – 4/5, support 0.8
{beer} – 3/5, support 0.6
{bread, butter} – 3/5, support 0.6
{butter, beer} – 3/5, support 0.6
{bread, beer} – 3/5, support 0.6
{bread, beer, butter} – 3/5, support 0.6

2.

Based on the frequent itemsets we found, we now need to generate


association rules of the form:

item1 Æ {item2, item3}

Since there are three items in the rule we can only use frequent
itemsets of size no less than three to generate the rule. The only such
frequent itemset is {bread, beer, butter}. We generate all
possible association rules for this itemset and compute their
confidence:

bread Æ {beer, butter} - confidence 3/3 = 1.0


beer Æ {bread, butter} - confidence 3/4 = 0.75
butter Æ {bread, beer} - confidence 3/4 = 0.75

All of these rules satisfy the minimum confidence of 0.7.

3.

bread Æ {beer, butter} - confidence 3/3 = 1.0

You might also like