Mining Association Rules in Large Databases

Slides:



Advertisements
Similar presentations
Association Rule Mining
Advertisements

Mining Association Rules in Large Databases
Recap: Mining association rules from large datasets
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,
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.
 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.
Data Mining Association Analysis: Basic Concepts and Algorithms
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
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,
Organization “Association Analysis”
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
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
Data Mining Association Analysis: Basic Concepts and Algorithms
Association Analysis: Basic Concepts and Algorithms.
Data Mining Association Analysis: Basic Concepts and Algorithms
Improvements to A-Priori
© Vipin Kumar CSci 8980 Fall CSci 8980: Data Mining (Fall 2002) Vipin Kumar Army High Performance Computing Research Center Department of Computer.
Eick, Tan, Steinbach, Kumar: Association Analysis Part1 Organization “Association Analysis” 1. What is Association Analysis? 2. Association Rules 3. The.
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,
Eick, Tan, Steinbach, Kumar: Association Analysis Part1 Organization “Association Analysis” 1. What is Association Analysis? 2. Association Rules 3. The.
Supermarket shelf management – Market-basket model:  Goal: Identify items that are bought together by sufficiently many customers  Approach: Process.
Data & Text Mining1 Introduction to Association Analysis Zhangxi Lin ISQS 3358 Texas Tech University.
Data Mining Association Analysis: Basic Concepts and Algorithms Lecture Notes for Chapter 6 Introduction to Data Mining by Tan, Steinbach, Kumar © Tan,Steinbach,
CSE4334/5334 DATA MINING CSE4334/5334 Data Mining, Fall 2014 Department of Computer Science and Engineering, University of Texas at Arlington Chengkai.
1 What is Association Analysis: l Association analysis uses a set of transactions to discover rules that indicate the likely occurrence of an item based.
© Tan,Steinbach, Kumar Introduction to Data Mining 4/18/ Data Mining: Association Analysis This lecture node is modified based on Lecture Notes for.
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 (2) Instructor: Dr. Chun Yu School of Statistics Jiangxi University of Finance and Economics Fall 2015.
Stats 202: Statistical Aspects of Data Mining Professor Rajan Patel
Mining Association Rules in Large Databases
Data Mining Association Analysis: Basic Concepts and Algorithms
Data Mining Association Analysis: Basic Concepts and Algorithms
Data Mining Association Analysis: Basic Concepts and Algorithms
Data Mining Association Analysis: Basic Concepts and Algorithms
Association Analysis: Basic Concepts and Algorithms
Data Mining Association Analysis: Basic Concepts and Algorithms
Frequent Pattern Mining
William Norris Professor and Head, Department of Computer Science
Frequent Itemsets Association Rules
COMP 5331: Knowledge Discovery and Data Mining
Market Basket Many-to-many relationship between different objects
Association Analysis: Basic Concepts
Data Mining Association Analysis: Basic Concepts and Algorithms
Association Rule Mining
Data Mining Association Analysis: Basic Concepts and Algorithms
Hash-Based Improvements to A-Priori
ΠΑΝΕΠΙΣΤΗΜΙΟ ΙΩΑΝΝΙΝΩΝ ΑΝΟΙΚΤΑ ΑΚΑΔΗΜΑΪΚΑ ΜΑΘΗΜΑΤΑ
Data Mining Association Analysis: Basic Concepts and Algorithms
Association Analysis: Basic Concepts and Algorithms
CSE4334/5334 Data Mining Lecture 15: Association Rule Mining (2)
Data Mining Association Analysis: Basic Concepts and Algorithms
Data Mining Association Analysis: Basic Concepts and Algorithms
Lecture 11 (Market Basket Analysis)
Data Mining Association Analysis: Basic Concepts and Algorithms
Data Mining Association Analysis: Basic Concepts and Algorithms
Mining Association Rules in Large Databases
Data Mining Association Analysis: Basic Concepts and Algorithms
Data Mining Association Analysis: Basic Concepts and Algorithms
Association Analysis: Basic Concepts
What Is Association Mining?
Presentation transcript:

Mining Association Rules in Large Databases 1

Association rules Given a set of transactions D, find rules that will predict the occurrence of an item (or a set of items) based on the occurrences of other items in the transaction Market-Basket transactions Examples of association rules {Diaper}  {Beer}, {Milk, Bread}  {Diaper,Coke}, {Beer, Bread}  {Milk}, 2

An even simpler concept: frequent itemsets Given a set of transactions D, find combination of items that occur frequently Market-Basket transactions Examples of frequent itemsets {Diaper, Beer}, {Milk, Bread} {Beer, Bread, Milk}, 3

Lecture outline Task 1: Methods for finding all frequent itemsets efficiently Task 2: Methods for finding association rules efficiently 4

Definition: Frequent Itemset A set of one or more items E.g.: {Milk, Bread, Diaper} k-itemset An itemset that contains k items Support count ()‏ Frequency of occurrence of an itemset (number of transactions it appears) E.g. ({Milk, Bread,Diaper}) = 2 Support Fraction of the transactions in which an itemset appears E.g. s({Milk, Bread, Diaper}) = 2/5 Frequent Itemset An itemset whose support is greater than or equal to a minsup threshold 5

Why do we want to find frequent itemsets? Find all combinations of items that occur together They might be interesting (e.g., in placement of items in a store ) Frequent itemsets are only positive combinations (we do not report combinations that do not occur frequently together) Frequent itemsets aims at providing a summary for the data 6

Finding frequent sets Task: Given a transaction database D and a minsup threshold find all frequent itemsets and the frequency of each set in this collection Stated differently: Count the number of times combinations of attributes occur in the data. If the count of a combination is above minsup report it. Recall: The input is a transaction database D where every transaction consists of a subset of items from some universe I 7

How many itemsets are there? Given d items, there are 2d possible itemsets 8

When is the task sensible and feasible? If minsup = 0, then all subsets of I will be frequent and thus the size of the collection will be very large This summary is very large (maybe larger than the original input) and thus not interesting The task of finding all frequent sets is interesting typically only for relatively large values of minsup 9

A simple algorithm for finding all frequent itemsets ?? 10

Brute-force algorithm for finding all frequent itemsets? Generate all possible itemsets (lattice of itemsets)‏ Start with 1-itemsets, 2-itemsets,...,d-itemsets Compute the frequency of each itemset from the data Count in how many transactions each itemset occurs If the support of an itemset is above minsup report it as a frequent itemset

Brute-force approach for finding all frequent itemsets Complexity? Match every candidate against each transaction For M candidates and N transactions, the complexity is~ O(NMw) => Expensive since M = 2d !!! 12

Speeding-up the brute-force algorithm Reduce the number of candidates (M)‏ Complete search: M=2d Use pruning techniques to reduce M Reduce the number of transactions (N)‏ Reduce size of N as the size of itemset increases Use vertical-partitioning of the data to apply the 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 13

Reduce the number of candidates Apriori principle (Main observation): 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: The support of an itemset never exceeds the support of its subsets This is known as the anti-monotone property of support 14

Example s(Bread) > s(Bread, Beer)‏ s(Milk) > s(Bread, Milk)‏ s(Diaper, Beer) > s(Diaper, Beer, Coke)‏ 15

Illustrating the Apriori principle Found to be Infrequent Pruned supersets 16

Illustrating the Apriori principle Items (1-itemsets)‏ Pairs (2-itemsets)‏ (No need to generate candidates involving Coke or Eggs)‏ minsup = 3/5 Triplets (3-itemsets)‏ If every subset is considered, 6C1 + 6C2 + 6C3 = 41 With support-based pruning, 6 + 6 + 1 = 13 17

Exploiting the Apriori principle Find frequent 1-items and put them to Lk (k=1)‏ Use Lk to generate a collection of candidate itemsets Ck+1 with size (k+1)‏ Scan the database to find which itemsets in Ck+1 are frequent and put them into Lk+1 If Lk+1 is not empty k=k+1 Goto step 2 R. Agrawal, R. Srikant: "Fast Algorithms for Mining Association Rules", Proc. of the 20th Int'l Conference on Very Large Databases, 1994. 18

The Apriori algorithm L1 = {frequent 1-itemsets}; Ck: Candidate itemsets of size k Lk : frequent itemsets of size k L1 = {frequent 1-itemsets}; for (k = 2; Lk !=; k++) Ck+1 = GenerateCandidates(Lk)‏ for each transaction t in database do increment count of candidates in Ck+1 that are contained in t endfor Lk+1 = candidates in Ck+1 with support ≥min_sup return k Lk;

Discussion of the Apriori algorithm Much faster than the Brute-force algorithm It avoids checking all elements in the lattice The running time is in the worst case O(2d)‏ Pruning really prunes in practice It makes multiple passes over the dataset One pass for every level k Multiple passes over the dataset is inefficient when we have thousands of candidates and millions of transactions

PCY (Park-Chen-Yu) Algorithm

PCY (Park-Chen-Yu) Algorithm Observation: In pass 1 of A-Priori, most memory is idle We store only individual item counts Can we use the idle memory to reduce memory required in pass 2? Pass 1 of PCY: In addition to item counts, maintain a hash table with as many buckets as fit in memory Keep a count for each bucket into which pairs of items are hashed For each bucket just keep the count, not the actual pairs that hash to the bucket!

PCY Algorithm – First Pass FOR (each basket) : FOR (each item in the basket) : add 1 to item’s count; FOR (each pair of items) : hash the pair to a bucket; add 1 to the count for that bucket; Few things to note: Pairs of items need to be generated from the input file; they are not present in the file We are not just interested in the presence of a pair, but we need to see whether it is present at least s (support) times New in PCY

Observations about Buckets Observation: If a bucket contains a frequent pair, then the bucket is surely frequent However, even without any frequent pair, a bucket can still be frequent  So, we cannot use the hash to eliminate any member (pair) of a “frequent” bucket But, for a bucket with total count less than s, none of its pairs can be frequent  Pairs that hash to this bucket can be eliminated as candidates (even if the pair consists of 2 frequent items) Pass 2: Only count pairs that hash to frequent buckets

PCY Algorithm – Between Passes Replace the buckets by a bit-vector: 1 means the bucket count exceeded the support s (call it a frequent bucket); 0 means it did not 4-byte integer counts are replaced by bits, so the bit-vector requires 1/32 of memory Also, decide which items are frequent and list them for the second pass

PCY Algorithm – Pass 2 Count all pairs {i, j} that meet the conditions for being a candidate pair: Both i and j are frequent items The pair {i, j} hashes to a bucket whose bit in the bit vector is 1 (i.e., a frequent bucket) Both conditions are necessary for the pair to have a chance of being frequent

Main-Memory: Picture of PCY Hash table Item counts Frequent items Bitmap Hash table for pairs Counts of candidate pairs Main memory Why hash table takes full space? We want to make it as large as possible. Why hash table bigger than bitmap? Hash table contains counts Pass 1 Pass 2

Frequent Itemsets in < 2 Passes A-Priori, PCY, etc., take k passes to find frequent itemsets of size k Can we use fewer passes? Use 2 or fewer passes for all sizes, but may miss some frequent itemsets Random sampling SON (Savasere, Omiecinski, and Navathe) Toivonen (see textbook)

Random Sampling (1) Take a random sample of the market baskets Run a-priori or one of its improvements in main memory So we don’t pay for disk I/O each time we increase the size of itemsets Reduce support threshold proportionally to match the sample size Copy of sample baskets Main memory Space for counts

Random Sampling (2) Optionally, verify that the candidate pairs are truly frequent in the entire data set by a second pass (avoid false positives) But you don’t catch sets frequent in the whole but not in the sample Smaller threshold, e.g., s/125, helps catch more truly frequent itemsets But requires more space

SON Algorithm – (1) Repeatedly read small subsets of the baskets into main memory and run an in-memory algorithm to find all frequent itemsets Note: we are not sampling, but processing the entire file in memory-sized chunks An itemset becomes a candidate if it is found to be frequent in any one or more subsets of the baskets.

SON Algorithm – (2) On a second pass, count all the candidate itemsets and determine which are frequent in the entire set Key “monotonicity” idea: an itemset cannot be frequent in the entire set of baskets unless it is frequent in at least one subset.

SON – Distributed Version SON lends itself to distributed data mining Baskets distributed among many nodes Compute frequent itemsets at each node Distribute candidates to all nodes Accumulate the counts of all candidates

Lecture outline Task 1: Methods for finding all frequent itemsets efficiently Task 2: Methods for finding association rules efficiently 58

Definition: Association Rule Let D be database of transactions e.g.: Let I be the set of items that appear in the database, e.g., I={A,B,C,D,E,F} A rule is defined by X  Y, where XI, YI, and XY= e.g.: {B,C}  {A} is a rule Transaction ID Items 2000 A, B, C 1000 A, C 4000 A, D 5000 B, E, F 59

Definition: Association Rule An implication expression of the form X  Y, where X and Y are non-overlapping 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 Example: 60

Rule Measures: Support and Confidence Customer buys both Customer buys diaper Find all the rules X  Y with minimum confidence and support support, s, probability that a transaction contains {X  Y} confidence, c, conditional probability that a transaction having X also contains Y Customer buys beer Let minimum support 50%, and minimum confidence 50%, we have A  C (50%, 66.6%)‏ C  A (50%, 100%)‏ TID Items 100 A,B,C 200 A,C 300 A,D 400 B,E,F 61

Example What is the support and confidence of the rule: {B,D}  {A} TID date items_bought 100 10/10/99 {F,A,D,B} 200 15/10/99 {D,A,C,E,B} 300 19/10/99 {C,A,B,E} 400 20/10/99 {B,A,D} What is the support and confidence of the rule: {B,D}  {A} Support: percentage of tuples that contain {A,B,D} = 75% Confidence: 100% 62

Association-rule mining task Given a set of transactions D, the goal of association rule mining is to find all rules having support ≥ minsup threshold confidence ≥ minconf threshold 63

Brute-force algorithm for association-rule mining List all possible association rules Compute the support and confidence for each rule Prune rules that fail the minsup and minconf thresholds  Computationally prohibitive! 64

Computational Complexity Given d unique items in I: Total number of itemsets = 2d Total number of possible association rules: If d=6, R = 602 rules

Mining Association Rules Example of Rules: {Milk,Diaper}  {Beer} (s=0.4, c=0.67) {Milk,Beer}  {Diaper} (s=0.4, c=1.0)‏ {Diaper,Beer}  {Milk} (s=0.4, c=0.67)‏ {Beer}  {Milk,Diaper} (s=0.4, c=0.67) {Diaper}  {Milk,Beer} (s=0.4, c=0.5) {Milk}  {Diaper,Beer} (s=0.4, c=0.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 66

Mining Association Rules Two-step approach: Frequent Itemset Generation Generate all itemsets whose support  minsup Rule Generation Generate high confidence rules from each frequent itemset, where each rule is a binary partition of a frequent itemset 67

Rule Generation – Naive algorithm Given a frequent itemset X, find all non-empty subsets y X such that y X – y 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 |X| = k, then there are 2k – 2 candidate association rules (ignoring L   and   L)‏ 68

Efficient rule generation How to efficiently generate rules from frequent itemsets? In general, confidence does not have an anti-monotone 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 Example: X = {A,B,C,D}: c(ABC  D)  c(AB  CD)  c(A  BCD)‏ Why? Confidence is anti-monotone w.r.t. number of items on the RHS of the rule 69

Rule Generation for Apriori Algorithm Lattice of rules Pruned Rules Low Confidence Rule 70

Example – 1984 Voting Records

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

Application of Interestingness Interestingness Measures

Statistical-based Measures Measures that take into account statistical dependence Lift & Interest are equivalent in the case of binary variables

Statistical Independence Population of 1000 students 600 students know how to swim (S) 700 students know how to bike (B) 420 students know how to swim and bike (S,B) P(SB) = 420/1000 = 0.42 P(S)  P(B) = 0.6  0.7 = 0.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

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 Apriori-style support based pruning? How does it affect these measures?

Computing Interestingness Given a rule X  Y, information needed to compute rule interestingness can be obtained from a contingency table Contingency table for X  Y Y X f11 f10 f1+ f01 f00 fo+ f+1 f+0 |T| f11: support of X and Y f10: support of X and Y f01: support of X and Y f00: support of X and Y Used to define various measures support, confidence, lift, Gini, J-measure, etc.

Drawback of Confidence Coffee Tea 15 5 20 75 80 90 10 100 Association Rule: Tea  Coffee Confidence= P(Coffee|Tea) = 0.75 but P(Coffee) = 0.9 Although confidence is high, rule is misleading P(Coffee|Tea) = 0.9375 Knowing a person is a Tea drinker actually lessons prob. that they are a coffee drinker