Apriori Algorithm in Data Mining
By: Anshulee Gautam
Tags: Association Rule, Data Mining Techniques, Data Science, Apriori Algorithm, Data Mining

Introduction

Apriori algorithm is designed in such a way that it finds the frequent item sets in a given dataset. This algorithm is named “Apriori” as we need to have prior knowledge of the data present in a particular dataset. The algorithm works on the Apriori concept that includes the subsets of a given frequent itemset must be frequent, if the itemset of particular dataset is not frequent then the supersets will be also infrequent. Support measure of anti-monotonicity is the main concept of this algorithm. The main aim of this algorithm is to find the association between the items whether it is strongly or weakly associated. We determine the association rule using this algorithm that emphasizes the trends and pattern of the dataset.

Example

Suppose, last 4 transactions of an ice cream parlour is given and we have to find an display the most frequent toppings served. So the toppings are listed below:

Chocochips(Ch), Hot Fudge (HF), Sprinkles(S), Caramel(Ca), Hot Chocolate(HC)

Transactions and Items are as per the table given below.

Table-1

Minimum Support — 50%

Threshold Confidence — 70%

Now, calculate support count for each item,

Create a table containing support count of each item present in dataset — called Candidate Set.

Total transaction — 4

Table-2

As Caramel(Ca) has support count less than 50% so we will ignore it for further computation.

Now we will pair each item and calculate support of each item set.

Table-3

We will ignore the item sets that has support below 50%.

Now, we will make item sets of 3 items, and calculate the support of each item sets.

Table-4

Again , we will ignore the item set that has support less the 50%.

So, here we conclude the most frequent item set is (HF, S, HC)

Now , we will find the association rule, so that we can give suggestions to the customer to add these toppings as combo offer.

A confidence of 70% implies that 70% of the total customers, asked for Hot Fudge and Sprinkles also added Hot Chocolate as their topping.

Confidence(A->B)=Support_count(A∪B)/Support_count(A)

By splitting the items from item set we will find the confidence%.

[HF^S]=>[HC] //confidence = sup(HF^S^HC)/sup(HF^S) = 2/2*100=100%

[S^HC]=>[HF] //confidence = sup(S^HC^HF)/sup(S^HC) = 2/2*100=100%

[HF^HC]=>[S] //confidence = sup(HF^HC^S)/sup(HF^HC) = 2/3*100=66%

[HF]=>[S^HC] //confidence = sup(HF^S^HC)/sup(HF) = 2/3*100=66%

[HC]=>[HF^S] //confidence = sup(HC^HF^S)/sup(HC) = 2/3*100=66%

[S]=>[HF^HC] //confidence = sup(S^HF^HC)/sup(S) = 2/3*100=66%

So, the minimum confidence is 70%, then first 2 rules should be considered as the association rules for given set of example.

We can conclude that [HF^S]=>[HC] & [S^HC]=>[HF] are strongly associated to each other.

Advantages

1. The algorithm is easy to understand.

2. Implementation of joins and prune on large datasets is comparatively easy.

3. Provides an intuitive rules as result that makes it easy for the end user to understand.

Disadvantages

1. The database needs to be scanned thoroughly

2. Hard to interpret when the minimum support is very low.

Applications

1. As Recommender System in Google and Amazon.

2. In Hospitals for the analysis of patient’s history.

3. In Educational Sector to admit student based on the given criteria.

4. In Market Analysis.

Conclusions

It provides good performance as it reduces the items of item set eventually after every new candidate set. This algorithm works efficiently as it only scans the entire database once. It is preferred due to its decision making capability in sales and industrial sector.