Question? Leave a message!




Data Mining Association Rules: Advanced Concepts and Algorithms

Data Mining Association Rules: Advanced Concepts and Algorithms
Data Mining Association Rules: Advanced Concepts and Algorithms © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 1Continuous and Categorical Attributes How to apply association analysis formulation to non asymmetric binary variables Session Country Session Number of Browser Id Length Web Pages Gender Buy Type (sec) viewed 1 USA 982 8 Male IE No 2 China 811 10 Female Netscape No 3 USA 2125 45 Female Mozilla Yes 4 Germany 596 4 Male IE Yes 5 Australia 123 9 Male Mozilla No … … … … … … … 10 Example of Association Rule: Number of Pages 5,10)  (Browser=Mozilla)  Buy = No © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Handling Categorical Attributes  Transform categorical attribute into asymmetric binary variables  Introduce a new “item” for each distinct attribute value pair – Example: replace Browser Type attribute with  Browser Type = Internet Explorer  Browser Type = Mozilla  Browser Type = Mozilla © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Handling Categorical Attributes  Potential Issues – What if attribute has many possible values  Example: attribute country has more than 200 possible values  Many of the attribute values may have very low support – Potential solution: Aggregate the lowsupport attribute values – What if distribution of attribute values is highly skewed  Example: 95 of the visitors have Buy = No  Most of the items will be associated with (Buy=No) item – Potential solution: drop the highly frequent items © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Handling Continuous Attributes  Different kinds of rules: – Age21,35)  Salary70k,120k)  Buy – Salary70k,120k)  Buy  Age: =28, =4  Different methods: – Discretizationbased – Statisticsbased – Nondiscretization based  minApriori © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Handling Continuous Attributes  Use discretization  Unsupervised: – Equalwidth binning – Equaldepth binning – Clustering  Supervised: Attribute values, v Class v v v v v v v v v 1 2 3 4 5 6 7 8 9 Anomalous 0 0 20 10 20 0 0 0 0 Normal 150 100 0 0 0 100 100 150 100 bin bin bin 1 2 3 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Discretization Issues  Size of the discretized intervals affect support confidence Refund = No, (Income = 51,250)  Cheat = No Refund = No, (60K  Income  80K)  Cheat = No Refund = No, (0K  Income  1B)  Cheat = No – If intervals too small  may not have enough support – If intervals too large  may not have enough confidence  Potential solution: use all possible intervals © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Discretization Issues  Execution time – If intervals contain n values, there are on average 2 O(n ) possible ranges  Too many rules Refund = No, (Income = 51,250)  Cheat = No Refund = No, (51K  Income  52K)  Cheat = No Refund = No, (50K  Income  60K)  Cheat = No © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Approach by Srikant Agrawal  Preprocess the data – Discretize attribute using equidepth partitioning  Use partial completeness measure to determine number of partitions  Merge adjacent intervals as long as support is less than maxsupport  Apply existing association rule mining algorithms  Determine interesting rules in the output © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Approach by Srikant Agrawal  Discretization will lose information Approximated X X – Use partial completeness measure to determine how much information is lost C: frequent itemsets obtained by considering all ranges of attribute values P: frequent itemsets obtained by considering all ranges over the partitions P is Kcomplete w.r.t C if P  C,and X  C,  X’  P such that: 1. X’ is a generalization of X and support (X’)  K  support(X) (K  1) 2. Y  X,  Y’  X’ such that support (Y’)  K  support(Y) Given K (partial completeness level), can determine number of intervals (N) © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Interestingness Measure Refund = No, (Income = 51,250)  Cheat = No Refund = No, (51K  Income  52K)  Cheat = No Refund = No, (50K  Income  60K)  Cheat = No  Given an itemset: Z = z , z , …, z and its 1 2 k generalization Z’ = z ’, z ’, …, z ’ 1 2 k P(Z): support of Z E (Z): expected support of Z based on Z’ Z’ P(z ) P(z ) P(z ) 1 2 k E (Z)P(Z') Z ' P(z ') P(z ') P(z ') 1 2 k – Z is Rinteresting w.r.t. Z’ if P(Z)  R  E (Z) Z’ © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Interestingness Measure  For S: X  Y, and its generalization S’: X’  Y’ P(YX): confidence of X  Y P(Y’X’): confidence of X’  Y’ E (YX): expected support of Z based on Z’ S’ P(y ) P(y ) P(y ) 1 2 k E(Y X )P(Y'X ') P(y ') P(y ') P(y ') 1 2 k  Rule S is Rinteresting w.r.t its ancestor rule S’ if – Support, P(S)  R  E (S) or S’ – Confidence, P(YX)  R  E (YX) S’ © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Statisticsbased Methods  Example: Browser=Mozilla  Buy=Yes  Age: =23  Rule consequent consists of a continuous variable, characterized by their statistics – mean, median, standard deviation, etc.  Approach: – Withhold the target variable from the rest of the data – Apply existing frequent itemset generation on the rest of the data – For each frequent itemset, compute the descriptive statistics for the corresponding target variable  Frequent itemset becomes a rule by introducing the target variable as rule consequent – Apply statistical test to determine interestingness of the rule © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Statisticsbased Methods  How to determine whether an association rule interesting – Compare the statistics for segment of population covered by the rule vs segment of population not covered by the rule: A  B:  versus A  B: ’ ' Z – Statistical hypothesis testing: 2 2 s s 1 2   Null hypothesis: H0: ’ =  +  n n 1 2  Alternative hypothesis: H1: ’  +   Z has zero mean and variance 1 under null hypothesis © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Statisticsbased Methods  Example: r: Browser=Mozilla  Buy=Yes  Age: =23 – Rule is interesting if difference between  and ’ is greater than 5 years (i.e.,  = 5) – For r, suppose n1 = 50, s1 = 3.5 – For r’ (complement): n2 = 250, s2 = 6.5 ' 30 23 5 Z 3.11 2 2 2 2 s s 3.5 6.5 1 2  n n 50 250 1 2 – For 1sided test at 95 confidence level, critical Zvalue for rejecting null hypothesis is 1.64. – Since Z is greater than 1.64, r is an interesting rule © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›MinApriori (Han et al) Documentterm matrix: TID W1 W2 W3 W4 W5 D1 2 2 0 0 1 D2 0 0 1 2 2 D3 2 3 0 0 0 D4 0 0 1 0 1 D5 1 1 1 0 2 Example: W1 and W2 tends to appear together in the same document © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›MinApriori  Data contains only continuous attributes of the same “type” – e.g., frequency of words in a document TID W1 W2 W3 W4 W5 D1 2 2 0 0 1 D2 0 0 1 2 2 D3 2 3 0 0 0 D4 0 0 1 0 1 D5 1 1 1 0 2  Potential solution: – Convert into 0/1 matrix and then apply existing algorithms  lose word frequency information – Discretization does not apply as users want association among words not ranges of words © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›MinApriori  How to determine the support of a word – If we simply sum up its frequency, support count will be greater than total number of documents  Normalize the word vectors – e.g., using L norm 1  Each word has a support equals to 1.0 TID W1 W2 W3 W4 W5 TID W1 W2 W3 W4 W5 D1 2 2 0 0 1 D1 0.40 0.33 0.00 0.00 0.17 Normalize D2 0 0 1 2 2 D2 0.00 0.00 0.33 1.00 0.33 D3 2 3 0 0 0 D3 0.40 0.50 0.00 0.00 0.00 D4 0 0 1 0 1 D4 0.00 0.00 0.33 0.00 0.17 D5 1 1 1 0 2 D5 0.20 0.17 0.33 0.00 0.33 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›MinApriori  New definition of support: sup(C) D(i, j) min jC iT TID W1 W2 W3 W4 W5 Example: D1 0.40 0.33 0.00 0.00 0.17 Sup(W1,W2,W3) D2 0.00 0.00 0.33 1.00 0.33 = 0 + 0 + 0 + 0 + 0.17 D3 0.40 0.50 0.00 0.00 0.00 = 0.17 D4 0.00 0.00 0.33 0.00 0.17 D5 0.20 0.17 0.33 0.00 0.33 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Antimonotone property of Support TID W1 W2 W3 W4 W5 D1 0.40 0.33 0.00 0.00 0.17 D2 0.00 0.00 0.33 1.00 0.33 D3 0.40 0.50 0.00 0.00 0.00 D4 0.00 0.00 0.33 0.00 0.17 D5 0.20 0.17 0.33 0.00 0.33 Example: Sup(W1) = 0.4 + 0 + 0.4 + 0 + 0.2 = 1 Sup(W1, W2) = 0.33 + 0 + 0.4 + 0 + 0.17 = 0.9 Sup(W1, W2, W3) = 0 + 0 + 0 + 0 + 0.17 = 0.17 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multilevel Association Rules Food Electronics Bread Computers Home Milk 2 Skim Wheat White Desktop Laptop Accessory TV DVD Foremost Kemps Printer Scanner © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multilevel Association Rules  Why should we incorporate concept hierarchy – Rules at lower levels may not have enough support to appear in any frequent itemsets – Rules at lower levels of the hierarchy are overly specific  e.g., skim milk  white bread, 2 milk  wheat bread, skim milk  wheat bread, etc. are indicative of association between milk and bread © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multilevel Association Rules  How do support and confidence vary as we traverse the concept hierarchy – If X is the parent item for both X1 and X2, then (X) ≤ (X1) + (X2) – If (X1  Y1) ≥ minsup, and X is parent of X1, Y is parent of Y1 then(X  Y1) ≥ minsup, (X1  Y) ≥ minsup (X  Y) ≥ minsup – If conf(X1  Y1) ≥ minconf, then conf(X1 Y) ≥ minconf © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multilevel Association Rules  Approach 1: – Extend current association rule formulation by augmenting each transaction with higher level items Original Transaction: skim milk, wheat bread Augmented Transaction: skim milk, wheat bread, milk, bread, food  Issues: – Items that reside at higher levels have much higher support counts  if support threshold is low, too many frequent patterns involving items from the higher levels – Increased dimensionality of the data © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multilevel Association Rules  Approach 2: – Generate frequent patterns at highest level first – Then, generate frequent patterns at the next highest level, and so on  Issues: – I/O requirements will increase dramatically because we need to perform more passes over the data – May miss some potentially interesting crosslevel association patterns © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Sequence Data Timeline 10 15 20 25 30 35 Sequence Database: Object A: Object Timestamp Events 2 6 1 A 10 2, 3, 5 1 3 A 20 6, 1 5 A 23 1 B 11 4, 5, 6 B 17 2 Object B: B 21 7, 8, 1, 2 1 4 2 7 B 28 1, 6 6 5 8 6 1 C 14 1, 8, 7 2 Object C: 1 7 8 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Examples of Sequence Data Sequence Sequence Element Event Database (Transaction) (Item) Customer Purchase history of a given A set of items bought by Books, diary products, customer a customer at time t CDs, etc Web Data Browsing activity of a A collection of files Home page, index particular Web visitor viewed by a Web visitor page, contact info, etc after a single mouse click Event data History of events generated Events triggered by a Types of alarms by a given sensor sensor at time t generated by sensors Genome DNA sequence of a An element of the DNA Bases A,T,G,C sequences particular species sequence Element Event (Transaction) E1 E1 E3 (Item) E2 E2 E2 E3 E4 Sequence © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Formal Definition of a Sequence  A sequence is an ordered list of elements (transactions) s = e e e … 1 2 3 – Each element contains a collection of events (items) e = i , i , …, i i 1 2 k – Each element is attributed to a specific time or location  Length of a sequence, s, is given by the number of elements of the sequence  A ksequence is a sequence that contains k events (items) © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Examples of Sequence  Web sequence: Homepage Electronics Digital Cameras Canon Digital Camera Shopping Cart Order Confirmation Return to Shopping  Sequence of initiating events causing the nuclear accident at 3mile Island: (http://stellarone.com/nuclear/staffreports/summarySOEtheinitiatingevent.htm) clogged resin outlet valve closure loss of feedwater condenser polisher outlet valve shut booster pumps trip main waterpump trips main turbine trips reactor pressure increases  Sequence of books checked out at a library: Fellowship of the Ring The Two Towers Return of the King © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Formal Definition of a Subsequence  A sequence a a … a is contained in another 1 2 n sequence b b … b (m ≥ n) if there exist integers 1 2 m i i … i such that a b , a b , …, a b 1 2 n 1 i1 2 i1 n in Data sequence Subsequence Contain 2,4 3,5,6 8 2 3,5 Yes 1,2 3,4 1 2 No 2,4 2,4 2,5 2 4 Yes  The support of a subsequence w is defined as the fraction of data sequences that contain w  A sequential pattern is a frequent subsequence (i.e., a subsequence whose support is ≥ minsup) © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Sequential Pattern Mining: Definition  Given: – a database of sequences – a userspecified minimum support threshold, minsup  Task: – Find all subsequences with support ≥ minsup © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Sequential Pattern Mining: Challenge  Given a sequence: a b c d e f g h i – Examples of subsequences: a c d f g , c d e , b g , etc.  How many ksubsequences can be extracted from a given nsequence a b c d e f g h i n = 9 Answer : k=4: Y Y Y Y n 9   126  k 4  a d e i © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Sequential Pattern Mining: Example Object Timestamp Events A 1 1,2,4 Minsup = 50 A 2 2,3 Examples of Frequent Subsequences: A 3 5 B 1 1,2 1,2 s=60 B 2 2,3,4 2,3 s=60 C 1 1, 2 2,4 s=80 C 2 2,3,4 3 5 s=80 C 3 2,4,5 1 2 s=80 D 1 2 2 2 s=60 D 2 3, 4 1 2,3 s=60 D 3 4, 5 2 2,3 s=60 E 1 1, 3 1,2 2,3 s=60 E 2 2, 4, 5 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Extracting Sequential Patterns  Given n events: i , i , i , …, i 1 2 3 n  Candidate 1subsequences: i , i , i , …, i 1 2 3 n  Candidate 2subsequences: i , i , i , i , …, i i , i i , …, i i 1 2 1 3 1 1 1 2 n1 n  Candidate 3subsequences: i , i , i , i , i , i , …, i , i i , i , i i , …, 1 2 3 1 2 4 1 2 1 1 2 2 i i , i , i i , i , …, i i i , i i i , … 1 1 2 1 1 3 1 1 1 1 1 2 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Generalized Sequential Pattern (GSP)  Step 1: – Make the first pass over the sequence database D to yield all the 1 element frequent sequences  Step 2: Repeat until no new frequent sequences are found – Candidate Generation:  Merge pairs of frequent subsequences found in the (k1)th pass to generate candidate sequences that contain k items – Candidate Pruning:  Prune candidate ksequences that contain infrequent (k1)subsequences – Support Counting:  Make a new pass over the sequence database D to find the support for these candidate sequences – Candidate Elimination:  Eliminate candidate ksequences whose actual support is less than minsup © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Candidate Generation  Base case (k=2): – Merging two frequent 1sequences i and i will produce 1 2 two candidate 2sequences: i i and i i 1 2 1 2  General case (k2): – A frequent (k1)sequence w is merged with another frequent 1 (k1)sequence w to produce a candidate ksequence if the 2 subsequence obtained by removing the first event in w is the same 1 as the subsequence obtained by removing the last event in w 2  The resulting candidate after merging is given by the sequence w 1 extended with the last event of w . 2 – If the last two events in w belong to the same element, then the last event 2 in w becomes part of the last element in w 2 1 – Otherwise, the last event in w becomes a separate element appended to 2 the end of w 1 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Candidate Generation Examples  Merging the sequences w =1 2 3 4 and w =2 3 4 5 1 2 will produce the candidate sequence 1 2 3 4 5 because the last two events in w (4 and 5) belong to the same element 2  Merging the sequences w =1 2 3 4 and w =2 3 4 5 1 2 will produce the candidate sequence 1 2 3 4 5 because the last two events in w (4 and 5) do not belong to the same element 2  We do not have to merge the sequences w =1 2 6 4 and w =1 2 4 5 1 2 to produce the candidate 1 2 6 4 5 because if the latter is a viable candidate, then it can be obtained by merging w with 1 1 2 6 5 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›GSP Example Frequent 3sequences Candidate 1 2 3 Generation 1 2 5 1 5 3 Candidate 1 2 3 4 2 3 4 Pruning 1 2 5 3 2 5 3 1 5 3 4 3 4 5 2 3 4 5 5 3 4 1 2 5 3 2 5 3 4 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Timing Constraints (I) A B C D E x : maxgap g = x n g g n : mingap g m : maximum span = m s s x = 2, n = 0, m = 4 g g s Data sequence Subsequence Contain 2,4 3,5,6 4,7 4,5 8 6 5 Yes 1 2 3 4 5 1 4 No 1 2,3 3,4 4,5 2 3 5 Yes 1,2 3 2,3 3,4 2,4 4,5 1,2 5 No © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Mining Sequential Patterns with Timing Constraints  Approach 1: – Mine sequential patterns without timing constraints – Postprocess the discovered patterns  Approach 2: – Modify GSP to directly prune candidates that violate timing constraints – Question:  Does Apriori principle still hold © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Apriori Principle for Sequence Data Suppose: Object Timestamp Events A 1 1,2,4 x = 1 (maxgap) g A 2 2,3 n = 0 (mingap) g A 3 5 B 1 1,2 m = 5 (maximum span) s B 2 2,3,4 minsup = 60 C 1 1, 2 C 2 2,3,4 C 3 2,4,5 2 5 support = 40 D 1 2 but D 2 3, 4 D 3 4, 5 2 3 5 support = 60 E 1 1, 3 E 2 2, 4, 5 Problem exists because of maxgap constraint No such problem if maxgap is infinite © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Contiguous Subsequences  s is a contiguous subsequence of w = e e … e 1 2 k if any of the following conditions hold: 1. s is obtained from w by deleting an item from either e or e 1 k 2. s is obtained from w by deleting an item from any element e that i contains more than 2 items 3. s is a contiguous subsequence of s’ and s’ is a contiguous subsequence of w (recursive definition)  Examples: s = 1 2 – is a contiguous subsequence of 1 2 3, 1 2 2 3, and 3 4 1 2 2 3 4 – is not a contiguous subsequence of 1 3 2 and 2 1 3 2 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Modified Candidate Pruning Step  Without maxgap constraint: – A candidate ksequence is pruned if at least one of its (k1)subsequences is infrequent  With maxgap constraint: – A candidate ksequence is pruned if at least one of its contiguous (k1)subsequences is infrequent © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Timing Constraints (II) x : maxgap g A B C D E n : mingap g = x n = ws g g ws: window size = m s m : maximum span s x = 2, n = 0, ws = 1, m = 5 g g s Data sequence Subsequence Contain 2,4 3,5,6 4,7 4,6 8 3 5 No 1 2 3 4 5 1,2 3 Yes 1,2 2,3 3,4 4,5 1,2 3,4 Yes © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Modified Support Counting Step  Given a candidate pattern: a, c – Any data sequences that contain … a c … , … a … c… ( where time(c) – time(a) ≤ ws) …c … a … (where time(a) – time(c) ≤ ws) will contribute to the support count of candidate pattern © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Other Formulation  In some domains, we may have only one very long time series – Example:  monitoring network traffic events for attacks  monitoring telecommunication alarm signals  Goal is to find frequent sequences of events in the time series – This problem is also known as frequent episode mining E1 E3 E1 E1 E2 E4 E1 E2 E1 E2 E4 E2 E3 E4 E2 E3 E5 E2 E3 E5 E2 E3 E1 Pattern: E1 E3 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›General Support Counting Schemes Object's Timeline Sequence: (p) (q) p p p p p q q q q q Method Support Count 1 2 3 4 5 6 7 1 COBJ Assume: CWIN 6 x = 2 (maxgap) g n = 0 (mingap) g 4 CMINWIN ws = 0 (window size) m = 2 (maximum span) s CDISTO 8 CDIST 5Frequent Subgraph Mining  Extend association rule mining to finding frequent subgraphs  Useful for Web Mining, computational chemistry, bioinformatics, spatial data sets, etc Homepage Research Artificial Databases Intelligence Data Mining © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Graph Definitions a a a q p p p p b a a a s s s r r p t t t t r r c c c c p q p p b b b (a) Labeled Graph (b) Subgraph (c) Induced Subgraph © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Representing Transactions as Graphs  Each transaction is a clique of items A TID = 1: Transaction Items Id C 1 A,B,C,D B 2 A,B,E 3 B,C 4 A,B,D,E 5 B,C,D E D © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Representing Graphs as Transactions a e a q p e p p q q p r b c d b b d r r r r p d c a G1 G2 G3 (a,b,p) (a,b,q) (a,b,r) (b,c,p) (b,c,q) (b,c,r) … (d,e,r) G1 1 0 0 0 0 1 … 0 G2 1 0 0 0 0 0 … 0 G3 0 0 1 1 0 0 … 0 G3 … … … … … … … … © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Challenges  Node may contain duplicate labels  Support and confidence – How to define them  Additional constraints imposed by pattern structure – Support and confidence are not the only constraints – Assumption: frequent subgraphs must be connected  Apriorilike approach: – Use frequent ksubgraphs to generate frequent (k+1) subgraphs What is k © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Challenges…  Support: – number of graphs that contain a particular subgraph  Apriori principle still holds  Levelwise (Apriorilike) approach: – Vertex growing:  k is the number of vertices – Edge growing:  k is the number of edges © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Vertex Growing a a a q q e e p p p p p p a a a d + r r r d r r a a a G2 G3 = join(G1,G2) G1 0 p p 0 q   0 p p 0 0 p p q    p 0 r 0 0   p 0 r 0 p 0 r 0    M M M p r 0 r 0 G 2 G 1 G3    p r 0 r p r 0 0   0 0 r 0 0    0 0 r 0 q 0 0 0    q 0 0 0 0  © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Edge Growing a a a q q p p p f f p p f p a a a + r r r r r a a a G1 G2 G3 = join(G1,G2) © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Apriorilike Algorithm  Find frequent 1subgraphs  Repeat – Candidate generation  Use frequent (k1)subgraphs to generate candidate ksubgraph – Candidate pruning  Prune candidate subgraphs that contain infrequent (k1)subgraphs – Support counting  Count the support of each remaining candidate – Eliminate candidate ksubgraphs that are infrequent In practice, it is not as easy. There are many other issues © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Example: Dataset a e a q q a e p e p p r q p q p p b c d r b b d r r r c r p d p c d a G1 G2 G3 G4 (a,b,p) (a,b,q) (a,b,r) (b,c,p) (b,c,q) (b,c,r) … (d,e,r) G1 1 0 0 0 0 1 … 0 G2 1 0 0 0 0 0 … 0 G3 0 0 1 1 0 0 … 0 G4 0 0 0 0 0 0 … 0 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Example Minimum support count = 2 k=1 a b c d e Frequent Subgraphs p q r a b a e b d k=2 Frequent p p Subgraphs c d c e p p d c a b k=3 Candidate p r Subgraphs e d (Pruned candidate) © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Candidate Generation  In Apriori: – Merging two frequent kitemsets will produce a candidate (k+1)itemset  In frequent subgraph mining (vertex/edge growing) – Merging two frequent ksubgraphs may produce more than one candidate (k+1)subgraph © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multiplicity of Candidates (Vertex Growing) a a a q q e e p p p p p p a a a d + r r r d r r a a a G2 G3 = join(G1,G2) G1 0 p p 0 0 p p q 0 p p 0 q     p 0 r 0 p 0 r 0 p 0 r 0 0    M M G 2 G 1   p r 0 r p r 0 0 M p r 0 r 0 G 3     0 0 r 0 q 0 0 0 0 0 r 0    q 0 0 0  © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multiplicity of Candidates (Edge growing)  Case 1: identical vertex labels a e a a b c e e + b b a c e c e b c © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multiplicity of Candidates (Edge growing)  Case 2: Core contains identical labels b a c a a a a a b c a b c a a + a a a a a a a a c a a Core: The (k1) subgraph that is common b between the joint graphs a © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Multiplicity of Candidates (Edge growing)  Case 3: Core multiplicity a a a a a b a a b a a b a + a a a b a a b a a b a b a © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Adjacency Matrix Representation A(2) A(1) A(1) A(2) A(3) A(4) B(5) B(6) B(7) B(8) A(1) 1 1 1 0 1 0 0 0 B (6) B (5) A(2) 1 1 0 1 0 1 0 0 A(3) 1 0 1 1 0 0 1 0 A(4) 0 1 1 1 0 0 0 1 B (7) B (8) B(5) 1 0 0 0 1 1 1 0 B(6) 0 1 0 0 1 1 0 1 B(7) 0 0 1 0 1 0 1 1 A(3) A(4) B(8) 0 0 0 1 0 1 1 1 A(1) A(2) A(3) A(4) B(5) B(6) B(7) B(8) A(1) A(2) A(1) 1 1 0 1 0 1 0 0 A(2) 1 1 1 0 0 0 1 0 B (6) B (7) A(3) 0 1 1 1 1 0 0 0 A(4) 1 0 1 1 0 0 0 1 B(5) 0 0 1 0 1 0 1 1 B (5) B (8) B(6) 1 0 0 0 0 1 1 1 B(7) 0 1 0 0 1 1 1 0 A(3) A(4) B(8) 0 0 0 1 1 1 0 1 • The same graph can be represented in many ways © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Graph Isomorphism  A graph is isomorphic if it is topologically equivalent to another graph B A A B A B B A B B A A A B A B © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Graph Isomorphism  Test for graph isomorphism is needed: – During candidate generation step, to determine whether a candidate has been generated – During candidate pruning step, to check whether its (k1)subgraphs are frequent – During candidate counting, to check whether a candidate is contained within another graph © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›Graph Isomorphism  Use canonical labeling to handle isomorphism – Map each graph into an ordered string representation (known as its code) such that two isomorphic graphs will be mapped to the same canonical encoding – Example:  Lexicographically largest adjacency matrix 0 0 1 0 0 1 1 1   0 0 1 1 1 0 1 0  1 1 0 11 1 0 0  0 1 1 0 1 0 0 0  Canonical: 0111101011001000 String: 0010001111010110 © Tan,Steinbach, Kumar Introduction to Data Mining 4/18/2004 ‹›