APRIORI Algoritam Pronalazenje skrivenog znanja

Report
Pronalaženje skrivenog znanja
Student: Nina Tatomir
Profesor: Veljko Milutinović
Apriori Algoritam-Osnovno
Data mining algoritam za pronalaženje pravila
pridruživanja analiziranjem transkacija
Koncept:
 Frequent itemsets (Veliki skupovi)
 Apriori property ( Apriori trik)
 Apriori-gen funkcija
Nina Tatomir
[email protected]
1/16
Apriori Algoritam - Ljuska
 Pronalaženje Frequent itemsets
-Podskup Velikog skupa mora takodje biti Veliki skup
-Iterativno pronalaženje Velikog skupa 1-k
 Generisnaje asocijativnih pravila
Nina Tatomir
[email protected]
2/16
Apriori-gen funkcija
 Join step
Ck se formira spajanjem elemenata iz Lk-1
 Prune step
Bilo koji k-1 ne Veliki podskup ne može biti podskup Velikog
skupa
Nina Tatomir
[email protected]
3/16
PseudoCode
L1 = {Frequent 1-itemsets};
for ( k = 2; Lk-1  0; k++ ) do begin
Ck = apriori-gen(Lk-1);
forall transactions t  D do begin
Ct = subset(Ck, t);
forall candidates c  Ct do
c.count++;
end
Lk = {c  Ck  c.count  minsup}
end
Answer = Uk Lk;
Nina Tatomir
[email protected]
4/16
Primer
TID
Elementi
T100
hleb, mleko, kikiriki
T200
mleko, jaja
T300
mleko, pivo
T400
hleb, mleko, jaja
T500
hleb, pivo
T600
mleko, pivo
T700
hleb, pivo
T800
hleb, mleko, pivo, kikiriki
T900
hleb, mleko, pivo
Nina Tatomir
[email protected]
5/16
Primer – Frequent 1-itemsets
Itemsets
Sup.count
{hleb}
6
{mleko}
7
{pivo}
Itemsets
Sup.count
{hleb}
6
{mleko}
7
6
{pivo}
6
{jaja}
2
{jaja}
2
{kikiriki}
2
{kikiriki}
2
supp({hleb})
>= min.supp
Frequent 1-itemsets L1 = {hleb, mleko, pivo, jaja, kikiriki}
Nina Tatomir
[email protected]
6/16
Primer – Frequent 2-itemstes
Join step
Itemsets
Supp
Itemsets
Supp
{hleb, mleko}
4
{hleb, mleko}
4
{hleb, pivo}
4
{hleb, pivo}
4
{hleb, jaja}
1
{hleb, kikiriki}
2
{hleb, kikiriki}
2
{mleko, pivo}
4
{mleko, pivo}
4
{mleko, jaja}
2
{mleko, jaja}
2
{mleko, kikiriki}
2
>min.supp
{mleko, kikiriki} 2
{pivo, jaja}
0
{pivo, kikiriki}
1
{jaja, kikiriki}
0
L2
C2
Nina Tatomir
[email protected]
7/16
Primeri – Frequent 3-itemsets
Itemsets
Itemsets
{hleb, mleko}
{hleb, mleko, pivo}
{hleb, pivo}
{hleb, mleko, kikiriki}
Join step
{hleb, kikiriki}
{hleb, pivo, kikiriki}
{mleko, pivo}
{mleko, pivo, jaja}
{mleko, jaja}
{mleko, pivo, kikiriki}
{mleko, kikiriki}
{mleko, jaja, kikiriki}
L2
Prune step
C3’
Itemsets
{hleb, mleko, pivo}
{hleb, mleko, kikiriki}
C3
Prune step -> apriori trik
Nina Tatomir
[email protected]
8/16
Primer – Frequent items
Itemsets
Supp
{hleb, mleko, pivo}
2
{hleb, mleko, kikiriki}
2
>min.supp
Itemsets
Supp
{hleb, mleko, pivo}
2
{hleb, mleko, kikiriki}
2
L3
C3
Join step
Itemsets
Prune step
{hleb, mleko, pivo, kikiriki}
C4’
C4
Frequent itemsets -> Association rules
Nina Tatomir
[email protected]
9/16
Primer – Association rules
s->(I-s)
conf(s)=supp(I)/supp(I-s) ≥ min.conf
Frequent itemsets:
L={{hleb},{mleko},{pivo},{jaja},{kikiriki},{hleb,mleko},{hleb,pivo},
{hleb,kikiriki},{mleko,pivo},{mleko,jaja},{mleko,kikiriki},{hleb,mleko,pivo}
,{hleb,mleko,kikiriki}}
Minimum confidence:
min.conf=70%
Nina Tatomir
[email protected]
10/16
Primer – Association rule
I= {hleb,mleko,pivo}
R1: hleb^mleko->pivo
conf=supp(hleb,mleko,pivo)/supp(hleb,mleko)=2/4
conf=50% < 70%
R1 odbijeno
R2:hleb^pivo->mleko
conf=supp(hleb,mleko,pivo)/supp(hleb,pivo)=2/2
conf=100% > 70%
R2 prihvaćeno
Nina Tatomir
[email protected]
11/16
Primer – Association rule
R3: mleko^pivo->hleb
conf=2/2= 100% > 70%
R3 prihvaćeno
R4: hleb->mleko^pivo
conf=supp(hleb,mleko,pivo)/supp(hleb)=2/6 = 33%
R4 odbijeno
R5: mleko-> hleb^pivo
conf=2/7=29%
R5 odbijeno
R6: pivo->hleb^mleko
conf=2/2 = 100%
R6 prihvaćeno
Nina Tatomir
[email protected]
12/16
Složenost – O(∑│Ck│np)
Nina Tatomir
[email protected]
13/16
Metode za poboljšanje efikasnosti
 Ograničavanje broja kandidata u svakoj iteraciji
 Ograničavanje maksimalne dubine pravila K
 Smanjivanje broja transakcija koje se analizairaju
 Smanjivanje broja različitih elemenata
Nina Tatomir
[email protected]
14/16
Literatura
 Top 10 algorithms in data mining
http://www.cs.umd.edu/~samir/498/10Algorithms08.pdf
 Dubinska nalaza podataka potrošačkih korpi
http://www.zemris.fer.hr/predmeti/kdisc/Sem5.doc
Nina Tatomir
[email protected]
15/16
Pitanja?
Nina Tatomir
[email protected]
16/16

similar documents