0% found this document useful (0 votes)
40 views9 pages

Association Rule Miningsolvedexamples

The document discusses solving problems related to association rule mining using the Apriori algorithm. It provides examples of generating rules from transaction data sets and calculating support and confidence for rules. It shows the step-by-step process of applying the Apriori algorithm.

Uploaded by

vasunews
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)
40 views9 pages

Association Rule Miningsolvedexamples

The document discusses solving problems related to association rule mining using the Apriori algorithm. It provides examples of generating rules from transaction data sets and calculating support and confidence for rules. It shows the step-by-step process of applying the Apriori algorithm.

Uploaded by

vasunews
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/ 9

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/340105166

Association Rule Mining--Apriori Algorithm Solved Problems

Method · March 2020


DOI: 10.13140/RG.2.2.35174.78407

CITATIONS READS
0 51,720

1 author:

Mahendra Patil
Atharva College of Engineering, Malad
48 PUBLICATIONS 32 CITATIONS

SEE PROFILE

All content following this page was uploaded by Mahendra Patil on 23 March 2020.

The user has requested enhancement of the downloaded file.


Association Rule Mining--Apriori Algorithm Solved Problems

Q.1) For the following given Transaction Data-set, Generate Rules using Apriori Algorithm.

Consider the values as Support=50% and Confidence=75%

Transaction ID Items Purchased

1 Bread, Cheese, Egg, Juice

2 Bread, Cheese, Juice

3 Bread, Milk, Yogurt

4 Bread, Juice, Milk

5 Cheese, Juice, Milk

Answer:

Given Support=50% and Confidence=75%

Step 1) Find Frequent Item Set and their support

Item Frequency Support (in %)

Bread 4 4/5=80%

Cheese 3 3/5=60%

Egg 1 1/5=20%

Juice 4 4/5=80%

Milk 3 3/5=60%

Yogurt 1 1/5=20%

Support (item) = Frequency of item/Number of transactions

Step 2) Remove all the items whose support is below given minimum support.

Item Frequency Support (in %)

Prepared By Prof. Mahendra Patil 1


Bread 4 4/5=80%

Cheese 3 3/5=60%

Juice 4 4/5=80%

Milk 3 3/5=60%

Step 3) Now form the two items candidate set and write their frequencies.

Items Pair Frequency Support (in %)

Bread, Cheese 2 2/5=40%

Bread, Juice 3 3/5=60%

Bread, Milk 2 2/5=40%

Cheese, Juice 3 3/5=60%

Cheese, Milk 1 1/5=20%

Juice, Milk 2 2/5=40%

Step 4) Remove all the items whose support is below given minimum support.

Items Pair Frequency Support (in %)

Bread, Juice 3 3/5=60%

Cheese, Juice 3 3/5=60%

Step 5) Generate rules

For Rules we consider item pairs:

a) (Bread, Juice)
Bread->Juice and Juice->Bread
b) (Cheese, Juice)
Cheese->Juice and Juice->Cheese

Confidence (A->B) = support (AUB)/support (A)

Prepared By Prof. Mahendra Patil 2


Therefore,

1. Confidence (Bread->Juice) = support (Bread U Juice)/support (Bread)


= 3/5 * 5/4=3/4= 75%
2. Confidence (Juice->Bread) = support (Juice U Bread)/support (Juice)

= 3/5*5/4=3/4=75%

3. Confidence (Cheese->Juice) = support (Cheese U Juice)/support (Cheese)

=3/5*5/3=1=100%

4. Confidence (Juice->Cheese) = support (Juice U Cheese)/support (Juice)

= 3/5*5/4=3/4=75%

All the above rules are good because the confidence of each rule is greater than or equal to
the minimum confidence given in the problem.

Q.2) For the following given transaction data set, generate rules using Apriori
Algorithm. Consider the values as Support=22% and Confidence= 70%

Transaction ID Items Purchased

1 I1,I2,I5

2 I2,I4

3 I2,I3

4 I1,I2,I4

5 I1,I3

6 I2,I3

7 I1,I3

8 I1,I2,I3,I5

9 I1,I2,I3

Answer:

Prepared By Prof. Mahendra Patil 3


Given minimum support=22% and confidence=70%

Step 1) Find Frequent Item Set and their support

Item Frequency Support (in %)

I1 6 6/9=66%

I2 7 7/9=80%

I3 6 6/9=66%

I4 2 2/9=22.2%

I5 2 2/9=22.2%

Support (item) = Frequency of item/Number of transactions

Step 2) Remove all the items whose support is below given minimum support and
form the two items candidate set and write their frequencies.

Item Frequency Support (in %)

I1,I2 4 4/9=44.4%

I1,I3 4 4/9=44.4%

I1,I4 1 1/9=11.1%

I1,I5 2 2/9=22.2%

I2,I3 4 4/9=44.4%

I2,I4 2 2/9=22.2%

I2,I5 2 2/9=22.2%

I3,I4 0 0/9=0%

I3,I5 1 1/9=11.1%

I4,I5 0 0/9=0%

Prepared By Prof. Mahendra Patil 4


Step 3) Remove all the items whose support is below given minimum support and
form the three items candidate set and write their frequencies

Items Pair Frequency Support (in %)

I1,I2,I3 2 2/9=22.2%

I1,I2,I5 2 2/9=22.2%

Step 4) Generate rules and find the confidence of each rule. If the confidence is below
70% then discard that rule. Keep only the rules whose confidence is equal to or
above 70%.

Confidence (A->B) = support (AUB)/support (A)

For the item set (I1,I2,I3) following rules are possible:

Rule Confidence

2/9*9/4=2/4=50%
(I1,I2)-> I3

2/9*9/4=2/4=50%
(I1,I3)-> I2

2/9*9/4=2/4=50%
(I2,I3)-> I1

2/9*9/6=2/6=33.33%
I1-> (I2,I3)

2/9*9/7=2/7=28.57%
I2-> (I1,I3)

2/9*9/6=2/6=33.33%
I3->(I1,I2)

For the item set (I1,I2,I5) following rules are possible:

Rule Confidence

2/9*9/4=2/4=50%
(I1,I2)-> I5

2/9*9/2=2/2=100%
(I1,I5)-> I2

Prepared By Prof. Mahendra Patil 5


2/9*9/2=2/2=100%
(I2,I5)-> I1

2/9*9/6=2/6=33.33%
I1-> (I2,I5)

2/9*9/7=2/7=28.57%
I2-> (I1,I5)

2/9*9/2=2/2=100%
I5->(I1,I2)

From above rules only following rules are valid (because it’s confidence>=75%):

(I1,I5)-> I2

(I2,I5)-> I1

I5->(I1,I2)

Q.3) Assume min. Support ort = 40%

Marks:​ 10 M
Year:​ Dec 2015
Ans:

Support count = 40%


x/5 * 100 = 50
x=3
Step 1: Generating 1-itemset frequent pattern

Prepared By Prof. Mahendra Patil 6


Scan D for count of each candidate
C1

Compare candidate support count with minimum support count


L1

Step 2: Generate C2- item set Frequent Pattern


Generate C2 candidate from L1
C2

Compare candidate support count with minimum support count


L2

Step 3: Generating 3- item set Frequent Pattern

Prepared By Prof. Mahendra Patil 7


View publication stats

C3

Compare candidate support count with minimum support count.


As the support count generated is less than minimum support count. So, there is no item set
with minimum support count.

Prepared By Prof. Mahendra Patil 8

You might also like