COMP 5331: Knowledge Discovery and Data Mining

Similar documents
DATA MINING - 1DL360

Lecture Notes for Chapter 6. Introduction to Data Mining

DATA MINING - 1DL360

Data Mining Concepts & Techniques

Association Analysis: Basic Concepts. and Algorithms. Lecture Notes for Chapter 6. Introduction to Data Mining

Lecture Notes for Chapter 6. Introduction to Data Mining. (modified by Predrag Radivojac, 2017)

CS 484 Data Mining. Association Rule Mining 2

Introduction to Data Mining, 2 nd Edition by Tan, Steinbach, Karpatne, Kumar

CS 584 Data Mining. Association Rule Mining 2

Descrip9ve data analysis. Example. Example. Example. Example. Data Mining MTAT (6EAP)

Descrip<ve data analysis. Example. E.g. set of items. Example. Example. Data Mining MTAT (6EAP)

Descriptive data analysis. E.g. set of items. Example: Items in baskets. Sort or renumber in any way. Example

DATA MINING LECTURE 3. Frequent Itemsets Association Rules

Descriptive data analysis. E.g. set of items. Example: Items in baskets. Sort or renumber in any way. Example item id s

Data Mining: Concepts and Techniques. (3 rd ed.) Chapter 6

Association Rules. Fundamentals

D B M G Data Base and Data Mining Group of Politecnico di Torino

DATA MINING LECTURE 4. Frequent Itemsets and Association Rules

D B M G. Association Rules. Fundamentals. Fundamentals. Elena Baralis, Silvia Chiusano. Politecnico di Torino 1. Definitions.

D B M G. Association Rules. Fundamentals. Fundamentals. Association rules. Association rule mining. Definitions. Rule quality metrics: example

DATA MINING LECTURE 4. Frequent Itemsets, Association Rules Evaluation Alternative Algorithms

Association Analysis Part 2. FP Growth (Pei et al 2000)

Association Rules Information Retrieval and Data Mining. Prof. Matteo Matteucci

Association Analysis 1

CSE4334/5334 Data Mining Association Rule Mining. Chengkai Li University of Texas at Arlington Fall 2017

Association Rules. Acknowledgements. Some parts of these slides are modified from. n C. Clifton & W. Aref, Purdue University

ASSOCIATION ANALYSIS FREQUENT ITEMSETS MINING. Alexandre Termier, LIG

CSE 5243 INTRO. TO DATA MINING

Chapter 6. Frequent Pattern Mining: Concepts and Apriori. Meng Jiang CSE 40647/60647 Data Science Fall 2017 Introduction to Data Mining

Association)Rule Mining. Pekka Malo, Assist. Prof. (statistics) Aalto BIZ / Department of Information and Service Management

732A61/TDDD41 Data Mining - Clustering and Association Analysis

Data Mining and Analysis: Fundamental Concepts and Algorithms

CSE 5243 INTRO. TO DATA MINING

Chapters 6 & 7, Frequent Pattern Mining

Association Rule. Lecturer: Dr. Bo Yuan. LOGO

COMP 5331: Knowledge Discovery and Data Mining

Meelis Kull Autumn Meelis Kull - Autumn MTAT Data Mining - Lecture 05

CS5112: Algorithms and Data Structures for Applications

Data mining, 4 cu Lecture 5:

CS 412 Intro. to Data Mining

Associa'on Rule Mining

Unit II Association Rules

Selecting a Right Interestingness Measure for Rare Association Rules

Course Content. Association Rules Outline. Chapter 6 Objectives. Chapter 6: Mining Association Rules. Dr. Osmar R. Zaïane. University of Alberta 4

Frequent Itemset Mining

Basic Data Structures and Algorithms for Data Profiling Felix Naumann

Exercise 1. min_sup = 0.3. Items support Type a 0.5 C b 0.7 C c 0.5 C d 0.9 C e 0.6 F

FP-growth and PrefixSpan

Chapter 4: Frequent Itemsets and Association Rules

Association Rule Mining on Web

Frequent Itemsets and Association Rule Mining. Vinay Setty Slides credit:

Knowledge Discovery and Data Mining I

Association Analysis. Part 1

Temporal Data Mining

sor exam What Is Association Rule Mining?

Machine Learning: Pattern Mining

Outline. Fast Algorithms for Mining Association Rules. Applications of Data Mining. Data Mining. Association Rule. Discussion

Data Analytics Beyond OLAP. Prof. Yanlei Diao

Frequent Itemset Mining

Association Analysis. Part 2

A New Concise and Lossless Representation of Frequent Itemsets Using Generators and A Positive Border

Data Mining. Dr. Raed Ibraheem Hamed. University of Human Development, College of Science and Technology Department of Computer Science

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany

Encyclopedia of Machine Learning Chapter Number Book CopyRight - Year 2010 Frequent Pattern. Given Name Hannu Family Name Toivonen

Introduction to Data Mining

Frequent Itemset Mining

ST3232: Design and Analysis of Experiments

Frequent Itemset Mining

Apriori algorithm. Seminar of Popular Algorithms in Data Mining and Machine Learning, TKK. Presentation Lauri Lahti

Positive Borders or Negative Borders: How to Make Lossless Generator Based Representations Concise

Density-Based Clustering

The Market-Basket Model. Association Rules. Example. Support. Applications --- (1) Applications --- (2)

Sequential Pattern Mining

1 Frequent Pattern Mining

Reductionist View: A Priori Algorithm and Vector-Space Text Retrieval. Sargur Srihari University at Buffalo The State University of New York

Data Mining and Analysis: Fundamental Concepts and Algorithms

Mining Infrequent Patter ns

Handling a Concept Hierarchy

OPPA European Social Fund Prague & EU: We invest in your future.

Lecture 3 : Probability II. Jonathan Marchini

Data Mining Concepts & Techniques

Association (Part II)

On Condensed Representations of Constrained Frequent Patterns

Discovering Non-Redundant Association Rules using MinMax Approximation Rules

Data Mining: Data. Lecture Notes for Chapter 2. Introduction to Data Mining

Selecting the Right Interestingness Measure for Association Patterns

Set Notation and Axioms of Probability NOT NOT X = X = X'' = X

Interesting Patterns. Jilles Vreeken. 15 May 2015

Discovering Binding Motif Pairs from Interacting Protein Groups

Interestingness Measures for Data Mining: A Survey

CSE 5243 INTRO. TO DATA MINING

Assignment 7 (Sol.) Introduction to Data Analytics Prof. Nandan Sudarsanam & Prof. B. Ravindran

Four Paradigms in Data Mining

Math for Liberal Studies

3. Problem definition

.. Cal Poly CSC 466: Knowledge Discovery from Data Alexander Dekhtyar..

Discovering Threshold-based Frequent Closed Itemsets over Probabilistic Data

Mining Free Itemsets under Constraints

CS738 Class Notes. Steve Revilak

Free-sets : a Condensed Representation of Boolean Data for the Approximation of Frequency Queries

Transcription:

COMP 5331: Knowledge Discovery and Data Mining Acknowledgement: Slides modified by Dr. Lei Chen based on the slides provided by Jiawei Han, Micheline Kamber, and Jian Pei And slides provide by Raymond Wong and Tan, Steinbach, Kumar 1 1

Association Rule Mining Given a set of transactions, find rules that will predict the occurrence of an item based on the occurrences of other items in the transaction Market-Basket transactions TID Items 1 Bread, Milk 2 Bread, Diaper, Beer, Eggs 3 Milk, Diaper, Beer, Coke 4 Bread, Milk, Diaper, Beer 5 Bread, Milk, Diaper, Coke Example of Association Rules {Diaper} {Beer}, {Milk, Bread} {Eggs,Coke}, {Beer, Bread} {Milk}, Implication means co-occurrence, not causality!

Definition: Frequent Itemset Itemset A collection of one or more items Example: {Milk, Bread, Diaper} k-itemset An itemset that contains k items Support count ( ) Frequency of occurrence of an itemset E.g. ({Milk, Bread,Diaper}) = 2 Support Fraction of transactions that contain an itemset E.g. s({milk, Bread, Diaper}) = 2/5 Frequent Itemset An itemset whose support is greater than or equal to a minsup threshold TID Items 1 Bread, Milk 2 Bread, Diaper, Beer, Eggs 3 Milk, Diaper, Beer, Coke 4 Bread, Milk, Diaper, Beer 5 Bread, Milk, Diaper, Coke

Definition: Association Rule Association Rule An implication expression of the form X Y, where X and Y are itemsets Example: {Milk, Diaper} {Beer} Rule Evaluation Metrics Support (s) Fraction of transactions that contain both X and Y Confidence (c) Measures how often items in Y appear in transactions that contain X TID Example: Items 1 Bread, Milk 2 Bread, Diaper, Beer, Eggs 3 Milk, Diaper, Beer, Coke 4 Bread, Milk, Diaper, Beer 5 Bread, Milk, Diaper, Coke { Milk, Diaper} Beer (Milk, Diaper, Beer) s T (Milk, Diaper, Beer) c (Milk, Diaper) 2 3 2 5.4.67

Association Rule Mining Task Given a set of transactions T, the goal of association rule mining is to find all rules having support minsup threshold confidence minconf threshold Brute-force approach: List all possible association rules Compute the support and confidence for each rule Prune rules that fail the minsup and minconf thresholds

Mining Association Rules TID Items 1 Bread, Milk 2 Bread, Diaper, Beer, Eggs 3 Milk, Diaper, Beer, Coke 4 Bread, Milk, Diaper, Beer 5 Bread, Milk, Diaper, Coke Example of Rules: {Milk,Diaper} {Beer} (s=.4, c=.67) {Milk,Beer} {Diaper} (s=.4, c=1.) {Diaper,Beer} {Milk} (s=.4, c=.67) {Beer} {Milk,Diaper} (s=.4, c=.67) {Diaper} {Milk,Beer} (s=.4, c=.5) {Milk} {Diaper,Beer} (s=.4, c=.5) Observations: All the above rules are binary partitions of the same itemset: {Milk, Diaper, Beer} Rules originating from the same itemset have identical support but can have different confidence Thus, we may decouple the support and confidence requirements

Mining Association Rules Two-step approach: 1. Frequent Itemset Generation Generate all itemsets whose support minsup 2. Rule Generation Generate high confidence rules from each frequent itemset, where each rule is a binary partitioning of a frequent itemset Frequent itemset generation is still computationally expensive

Frequent Itemset Generation null A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE Given d items, there are 2 d possible candidate itemsets ABCDE

Frequent Itemset Generation Brute-force approach: Each itemset in the lattice is a candidate frequent itemset Count the support of each candidate by scanning the database N Transactions TID Items 1 Bread, Milk 2 Bread, Diaper, Beer, Eggs 3 Milk, Diaper, Beer, Coke 4 Bread, Milk, Diaper, Beer 5 Bread, Milk, Diaper, Coke w List of Candidates M

Computational Complexity Given d unique items: Total number of itemsets = 2 d Total number of possible association rules: 1 2 3 1 1 1 1 d d d k k d j j k d k d R If d=6, R = 62 rules

Frequent Itemset Generation Strategies Reduce the number of candidates (M) Complete search: M=2 d Use pruning techniques to reduce M Reduce the number of transactions (N) Reduce size of N as the size of itemset increases Used by DHP and vertical-based mining algorithms Reduce the number of comparisons (NM) Use efficient data structures to store the candidates or transactions No need to match every candidate against every transaction

Reducing Number of Candidates Apriori principle: If an itemset is frequent, then all of its subsets must also be frequent Apriori principle holds due to the following property of the support measure: X, Y : ( X Y ) s( X ) s( Y Support of an itemset never exceeds the support of its subsets This is known as the anti-monotone property of support )

Illustrating Apriori Principle null A B C D E AB AC AD AE BC BD BE CD CE DE Found to be Infrequent ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE Pruned supersets ABCDE

Illustrating Apriori Principle Item Count Bread 4 Coke 2 Milk 4 Beer 3 Diaper 4 Eggs 1 Minimum Support = 3 Items (1-itemsets) Itemset Count {Bread,Milk} 3 {Bread,Beer} 2 {Bread,Diaper} 3 {Milk,Beer} 2 {Milk,Diaper} 3 {Beer,Diaper} 3 Pairs (2-itemsets) (No need to generate candidates involving Coke or Eggs) Triplets (3-itemsets) If every subset is considered, 6 C 1 + 6 C 2 + 6 C 3 = 41 With support-based pruning, 6 + 6 + 1 = 13 Itemset Count {Bread,Milk,Diaper} 3

Apriori Algorithm Method: Let k=1 Generate frequent itemsets of length 1 Repeat until no new frequent itemsets are identified Generate length (k+1) candidate itemsets from length k frequent itemsets Prune candidate itemsets containing subsets of length k that are infrequent Count the support of each candidate by scanning the DB Eliminate candidates that are infrequent, leaving only those that are frequent

Apriori: A Candidate Generation & Test Approach Apriori pruning principle: If there is any itemset which is infrequent, its superset should not be generated/tested! (Agrawal & Srikant @VLDB 94, Mannila, et al. @ KDD 94) Method: Initially, scan DB once to get frequent 1-itemset Generate length (k+1) candidate itemsets from length k frequent itemsets Test the candidates against DB Terminate when no frequent or candidate set can be generated 16

The Apriori Algorithm An Example Sup Itemset sup Database TDB min = 2 {A} 2 L Tid Items C 1 1 {B} 3 1 A, C, D 2 B, C, E 3 A, B, C, E 4 B, E 1 st scan {C} 3 {D} 1 {E} 3 C 2 C 2 {A, B} 1 L 2 Itemset sup 2 nd scan {A, C} 2 {B, C} 2 {B, E} 3 {C, E} 2 Itemset sup {A, C} 2 {A, E} 1 {B, C} 2 {B, E} 3 {C, E} 2 Itemset sup {A} 2 {B} 3 {C} 3 {E} 3 Itemset {A, B} {A, C} {A, E} {B, C} {B, E} {C, E} C Itemset 3 3 rd scan L 3 {B, C, E} Itemset sup {B, C, E} 2 17

Buckets Reducing Number of Comparisons Candidate counting: Scan the database of transactions to determine the support of each candidate itemset To reduce the number of comparisons, store the candidates in a hash structure Instead of matching each transaction against every candidate, match it against candidates contained in the hashed buckets Transactions Hash Structure N TID Items 1 Bread, Milk 2 Bread, Diaper, Beer, Eggs 3 Milk, Diaper, Beer, Coke 4 Bread, Milk, Diaper, Beer 5 Bread, Milk, Diaper, Coke k

Generate Hash Tree Suppose you have 15 candidate itemsets of length 3: {1 4 5}, {1 2 4}, {4 5 7}, {1 2 5}, {4 5 8}, {1 5 9}, {1 3 6}, {2 3 4}, {5 6 7}, {3 4 5}, {3 5 6}, {3 5 7}, {6 8 9}, {3 6 7}, {3 6 8} You need: Hash function Max leaf size: max number of itemsets stored in a leaf node (if number of candidate itemsets exceeds max leaf size, split the node) Hash function 3,6,9 1,4,7 2,5,8 1 4 5 1 2 4 4 5 7 1 2 5 4 5 8 2 3 4 5 6 7 3 4 5 3 5 6 1 3 6 3 5 7 6 8 9 1 5 9 3 6 7 3 6 8

Association Rule Discovery: Hash tree Hash Function Candidate Hash Tree 1,4,7 2,5,8 Hash on 1, 4 or 7 3,6,9 1 4 5 1 3 6 1 2 4 1 2 5 1 5 9 4 5 7 4 5 8 2 3 4 5 6 7 3 4 5 3 5 6 3 5 7 6 8 9 3 6 7 3 6 8

Association Rule Discovery: Hash tree Hash Function Candidate Hash Tree 1,4,7 2,5,8 Hash on 2, 5 or 8 3,6,9 1 4 5 1 3 6 1 2 4 1 2 5 1 5 9 4 5 7 4 5 8 2 3 4 5 6 7 3 4 5 3 5 6 3 5 7 6 8 9 3 6 7 3 6 8

Association Rule Discovery: Hash tree Hash Function Candidate Hash Tree 1,4,7 2,5,8 Hash on 3, 6 or 9 3,6,9 1 4 5 1 3 6 1 2 4 1 2 5 1 5 9 4 5 7 4 5 8 2 3 4 5 6 7 3 4 5 3 5 6 3 5 7 6 8 9 3 6 7 3 6 8

Subset Operation Given a transaction t, what are the possible subsets of size 3? Transaction, t 1 2 3 5 6 Level 1 1 2 3 5 6 2 3 5 6 3 5 6 Level 2 1 2 3 5 6 1 3 5 6 1 5 6 2 3 5 6 2 5 6 3 5 6 1 2 3 1 2 5 1 2 6 1 3 5 1 3 6 1 5 6 2 3 5 2 3 6 2 5 6 3 5 6 Level 3 Subsets of 3 items

Subset Operation Using Hash Tree 1 2 3 5 6 transaction 1 + 2 3 5 6 2 + 3 5 6 Hash Function 3 + 5 6 2 3 4 5 6 7 1,4,7 2,5,8 3,6,9 1 4 5 1 3 6 1 2 4 1 2 5 1 5 9 4 5 7 4 5 8 3 4 5 3 5 6 3 6 7 3 5 7 3 6 8 6 8 9

Subset Operation Using Hash Tree 1 2 3 5 6 transaction Hash Function 1 2 + 1 3 + 3 5 6 5 6 1 + 2 3 5 6 2 + 3 5 6 3 + 5 6 1,4,7 2,5,8 3,6,9 1 5 + 6 2 3 4 5 6 7 1 4 5 1 3 6 1 2 4 1 2 5 1 5 9 4 5 7 4 5 8 3 4 5 3 5 6 3 6 7 3 5 7 3 6 8 6 8 9

Subset Operation Using Hash Tree 1 2 3 5 6 transaction Hash Function 1 2 + 1 3 + 3 5 6 5 6 1 + 2 3 5 6 2 + 3 5 6 3 + 5 6 1,4,7 2,5,8 3,6,9 1 5 + 6 2 3 4 5 6 7 1 4 5 1 3 6 1 2 4 1 2 5 1 5 9 4 5 7 4 5 8 3 4 5 3 5 6 3 5 7 6 8 9 3 6 7 3 6 8 Match transaction against 9 out of 15 candidates

Factors Affecting Complexity Choice of minimum support threshold lowering support threshold results in more frequent itemsets this may increase number of candidates and max length of frequent itemsets Dimensionality (number of items) of the data set more space is needed to store support count of each item if number of frequent items also increases, both computation and I/O costs may also increase Size of database since Apriori makes multiple passes, run time of algorithm may increase with number of transactions Average transaction width transaction width increases with denser data sets This may increase max length of frequent itemsets and traversals of hash tree (number of subsets in a transaction increases with its width)

Compact Representation of Frequent Itemsets Some itemsets are redundant because they have identical support as their supersets TID A1 A2 A3 A4 A5 A6 A7 A8 A9 A1 B1 B2 B3 B4 B5 B6 B7 B8 B9 B1 C1 C2 C3 C4 C5 C6 C7 C8 C9 C1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 1 1 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 12 1 1 1 1 1 1 1 1 1 1 13 1 1 1 1 1 1 1 1 1 1 14 1 1 1 1 1 1 1 1 1 1 15 1 1 1 1 1 1 1 1 1 1 Number of frequent itemsets Need a compact representation 1 3 1 k 1 k

Maximal Frequent Itemset An itemset is maximal frequent if none of its immediate supersets is frequent null Maximal Itemsets A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE Infrequent Itemsets ABCD E Border

Closed Itemset An itemset is closed if none of its immediate supersets has the same support as the itemset TID Items 1 {A,B} 2 {B,C,D} 3 {A,B,C,D} 4 {A,B,D} 5 {A,B,C,D} Itemset Support {A} 4 {B} 5 {C} 3 {D} 4 {A,B} 4 {A,C} 2 {A,D} 3 {B,C} 3 {B,D} 4 {C,D} 3 Itemset Support {A,B,C} 2 {A,B,D} 3 {A,C,D} 2 {B,C,D} 3 {A,B,C,D} 2

TID Items 1 ABC 2 ABCD 3 BCE 4 ACDE 5 DE Maximal vs Closed Itemsets null Transaction Ids 124 123 1234 245 345 A B C D E 12 124 24 4 123 2 3 24 34 45 AB AC AD AE BC BD BE CD CE DE 12 2 24 4 4 2 3 4 ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE 2 4 ABCD ABCE ABDE ACDE BCDE Not supported by any transactions ABCDE

Maximal vs Closed Frequent Itemsets Minimum support = 2 null Closed but not maximal 124 123 1234 245 345 A B C D E Closed and maximal 12 124 24 4 123 2 3 24 34 45 AB AC AD AE BC BD BE CD CE DE 12 2 24 4 4 2 3 4 ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE 2 4 ABCD ABCE ABDE ACDE BCDE # Closed = 9 # Maximal = 4 ABCDE

Maximal vs Closed Itemsets Frequent Itemsets Closed Frequent Itemsets Maximal Frequent Itemsets

Large Itemset Mining Frequent Itemset Mining Problem: to find all large (or frequent) itemsets with support at least a threshold (i.e., itemsets with support >= 3) TID Items Bought 1 a, b, c, d, e, f, g, h 2 a, f, g 3 b, d, e, f, j 4 a, b, d, i, k 5 a, b, e, g 34

Apriori 1. Join Step 2. Prune Step L 1 Disadvantage 1: It is costly to handle a large number of candidate sets Large 2-itemset Generation C 2 Candidate Generation Large Itemset Generation Disadvantage 2: It is tedious to repeatedly scan the database and check the candidate patterns Large 3-itemset Generation L 2 Counting Step Candidate Generation C 3 Large Itemset Generation L 3 35

FP-tree Scan the database once to store all essential information in a data structure called FP-tree (Frequent Pattern Tree) The FP-tree is concise and is used in directly generating large itemsets 36

FP-tree Step 1: Deduce the ordered frequent items. For items with the same frequency, the order is given by the alphabetical order. Step 2: Construct the FP-tree from the above data Step 3: From the FP-tree above, construct the FPconditional tree for each item (or itemset). Step 4: Determine the frequent patterns. 37

FP-tree Frequent Itemset Mining Problem: to find all large (or frequent) itemsets with support at least a threshold (i.e., itemsets with support >= 3) TID Items Bought 1 a, b, c, d, e, f, g, h 2 a, f, g 3 b, d, e, f, j 4 a, b, d, i, k 5 a, b, e, g 38

FP-tree TID Items Bought 1 a, b, c, d, e, f, g, h 2 a, f, g 3 b, d, e, f, j 4 a, b, d, i, k 5 a, b, e, g 39

TID Items Bought 1 a, b, c, d, e, f, g, h 2 a, f, g 3 b, d, e, f, j 4 a, b, d, i, k 5 a, b, e, g FP-tree 4

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h 2 a, f, g 3 b, d, e, f, j 4 a, b, d, i, k 5 a, b, e, g Threshold = 3 Item a b c d e f g h i j k Frequency 4 COMP5331 41

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h Threshold = 3 2 a, f, g 3 b, d, e, f, j 4 a, b, d, i, k 5 a, b, e, g Item a b c d e f g h i j k Frequency 4 4 1 3 3 3 3 1 1 1 1 COMP5331 42

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h Threshold = 3 2 a, f, g 3 b, d, e, f, j 4 a, b, d, i, k 5 a, b, e, g Item Frequency Item Frequency a b c d e f g h i j k 4 4 1 3 3 3 3 1 1 1 1 a 4 b 4 d 3 e 3 f 3 g 3 COMP5331 43

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h a, b, d, e, f, g 2 a, f, g a, f, g 3 b, d, e, f, j b, d, e, f 4 a, b, d, i, k a, b, d 5 a, b, e, g a, b, e, g Threshold = 3 Item Frequency Item Frequency a b c d e f g h i j k 4 4 1 3 3 3 3 1 1 1 1 a 4 b 4 d 3 e 3 f 3 g 3 COMP5331 44

FP-tree Step 1: Deduce the ordered frequent items. For items with the same frequency, the order is given by the alphabetical order. Step 2: Construct the FP-tree from the above data Step 3: From the FP-tree above, construct the FPconditional tree for each item (or itemset). Step 4: Determine the frequent patterns. 45

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h a, b, d, e, f, g 2 a, f, g a, f, g 3 b, d, e, f, j b, d, e, f 4 a, b, d, i, k a, b, d 5 a, b, e, g a, b, e, g Threshold = 3 Item a b Head of node-link b:1 a:1 root d e d:1 f g 46

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h a, b, d, e, f, g 2 a, f, g a, f, g 3 b, d, e, f, j b, d, e, f 4 a, b, d, i, k a, b, d 5 a, b, e, g a, b, e, g Threshold = 3 Item a b Head of node-link b:1 a:2 a:1 root d e d:1 f g 47

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h a, b, d, e, f, g 2 a, f, g a, f, g 3 b, d, e, f, j b, d, e, f 4 a, b, d, i, k a, b, d 5 a, b, e, g a, b, e, g Threshold = 3 Item a b d e Head of node-link d:1 b:1 a:2 root b:1 d:1 f g 48

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h a, b, d, e, f, g 2 a, f, g a, f, g 3 b, d, e, f, j b, d, e, f 4 a, b, d, i, k a, b, d 5 a, b, e, g a, b, e, g Threshold = 3 Item a b d e Head of node-link d:2 d:1 b:2 b:1 a:3 a:2 root b:1 d:1 f g 49

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h a, b, d, e, f, g 2 a, f, g a, f, g 3 b, d, e, f, j b, d, e, f 4 a, b, d, i, k a, b, d 5 a, b, e, g a, b, e, g Threshold = 3 Item a b d e Head of node-link d:2 b:3 b:2 a:4 a:3 root b:1 d:1 f g 5

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h a, b, d, e, f, g 2 a, f, g a, f, g 3 b, d, e, f, j b, d, e, f 4 a, b, d, i, k a, b, d 5 a, b, e, g a, b, e, g Threshold = 3 Item a b d e Head of node-link d:2 b:3 a:4 root b:1 d:1 f g 51

FP-tree Step 1: Deduce the ordered frequent items. For items with the same frequency, the order is given by the alphabetical order. Step 2: Construct the FP-tree from the above data Step 3: From the FP-tree above, construct the FPconditional tree for each item (or itemset). Step 4: Determine the frequent patterns. 52

TID Items Bought (Ordered) Frequent Items 1 a, b, c, d, e, f, g, h a, b, d, e, f, g 2 a, f, g a, f, g 3 b, d, e, f, j b, d, e, f 4 a, b, d, i, k a, b, d 5 a, b, e, g a, b, e, g Threshold = 3 Item a b d e Head of node-link d:2 b:3 a:4 root b:1 d:1 f g 53

Item a b d e Head of node-link d:2 b:3 a:4 root b:1 d:1 f g 54

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on g { (a:1, b:1, d:1,,, ), } 55

Item Head of node-link Threshold = 3 root a b b:3 a:4 b:1 d:1 d e d:2 f g Cond. FP-tree on g { (a:1, b:1, d:1,,, ), (a:1, b:1,, ), } 56

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on g { (a:1, b:1, d:1,,, ), (a:1, b:1,, ), (a:1,, ) } Item Frequency a b d e f g 3 2 1 2 2 COMP5331 57 3

Item a b d e f g Head of node-link Cond. FP-tree on g { (a:1, b:1, d:1,,, ), (a:1, b:1,, ), (a:1,, ) Item a b d e f g } Frequency 3 2 1 2 Item 3 Threshold = 3 { d:2 b:3 (a:1, ), (a:1, ), Frequency a 3 g 3 (a:1, ) } root 2 COMP5331 58 3 Item a a:4 Head of node-link a:3 b:1 d:1 conditional pattern base of g root

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on f { (a:1, b:1, d:1,, ), } 59

Item Head of node-link Threshold = 3 root a b b:3 a:4 b:1 d:1 d e d:2 f g Cond. FP-tree on f { (a:1, b:1, d:1,, ), (a:1, ), } 6

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on f { (a:1, b:1, d:1,, ), (a:1, ), (b:1, d:1,, ) } Item Frequency a b d e f g 2 2 2 2 3 COMP5331 61

Item Head of node-link a b d e f g Cond. FP-tree on f 3 { (a:1, b:1, d:1,, ), (a:1, ), (b:1, d:1,, ) } Threshold = 3 b:3 d:2 (), (), Item Frequency Item Frequency a b d e f g 2 f 3 { () } root a:4 b:1 d:1 root 2 2 2 3 COMP5331 62

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on e { (a:1, b:1, d:1, ), (a:1, b:1, ), (b:1, d:1, ) } Item Frequency a b d e f g 2 3 2 3 COMP5331 63

Item Head of node-link a b d e f g Cond. FP-tree on e 3 { (a:1, b:1, d:1, ), (a:1, b:1, ), (b:1, d:1, ) Item Frequency a b d e f g } Item Threshold = 3 b:3 d:2 (b:1, ), (b:1, ), Frequency 2 b 3 3 e 3 2 { (b:1, ) root a:4 b:1 d:1 } Item Head of node-link root b:3 3 COMP5331 64 b

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on d { (a:2, b:2, d:2), (b:1, d:1) } Item a b d e f g Frequency 2 3 3 COMP5331 65

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on d 3 { (a:2, b:2, d:2), (b:1, d:1) } { (b:2, d:2), (b:1, d:1) } Item a b d e f g Frequency Item Frequency 2 b 3 3 d 3 3 Item Head of node-link root b:3 COMP5331 66 b

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on b { (a:3, b:3), (b:1) } Item a b d e f g Frequency 3 4 COMP5331 67

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on b 4 { (a:3, b:3), (b:1) } { (a:3, b:3), (b:1) } Item a b d e f g Frequency Item Frequency 3 a 3 4 b 4 Item Head of node-link root a:3 COMP5331 68 a

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on a { } (a:4) Item a b d e f g Frequency 4 COMP5331 69

Item a b d e Head of node-link Threshold = 3 a:4 b:3 d:2 root b:1 d:1 f g Cond. FP-tree on a { } (a:4) 4 { } (a:4) Item a b d e f g Frequency 4 Item Frequency a 4 root COMP5331 7

FP-tree Step 1: Deduce the ordered frequent items. For items with the same frequency, the order is given by the alphabetical order. Step 2: Construct the FP-tree from the above data Step 3: From the FP-tree above, construct the FPconditional tree for each item (or itemset). Step 4: Determine the frequent patterns. 71

Cond. FP-tree on g 3 72

Cond. FP-tree on g 3 Item a Head of node-link a:3 root Cond. FP-tree on f 3 root Cond. FP-tree on e 3 73

Cond. FP-tree on g 3 Cond. FP-tree on d 3 Item a Head of node-link a:3 root Cond. FP-tree on f 3 root Cond. FP-tree on e 3 Item b Head of node-link b:3 root 74

Cond. FP-tree on g 3 Cond. FP-tree on d 3 Item a Head of node-link a:3 root Item b Head of node-link b:3 root Cond. FP-tree on f 3 Cond. FP-tree on b 4 root Cond. FP-tree on e 3 Item Head of root b node-link b:3 75

Cond. FP-tree on g 3 Cond. FP-tree on d 3 Item a Head of node-link a:3 root Item b Head of node-link b:3 root Cond. FP-tree on f 3 root Cond. FP-tree on b 4 Item Head of node-link a a:3 root Cond. FP-tree on e 3 Cond. FP-tree on a 4 Item Head of root root b node-link b:3 76

Cond. FP-tree on g 1. Before generating this Item Head of cond. tree, we generate {g} (support node-link = 3) a 2. After generating this cond. tree, we generate {a, g} (support = 3) Cond. FP-tree on f 1. Before generating this cond. tree, we generate {f} (support = 3) 2. After generating this cond. tree, we do not generate any itemset. a:3 3 3 root root Cond. FP-tree on d 1. Before generating this cond. Item tree, Head we generate of {d} (support node-link = 3) b 2. After generating this cond. tree, we generate {b, d} (support = 3) Cond. FP-tree on b 1. Before Itemgenerating Head of this cond. tree, we generate node-link {b} (support = 4) a 2. After generating this cond. tree, we generate {a, b} (support = 3) 3 b:3 4 a:3 root root Cond. FP-tree on e 3 Cond. FP-tree on a 1. Before generating this 1. Before generating this root root Item Head of cond. tree, we generate cond. tree, we generate {e} (support node-link {a} (support = 4) = 3) b:3 2. After generating this 2. After b generating this cond. tree, we do not cond. tree, we generate COMP5331 generate any itemset. 77 {b, e} (support = 3) 4

Complexity Complexity in building FP-tree Two scans of the transactions DB Collect frequent items Construct the FP-tree Cost to insert one transaction Number of frequent items in this transaction 78

Size of the FP-tree The size of the FP-tree is bounded by the overall occurrences of the frequent items in the database 79

Height of the Tree The height of the tree is bounded by the maximum number of frequent items in any transaction in the database 8

Compression With respect to the total number of items stored, is FP-tree more compressed compared with the original databases? COMP5331 81

Details of the Algorithm Procedure FP-growth (Tree, ) if Tree contains a single path P else for each combination (denoted by ) of the nodes in the path P do generate pattern U with support = minimum support of nodes in for each a i in the header table of Tree do generate pattern = a i U with support = a i.support construct s conditional pattern base and then s conditional FP-tree Tree if Tree Call FP-growth(Tree, ) COMP5331 82

Rule Generation Given a frequent itemset L, find all non-empty subsets f L such that f L f satisfies the minimum confidence requirement If {A,B,C,D} is a frequent itemset, candidate rules: ABC D, ABD C, ACD B, BCD A, A BCD, B ACD, C ABD, D ABC AB CD, AC BD, AD BC, BC AD, BD AC, CD AB, If L = k, then there are 2 k 2 candidate association rules (ignoring L and L) Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Rule Generation How to efficiently generate rules from frequent itemsets? In general, confidence does not have an antimonotone property c(abc D) can be larger or smaller than c(ab D) But confidence of rules generated from the same itemset has an anti-monotone property e.g., L = {A,B,C,D}: c(abc D) c(ab CD) c(a BCD) Confidence is anti-monotone w.r.t. number of items on the RHS of the rule Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Rule Generation for Apriori Algorithm Lattice of rules Low Confidence Rule ABCD=>{ } BCD=>A ACD=>B ABD=>C ABC=>D CD=>AB BD=>AC BC=>AD AD=>BC AC=>BD AB=>CD Pruned Rules D=>ABC C=>ABD B=>ACD A=>BCD Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Rule Generation for Apriori Algorithm Candidate rule is generated by merging two rules that share the same prefix in the rule consequent join(cd=>ab,bd=>ac) would produce the candidate rule D => ABC CD=>AB BD=>AC Prune rule D=>ABC if its subset AD=>BC does not have high confidence D=>ABC Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Pattern Evaluation Association rule algorithms tend to produce too many rules many of them are uninteresting or redundant Redundant if {A,B,C} {D} and {A,B} {D} have same support & confidence Interestingness measures can be used to prune/rank the derived patterns In the original formulation of association rules, support & confidence are the only measures used Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Application of Interestingness Measure Interestingness Measures Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Computing Interestingness Measure Given a rule X Y, information needed to compute rule interestingness can be obtained from a contingency table Contingency table for X Y Y Y X f 11 f 1 f 1+ X f 1 f f o+ f +1 f + T f 11 : support of X and Y f 1 : support of X and Y f 1 : support of X and Y f : support of X and Y Used to define various measures support, confidence, lift, Gini, J-measure, etc. Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Drawback of Confidence Coffee Coffee Tea 15 5 2 Tea 75 5 8 9 1 1 Association Rule: Tea Coffee Confidence= P(Coffee Tea) =.75 but P(Coffee) =.9 Although confidence is high, rule is misleading P(Coffee Tea) =.9375 Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Statistical Independence Population of 1 students 6 students know how to swim (S) 7 students know how to bike (B) 42 students know how to swim and bike (S,B) P(S B) = 42/1 =.42 P(S) P(B) =.6.7 =.42 P(S B) = P(S) P(B) => Statistical independence P(S B) > P(S) P(B) => Positively correlated P(S B) < P(S) P(B) => Negatively correlated Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 # Statistical-based Measures Measures that take into account statistical dependence )] ( )[1 ( )] ( )[1 ( ) ( ) ( ), ( ) ( ) ( ), ( ) ( ) ( ), ( ) ( ) ( Y P Y P X P X P Y P X P Y X P coefficien t Y P X P Y X P PS Y P X P Y X P Interest Y P X Y P Lift

Example: Lift/Interest Coffee Coffee Tea 15 5 2 Tea 75 5 8 9 1 1 Association Rule: Tea Coffee Confidence= P(Coffee Tea) =.75 but P(Coffee) =.9 Lift =.75/.9=.8333 (< 1, therefore is negatively associated) Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Drawback of Lift & Interest Y Y X 1 1 X 9 9 1 9 1 Y Y X 9 9 X 1 1 9 1 1.1 Lift 1.9 Lift 1. 11 (.1)(.1) (.9)(.9) Statistical independence: If P(X,Y)=P(X)P(Y) => Lift = 1 Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

There are lots of measures proposed in the literature Some measures are good for certain applications, but not for others What criteria should we use to determine whether a measure is good or bad? What about Aprioristyle support based pruning? How does it affect these measures?

Properties of A Good Measure Piatetsky-Shapiro: 3 properties a good measure M must satisfy: M(A,B) = if A and B are statistically independent M(A,B) increase monotonically with P(A,B) when P(A) and P(B) remain unchanged M(A,B) decreases monotonically with P(A) [or P(B)] when P(A,B) and P(B) [or P(A)] remain unchanged Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Comparing Different Measures 1 examples of contingency tables: Rankings of contingency tables using various measures: Example f 11 f 1 f 1 f E1 8123 83 424 137 E2 833 2 622 146 E3 9481 94 127 298 E4 3954 38 5 2961 E5 2886 1363 132 4431 E6 15 2 5 6 E7 4 2 1 3 E8 4 2 2 2 E9 172 7121 5 1154 E1 61 2483 4 7452 Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Property under Variable Permutation B B A p q A r s A A B p r B q s Does M(A,B) = M(B,A)? Symmetric measures: support, lift, collective strength, cosine, Jaccard, etc Asymmetric measures: confidence, conviction, Laplace, J-measure, etc Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Property under Row/Column Scaling Grade-Gender Example (Mosteller, 1968): Male Female High 2 3 5 Low 1 4 5 3 7 1 Male Female High 4 3 34 Low 2 4 42 6 7 76 2x 1x Mosteller: Underlying association should be independent of the relative number of male and female students in the samples Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 # Property under Inversion Operation 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 A B C D (a) (b) 1 1 1 1 1 1 1 1 1 (c) E F Transaction 1 Transaction N.....

Example: -Coefficient -coefficient is analogous to correlation coefficient for continuous variables Y Y X 6 1 7 X 1 2 3 7 3 1 Y Y X 2 1 3 X 1 6 7 3 7 1.6.7.7.7.3.7.3.5238.2.3.3.7.3.7.3.5238 Coefficient is the same for both tables Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Property under Null Addition B B A p q A r s B B A p q A r s + k Invariant measures: support, cosine, Jaccard, etc Non-invariant measures: correlation, Gini, mutual information, odds ratio, etc Tan,Steinbach, Kumar Introduction to Data Mining 4/18/24 #

Different Measures have Different Properties Sym bol Measure Range P1 P2 P3 O1 O2 O3 O3' O4 Correlation -1 1 Yes Yes Yes Yes No Yes Yes No Lambda 1 Yes No No Yes No No* Yes No Odds ratio 1 Yes* Yes Yes Yes Yes Yes* Yes No Q Yule's Q -1 1 Yes Yes Yes Yes Yes Yes Yes No Y Yule's Y -1 1 Yes Yes Yes Yes Yes Yes Yes No Cohen's -1 1 Yes Yes Yes Yes No No Yes No M Mutual Information 1 Yes Yes Yes Yes No No* Yes No J J-Measure 1 Yes No No No No No No No G Gini Index 1 Yes No No No No No* Yes No s Support 1 No Yes No Yes No No No No c Confidence 1 No Yes No Yes No No No Yes L Laplace 1 No Yes No Yes No No No No V Conviction.5 1 No Yes No Yes** No No Yes No I Interest 1 Yes* Yes Yes Yes No No No No IS IS (cosine).. 1 No Yes Yes Yes No No No Yes PS Piatetsky-Shapiro's -.25.25 Yes Yes Yes Yes No Yes Yes No F Certainty factor -1 1 Yes Yes Yes No No No Yes No AV Added value.5 1 1 Yes Yes Yes No No No No No S Collective strength 1 No Yes Yes Yes No Yes* Yes No Jaccard.. 1 No Yes Yes Yes No No No Yes 2 K Klosgen's 1 2 1 Yes Yes Yes No No No No No Tan,Steinbach, Kumar 2 3 3 Introduction 3 to Data 3 3 Mining 4/18/24 #