Apriori algorithm

14
Apriori Algorithm Apriori Algorithm Hash Based and Graph Hash Based and Graph Based Modifications Based Modifications

description

this is my first trial

Transcript of Apriori algorithm

Page 1: Apriori algorithm

Apriori AlgorithmApriori Algorithm

Hash Based and Graph Based Hash Based and Graph Based ModificationsModifications

Page 2: Apriori algorithm

AgendaAgenda

• Data Mining

• Association Rule

• Ariori Algorithm

• Hash Based Method

• Graph Based Approach

• Conclusion and Future Work

Page 3: Apriori algorithm

Data MiningData Mining

• Data mining is the process of extracting patterns (knowledge) from data. The aim of data mining is to automate the process of finding interesting patterns and trends from a given data. It is seen as an increasingly important tool by modern business to transform data into business intelligence giving an informational advantage. It is currently used in a wide range of profiling practices, scientific discovery, and decision making.

Page 4: Apriori algorithm

Association RulesAssociation Rules

• Association rule learning is a popular and well researched method for discovering interesting relations between variables in large database.

• For example, the rule found in the sales data of a supermarket would indicate that if a customer buys onions and potatoes together, he or she is likely to also buy burger. Such information can be used as the basis for decisions about marketing activities.

Page 5: Apriori algorithm

Problem DescriptionProblem Description

• I = {A, B, C}• Possible Item sets:

Page 6: Apriori algorithm

Support and ConfidenceSupport and Confidence

• Support (A -> B) =

No. of transactions containing A & B

________________________________

No. of total transactions

• Confidence (A -> B) =

No. of transactions containing A & B

_________________________________

No. of transactions containing A

Page 7: Apriori algorithm

Original Apriori AlgorithmOriginal Apriori Algorithm

Page 8: Apriori algorithm

L1 = {large 1-itemsetsg}for ( k = 2; Lk !=0, k++ )

do beginCk = apriori-gen(Lk-1 ); // New candidates

for all transactions tЄD do begin

Ct = subset (Ck , t); // Candidates contained in tfor all candidates cЄCt do

c.count;++end

Lk = {c Є Ck | c.count >= minsup}end

Page 9: Apriori algorithm
Page 10: Apriori algorithm

Hash based methodHash based method Repeat //for each transaction of the database

}D = { set of all possible k-itemsets in the ith transaction}

For each element of D}

Find a unique integer uniq_int using thehash function for k-itemsetIncrement freq[uniq_int]

{Increment trans_pos

//Moves pointer to next transaction until end_of_file For (freq_ind=0; freq_ind<length_of_the_array(two_three_freq[]); freq_ind++)

}if (freq[freq_ind] >= required support)

mark the corresponding k-itemset{{

Page 11: Apriori algorithm

Graph based approachGraph based approach Procedure FrequentItemGraph (Tree, F)

}scan the DB once to collect the frequent 2-itemsets

and their support ascending;add all items in the DB as the header nodes

for each 2-itemset entry (top down order) in freq2list do

if (first item = item in header node) thencreate a link to the corresponding header node i=3

for each i-itemsets entry in the tree do

call buildsubtree (F)end {

Procedure buildsubtree (F) If (first i-1 itemset = itemsets in their respective header nodes) then

create a link to the corresponding header node i=i+1repeat buildsubtree (F)

end{

Page 12: Apriori algorithm

ExampleExample::TransactionItems

T1b e

T2a b c e f g

T3b c e f g

T4a c g

Page 13: Apriori algorithm

Conclusion and Future WorkConclusion and Future Work• In order to be able to continue with the hashing method, we need a

perfect hash function h(e1, e2,…, ek), this hash function can be obtained by one of the following methods:

• h(e1,e2,…,ek) = prm(1)^e1 + prm(2)^e2 + … + prm(k)^ek Where prm is the set of prime numbers, prm = {2, 3, 5, 7…} Although this hash function guarantee a unique key for every

itemset, but it requires an irrational memory space, for example, consider an original item set X with only 10 items, and the following T hashed item set, T = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, consider a 4-itemset (1, 2, 3, 10), this item set will be hashed to the value “282475385”, this will result in reserving large memory space without being used effectively.

• Other perfect hash functions, used in hashing strings, are not applicable here, because the input variables are limited to 26, which is the number of alphabets, while the number of items in a certain database can be very larger than this.

Page 14: Apriori algorithm

Use hashing techniques to find the efficient frequent 2-itemsets in order to reduce the time and memory requirements to build a graphical structure