1 Mining Associations Apriori Algorithm. 2 Computation Model uTypically, data is kept in a flat file rather than a database system. wStored on disk. wStored.

Slides:



Advertisements
Similar presentations
Association Rule Mining
Advertisements

1 CPS : Information Management and Mining Association Rules and Frequent Itemsets.
Huffman Codes and Asssociation Rules (II) Prof. Sin-Min Lee Department of Computer Science.
Association Analysis (2). Example TIDList of item ID’s T1I1, I2, I5 T2I2, I4 T3I2, I3 T4I1, I2, I4 T5I1, I3 T6I2, I3 T7I1, I3 T8I1, I2, I3, I5 T9I1, I2,
1 Frequent Itemset Mining: Computation Model uTypically, data is kept in a flat file rather than a database system. wStored on disk. wStored basket-by-basket.
Data Mining of Very Large Data
Association Rule Mining. 2 The Task Two ways of defining the task General –Input: A collection of instances –Output: rules to predict the values of any.
1 CPS : Information Management and Mining Association Rules and Frequent Itemsets.
IDS561 Big Data Analytics Week 6.
 Back to finding frequent itemsets  Typically, data is kept in flat files rather than in a database system:  Stored on disk  Stored basket-by-basket.
חוקי Association ד " ר אבי רוזנפלד. המוטיבציה מה הם הדברים שהולכים ביחד ? –איזה מוצרים בסופר שווה לשים ביחד –מערכות המלצה – Recommendation Systems שבוע.
Association rules The goal of mining association rules is to generate all possible rules that exceed some minimum user-specified support and confidence.
1 Association Rules Market Baskets Frequent Itemsets A-Priori Algorithm.
Mining of Massive Datasets Jure Leskovec, Anand Rajaraman, Jeff Ullman Stanford University Note to other teachers and users of these.
1 of 25 1 of 45 Association Rule Mining CIT366: Data Mining & Data Warehousing Instructor: Bajuna Salehe The Institute of Finance Management: Computing.
Data Mining Association Analysis: Basic Concepts and Algorithms
Association Analysis. Association Rule Mining: Definition Given a set of records each of which contain some number of items from a given collection; –Produce.
Data Mining Techniques So Far: Cluster analysis K-means Classification Decision Trees J48 (C4.5) Rule-based classification JRIP (RIPPER) Logistic Regression.
Data Mining Association Analysis: Basic Concepts and Algorithms Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach, Kumar Introduction.
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
Data Mining Association Analysis: Basic Concepts and Algorithms
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.
1 Association Rules Apriori Algorithm. 2 Computation Model uTypically, data is kept in a flat file rather than a database system. wStored on disk. wStored.
Association Analysis (2). Example TIDList of item ID’s T1I1, I2, I5 T2I2, I4 T3I2, I3 T4I1, I2, I4 T5I1, I3 T6I2, I3 T7I1, I3 T8I1, I2, I3, I5 T9I1, I2,
1 Improvements to A-Priori Park-Chen-Yu Algorithm Multistage Algorithm Approximate Algorithms Compacting Results.
Data Mining Association Analysis: Basic Concepts and Algorithms
1 Association Rules Market Baskets Frequent Itemsets A-priori Algorithm.
Improvements to A-Priori
Association Analysis: Basic Concepts and Algorithms.
Data Mining Association Analysis: Basic Concepts and Algorithms
Improvements to A-Priori
Asssociation Rules Prof. Sin-Min Lee Department of Computer Science.
© Vipin Kumar CSci 8980 Fall CSci 8980: Data Mining (Fall 2002) Vipin Kumar Army High Performance Computing Research Center Department of Computer.
Fast Algorithms for Association Rule Mining
Mining Sequences. Examples of Sequence Web sequence:  {Homepage} {Electronics} {Digital Cameras} {Canon Digital Camera} {Shopping Cart} {Order Confirmation}
1 Fast Algorithms for Mining Association Rules Rakesh Agrawal Ramakrishnan Srikant Slides from Ofer Pasternak.
1 Improvements to A-Priori Park-Chen-Yu Algorithm Multistage Algorithm Approximate Algorithms Compacting Results.
1 “Association Rules” Market Baskets Frequent Itemsets A-priori Algorithm.
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining By Tan, Steinbach, Kumar Lecture.
Modul 7: Association Analysis. 2 Association Rule Mining  Given a set of transactions, find rules that will predict the occurrence of an item based on.
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
Frequent Itemsets and Association Rules 1 Wu-Jun Li Department of Computer Science and Engineering Shanghai Jiao Tong University Lecture 3: Frequent Itemsets.
DATA MINING LECTURE 3 Frequent Itemsets Association Rules.
Note to other teachers and users of these slides: We would be delighted if you found this our material useful in giving your own lectures. Feel free to.
CS 8751 ML & KDDSupport Vector Machines1 Mining Association Rules KDD from a DBMS point of view –The importance of efficiency Market basket analysis Association.
CSE4334/5334 DATA MINING CSE4334/5334 Data Mining, Fall 2014 Department of Computer Science and Engineering, University of Texas at Arlington Chengkai.
Sampling Large Databases for Association Rules Jingting Zeng CIS 664 Presentation March 13, 2007.
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/ Data Mining: Association Analysis This lecture node is modified based on Lecture Notes for.
CS 345: Topics in Data Warehousing Thursday, November 18, 2004.
1 CPS216: Advanced Database Systems Data Mining Slides created by Jeffrey Ullman, Stanford.
Jeffrey D. Ullman Stanford University.  2% of your grade will be for answering other students’ questions on Piazza.  18% for Gradiance.  Piazza code.
1 Association Rules Market Baskets Frequent Itemsets A-Priori Algorithm.
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
1 Data Mining Lecture 6: Association Analysis. 2 Association Rule Mining l Given a set of transactions, find rules that will predict the occurrence of.
Data Mining Association Analysis: Basic Concepts and Algorithms
Frequent Pattern Mining
Frequent Itemsets Association Rules
CPS216: Advanced Database Systems Data Mining
Data Mining Association Analysis: Basic Concepts and Algorithms
Association Rule Mining
Data Mining Association Analysis: Basic Concepts and Algorithms
Market Baskets Frequent Itemsets A-Priori Algorithm
Hash-Based Improvements to A-Priori
Frequent Itemset Mining & Association Rules
Frequent Itemset Mining & Association Rules
Data Mining Association Analysis: Basic Concepts and Algorithms
Association Analysis: Basic Concepts
Presentation transcript:

1 Mining Associations Apriori Algorithm

2 Computation Model uTypically, data is kept in a flat file rather than a database system. wStored on disk. wStored basket-by-basket. uThe true cost of mining disk- resident data is usually the number of disk I/O’s. uIn practice, association-rule algorithms read the data in passes – all baskets read in turn. uThus, we measure the cost by the number of passes an algorithm takes. Item Basket 1 Basket 2 Basket 3 Etc.

3 Main-Memory Bottleneck uFor many frequent-itemset algorithms, main memory is the critical resource. wAs we read baskets, we need to count something, e.g., occurrences of pairs. wThe number of different things we can count is limited by main memory. wSwapping counts in/out is a disaster.

4 Finding Frequent Pairs uThe hardest problem often turns out to be finding the frequent pairs. uWe’ll concentrate on how to do that, then discuss extensions to finding frequent triples, etc.

5 Naïve Algorithm uRead file once, counting in main memory the occurrences of each pair. wFrom each basket of n items, generate its n (n -1)/2 pairs by two nested loops. uFails if (#items) 2 exceeds main memory. wRemember: #items can be 100K (Wal- Mart) or 10B (Web pages).

6 Details of Main-Memory Counting uTwo approaches: 1.Count all pairs, using a triangular matrix. 2.Keep a table of triples [i, j, c] = the count of the pair of items {i,j } is c. u(1) requires only 4 bytes/pair. wNote: assume integers are 4 bytes. u(2) requires 12 bytes, but only for those pairs with count > 0.

7 4 per pair Method (1) Method (2) 12 per occurring pair

8 Triangular-Matrix Approach – (1) uNumber items 1, 2, …,n uCount {i, j } only if i < j. uKeep pairs in the order w{1,2}, {1,3},…, {1,n}, w{2,3}, {2,4},…,{2,n}, w{3,4},…, {3, n}, w… w{n -1,n}.

9 Triangular-Matrix Approach – (2) uLet n be the number of items. Count for pair {i, j } is at position T(i,j) = (i-1)n - i(i+1)/2 + j {1,2}, {1,3}, {1,4}, {2,3}, {2,4} {3,4} uTotal number of pairs n (n –1)/2; total bytes about 2n 2.

10 Details of Approach #2 uTotal bytes used is about 12p, where p is the number of pairs that actually occur. wBeats triangular matrix if at most 1/3 of possible pairs actually occur. uMay require extra space for retrieval structure, e.g., a hash table.

11 Apriori Algorithm for pairs– (1) uA two-pass approach called a-priori limits the need for main memory. uKey idea: monotonicity : if a set of items appears at least s times, so does every subset. wContrapositive for pairs: if item i does not appear in s baskets, then no pair including i can appear in s baskets.

12 Apriori Algorithm for pairs– (2) uPass 1: Read baskets and count in main memory the occurrences of each item. wRequires only memory proportional to #items. uPass 2: Read baskets again and count in main memory only those pairs whose both elements were found in Pass 1 to be frequent. wRequires memory proportional to square of frequent items only. Item counts Pass 1Pass 2 Frequent items Counts of candidate pairs

13 Detail for A-Priori uYou can use the triangular matrix method with n = number of frequent items. uTrick: number frequent items 1,2,… and keep a table relating new numbers to original item numbers.

14 Frequent Triples, Etc. uFor each k, we construct two sets of k –itemsets: wC k = candidate k - itemsets = those that might be frequent (support > s ) based on information from the pass for k –1. wF k = the set of truly frequent k - itemsets. C1C1 F1F1 C2C2 F2F2 C3C3 Filter Construct First pass Second pass All items All pairs of items from F 1 Count the pairs To be explained Count the items

15 Full Apriori Algorithm wLet k=1 wGenerate frequent itemsets of length 1 wRepeat until no new frequent itemsets are found k=k+1 1.Generate length k candidate itemsets from length k-1 frequent itemsets 2.Prune candidate itemsets containing subsets of length k-1 that are infrequent 3.Count the support of each candidate by scanning the DB and eliminate candidates that are infrequent, leaving only those that are frequent

16 Illustrating Apriori Suppose AB is not in F 2. All these will either not be generated by Step 1 as candidates in C 3, or will be pruned in Step 2.

17 Candidate generation 1.Must ensure that the candidate set is complete. 2.Should not generate the same candidate itemset more than once.

18 Data Set Example s=3

19 F k-1  F 1 Method uExtend each frequent (k - 1)­itemset with a frequent 1-itemset. uIs it complete? uYes, because every frequent k­itemset is composed of wa frequent (k-1)­itemset and wa frequent 1­itemset. uHowever, it doesn’t prevent the same candidate itemset from being generated more than once. wE.g., {Bread, Diapers, Milk} can be generated by merging w{Bread, Diapers} with {Milk}, w{Bread, Milk} with {Diapers}, or w{Diapers, Milk} with {Bread}.

20 Lexicographic Order uKeep frequent itemset sorted in lexicographic order. uEach frequent (k-1)­itemset X is extended with frequent items that are lexicographically larger than the items in X. Example u{Bread, Diapers} can be extended with {Milk} u{Bread, Milk} can’t be extended with {Diapers} u{Diapers, Milk} can’t be extended with {Bread} uWhy is it complete?

21 Prunning uMerging {Beer, Diapers} with {Milk} is unnecessary. Why? uBecause one of its subsets, {Beer, Milk}, is infrequent. uSolution: Prune! uHow?

22 F k-1  F 1 Example {Beer,Diapers,Bread} and {Bread,Milk,Beer} aren't in fact generated if lexicographical ord. is considered.

23 F k-1  F k-1 Method uMerge a pair of frequent (k-1) itemsets only if their first k-2 items are identical. uE.g. frequent itemsets {Bread, Diapers} and {Bread, Milk} are merged to form a candidate 3­itemset {Bread, Diapers, Milk}.

24 F k-1  F k-1 Method uWe don’t merge {Beer, Diapers} with {Diapers, Milk} because the first item in both itemsets is different. But, is this "don't merge" decision Ok? uIndeed, if {Beer, Diapers, Milk} is a viable candidate, it would have been obtained by merging {Beer, Diapers} with {Beer, Milk} instead. Pruning uBecause each candidate is obtained by merging a pair of frequent (k-1)­itemsets, an additional candidate pruning step is needed to ensure that the remaining k-2 subsets of k-1 elements are frequent.

25 F k-1  F k-1 Example

26 Another Example TIDList of item ID’s T1I1, I2, I5 T2I2, I4 T3I2, I3 T4I1, I2, I4 T5I1, I3 T6I2, I3 T7I1, I3 T8I1, I2, I3, I5 T9I1, I2, I3 Min_sup_count = 2 Itemset {I5} {I4} {I3} {I2} {I1} C1 Sup. count Itemset 2{I5} 2{I4} 6{I3} 7{I2} 6{I1} F1

27 Generate C2 from F1  F1 TIDList of item ID’s T1I1, I2, I5 T2I2, I4 T3I2, I3 T4I1, I2, I4 T5I1, I3 T6I2, I3 T7I1, I3 T8I1, I2, I3, I5 T9I1, I2, I3 Min_sup_count = 2 ItemsetSup. count {I1}6 {I2}7 {I3}6 {I4}2 {I5}2 F1 {I4,I5} {I3,I5} {I3,I4} {I2,I5} {I2,I4} Itemset {I2,I3} {I1,I5} {I1,I4} {I1,I3} {I1,I2} C2 ItemsetSup. C {I1,I2}4 {I1,I3}4 {I1,I4}1 {I1,I5}2 {I2,I3}4 {I2,I4}2 {I2,I5}2 {I3,I4}0 {I3,I5}1 {I4,I5}0

28 Generate C3 from F2  F2 TIDList of item ID’s T1I1, I2, I5 T2I2, I4 T3I2, I3 T4I1, I2, I4 T5I1, I3 T6I2, I3 T7I1, I3 T8I1, I2, I3, I5 T9I1, I2, I3 Min_sup_count = 2 ItemsetSup. C {I1,I2}4 {I1,I3}4 {I1,I5}2 {I2,I3}4 {I2,I4}2 {I2,I5}2 F2 Itemset {I1,I2,I3} {I1,I2,I5} {I1,I3,I5} {I2,I3,I4} {I2,I3,I5} {I2,I4,I5} Prune Itemset {I1,I2,I3} {I1,I2,I5} {I1,I3,I5} {I2,I3,I4} {I2,I3,I5} {I2,I4,I5} ItemsetSup. C {I1,I2,I3}2 {I1,I2,I5}2 F3 C3

29 Generate C4 from F3  F3 TIDList of item ID’s T1I1, I2, I5 T2I2, I4 T3I2, I3 T4I1, I2, I4 T5I1, I3 T6I2, I3 T7I1, I3 T8I1, I2, I3, I5 T9I1, I2, I3 Min_sup_count = 2 Itemset {I1,I2,I3,I5} C4 {I1,I2,I3,I5} is pruned because {I2,I3,I5} is infrequent ItemsetSup. C {I1,I2,I3}2 {I1,I2,I5}2 F3