一. Apriori這個算法的a表示如下:
1)
輸入: 一個相當於0/1矩陣的數據庫,包含n條記錄(transaction); 最小支持t(t>0)
輸出: 一系列t-frequent的集合
1: C1 := I
2: i:=1
3: while Ci!=空集 執行
4: Fi := {X屬於Ci: |D[x]|>=t}
5: print Fi
6: C(i+1) := CANDIDATEGENERATION(Fi)
7: i:= i+1
8: endwhile
2). CANDIDATEGENERATION
對於數據庫中的所有元素, 定義他們的順序(例如: 按照字母表順序)
輸入: set F(K) of frequent k-itemsets
輸出: set C(k+1) of candidate (k+1)-itemsets
1: C(k+1)=空集
2: 對於F(k)中只有最後元素不同的的X, Y
3: make a (k+1)-element set Z by concatenating the common
(k-1)-prefix with the two differing elements according to the order
4: 如果Z的所有K元素子集都在Fk中, 把Z加入到C(k+1)
5: return Ck+1
二. 例子