Association Rule Mining
Association Rule Mining
Association Rule Mining
patterns and
associations
Introduction
Syllabus
Market Basket Analysis,
Frequent Item sets,
Closed Item sets and Association Rule,
Frequent Pattern Mining,
Apriori Algorithm,
Association Rule Generation,
Improving the Efficiency of Apriori,
Mining Frequent Itemsets without candidate
generation,
Introduction to Mining Multilevel Association Rules
and Mining Multidimensional Association Rules.
Affinity Analysis
Affinity analysis
falls under the
umbrella term of
data mining which
uncovers
meaningful
correlations
between different
entities according to
their co-occurrence
in a data set.
Affinity analysis
Key Features
Completeness: find all rules.
No target item(s) on the right-hand-side
Mining with data on hard disk (not in memory)
t1: Beef, Chicken, Milk
An example t2: Beef, Cheese
t3: Cheese, Boots
t4: Beef, Chicken, Cheese
t5: Beef, Chicken, Clothes, Cheese, Milk
Transaction data t6: Chicken, Clothes, Milk
t7: Chicken, Milk, Clothes
Assume:
minsup = 30%
minconf = 80%
An example frequent itemset:
{Chicken, Clothes, Milk} [sup = 3/7]
Association rules from the itemset:
Clothes Milk, Chicken [sup = 3/7, conf = 3/3]
… …
Clothes, Chicken Milk, [sup = 3/7, conf = 3/3]
Transaction data representation
Basic concepts
Apriori algorithm
Different data formats for mining
Mining with multiple minimum supports
Mining class association rules
Summary
The Apriori algorithm
Probably the best known algorithm
Two steps:
Find all itemsets that have minimum support
(frequent itemsets, also called large itemsets).
Use frequent itemsets to generate rules.
AB AC AD BC BD CD
A B C D
The Algorithm
Iterative algo. (also called level-wise search):
Find all 1-item frequent itemsets; then all 2-item
frequent itemsets, and so on.
In each iteration k, only consider itemsets that
contain some k-1 frequent itemset.
Find frequent itemsets of size 1: F1
From k = 2
Ck = candidates of size k: those itemsets of size k
that could be frequent, given Fk-1
Fk = those itemsets that are actually frequent, Fk
Ck (need to scan the database once).
Dataset T
Example – minsup=0.5
TID Items
T100 1, 3, 4
Finding frequent itemsets T200 2, 3, 5
T300 1, 2, 3, 5
T400 2, 5
itemset:count
1. scan T C1: {1}:2, {2}:3, {3}:3, {4}:1, {5}:3
F1: {1}:2, {2}:3, {3}:3, {5}:3
C2: {1,2}, {1,3}, {1,5}, {2,3}, {2,5}, {3,5}
2. scan T C2: {1,2}:1, {1,3}:2, {1,5}:1, {2,3}:2, {2,5}:3, {3,5}:2
F2: {1,3}:2, {2,3}:2, {2,5}:3, {3,5}:2
C3: {2, 3,5}
3. scan T C3: {2, 3, 5}:2 F3: {2, 3, 5}
Details: ordering of items
After join
C4 = {{1, 2, 3, 4}, {1, 3, 4, 5}}
After pruning:
C4 = {{1, 2, 3, 4}}
because {1, 4, 5} is not in F3 ({1, 3, 4, 5} is removed)
Step 2: Generating rules from frequent
itemsets
Frequent itemsets association rules
One more step is needed to generate
association rules
For each frequent itemset X,
For each proper nonempty subset A of X,
Let B = X - A
A B is an association rule if
Confidence(A B) ≥ minconf,
Basic concepts
Apriori algorithm
Different data formats for mining
Mining with multiple minimum supports
Mining class association rules
Summary
Different data formats for mining
The data can be in transaction form or table
form
Transaction form: a, b
a, c, d, e
a, d, f
Table form: Attr1 Attr2 Attr3
a, b, d
b, c, e
Table data need to be converted to
transaction form for association mining
From a table to a set of transactions
Table form: Attr1 Attr2 Attr3
a, b, d
b, c, e
Transaction form:
(Attr1, a), (Attr2, b), (Attr3, d)
(Attr1, b), (Attr2, c), (Attr3, e)
Basic concepts
Apriori algorithm
Different data formats for mining
Mining with multiple minimum supports
Mining class association rules
Summary
Problems with the association mining
Single minsup: It assumes that all items in
the data are of the same nature and/or
have similar frequencies.
Not true: In many applications, some items
appear very frequently in the data, while
others rarely appear.
E.g., in a supermarket, people buy food processor
and cooking pan much less frequently than they
buy bread and milk.
Rare Item Problem
If the frequencies of items vary a great deal,
we will encounter two problems
If minsup is set too high, those rules that involve
rare items will not be found.
To find rules that involve both frequent and rare
items, minsup has to be set very low. This may
cause combinatorial explosion because those
frequent items will be associated with one another
in all possible ways.
Multiple minsups model
The minimum support of a rule is expressed in
terms of minimum item supports (MIS) of the items
that appear in the rule.
Each item can have a minimum item support.
By providing different MIS values for different
items, the user effectively expresses different
support requirements for different rules.
Minsup of a rule
Basic concepts
Apriori algorithm
Different data formats for mining
Mining with multiple minimum supports
Mining class association rules
Summary
Mining class association rules (CAR)
Normal association rule mining does not have
any target.
It finds all possible rules that exist in data, i.e.,
any item can appear as a consequent or a
condition of a rule.
However, in some applications, the user is
interested in some targets.
E.g, the user has a set of text documents from
some known topics. He/she wants to find out what
words are associated or correlated with each topic.
Problem definition
Let T be a transaction data set consisting of n
transactions.
Each transaction is also labeled with a class y.
Let I be the set of all items in T, Y be the set of all
class labels and I Y = .
A class association rule (CAR) is an implication of
the form
X y, where X I, and y Y.
The definitions of support and confidence are the
same as those for normal association rules.
An example
A text document data set
doc 1: Student, Teach, School : Education
doc 2: Student, School : Education
doc 3: Teach, School, City, Game : Education
doc 4: Baseball, Basketball : Sport
doc 5: Basketball, Player, Spectator : Sport
doc 6: Baseball, Coach, Game, Team : Sport
doc 7: Basketball, Team, City, Game : Sport
Let minsup = 20% and minconf = 60%. The following are two
examples of class association rules:
Student, School Education [sup= 2/7, conf = 2/2]
game Sport [sup= 2/7, conf = 2/3]
Mining algorithm
Unlike normal association rules, CARs can be mined
directly in one step.
The key operation is to find all ruleitems that have
support above minsup. A ruleitem is of the form:
(condset, y)
where condset is a set of items from I (i.e., condset
I), and y Y is a class label.
Each ruleitem basically represents a rule:
condset y,
The Apriori algorithm can be modified to generate
CARs
Multiple minimum class supports
The multiple minimum support idea can also be
applied here.
The user can specify different minimum supports to
different classes, which effectively assign a different
minimum support to rules of each class.
For example, we have a data set with two classes,
Yes and No. We may want
rules of class Yes to have the minimum support of 5% and
rules of class No to have the minimum support of 10%.
By setting minimum class supports to 100% (or
more for some classes), we tell the algorithm not to
generate rules of those classes.
This is a very useful trick in applications.
Road map
Basic concepts
Apriori algorithm
Different data formats for mining
Mining with multiple minimum supports
Mining class association rules
Summary
Summary
Association rule mining has been extensively studied
in the data mining community.
There are many efficient algorithms and model
variations.