Machine Learning II:
Association Rules and Recommendation
Patrick Hall
Visiting Faculty, Department of Decision Sciences
George Washington University
Lecture 11 Agenda
Where are we in the modeling lifecycle?
Data Collection �& ETL
Feature Selection & Engineering
Supervised�Learning
Unsupervised�Learning
Deployment
Cost Intensive
Revenue
Generating
Assessment & Validation
Association Rules
Overview
Rule Evaluation Metrics
Overview: Association Rules
Source: Introduction to Data Mining
Mining Association Rules
Two-step approach:
Frequent itemset generation is computationally expensive!
Source: Introduction to Data Mining
Association Rules 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.
Source: Introduction to Data Mining
Market-Basket Transactions
Examples of Association Rules:
Implication means co-occurrence, not causality!
Terms and Definitions
Source: Introduction to Data Mining
Rule Evaluation Metrics
Source: Introduction to Data Mining
Example:
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:
Source: Introduction to Data Mining
Probability that the two itemsets in a rule occur together.
Itemset: {KLYT6, IA45Y}
Rule: {KLYT6} → {IA45Y}
KLYT6 and IA45Y both occur together in ⅘ transactions
(KLYT6 and IA45Y) / |T|
s = 0.8
Support is symmetric:
s({KLYT6} → {IA45Y}) = s({IA45Y} → {KLYT6})
Rule Evaluation Metrics: Support
| | | |
| Transaction ID | Product ID | |
| 11231 | IA45Y | |
| 11231 | DDD7M | |
| 11231 | BDR5U0 | |
| 11231 | KLYT6 | |
| 11232 | TTR45H | |
| 11232 | HJL9B | |
| 11232 | DDD7M | |
| 11232 | IA45Y | |
| 11232 | BDR5U0 | |
| 11232 | KLYT6 | |
| 11233 | KLYT6 | |
| 11233 | IA45Y | |
| 11233 | DDD7M | |
| 11234 | KLYT6 | |
| 11234 | BDR5U0 | |
| 11235 | DDD7M | |
| 11235 | KLYT6 | |
| 11235 | BDR5U0 | |
| 11235 | IA45Y | |
| | | |
Conditional probability of a transaction containing itemset Y given that it contains itemset X.
Rule: {KLYT6} → {IA45Y}
⅘ of the transactions that contains KLYT6 (X)
also contains IA45Y (Y)
(KLYT6 and IA45Y) / {KLYT6}
c = 0.8
Rule Evaluation Metrics: Confidence
| | | |
| Transaction ID | Product ID | |
| 11231 | IA45Y | |
| 11231 | DDD7M | |
| 11231 | BDR5U0 | |
| 11231 | KLYT6 | |
| 11232 | TTR45H | |
| 11232 | HJL9B | |
| 11232 | DDD7M | |
| 11232 | IA45Y | |
| 11232 | BDR5U0 | |
| 11232 | KLYT6 | |
| 11233 | KLYT6 | |
| 11233 | IA45Y | |
| 11233 | DDD7M | |
| 11234 | KLYT6 | |
| 11234 | BDR5U0 | |
| 11235 | DDD7M | |
| 11235 | KLYT6 | |
| 11235 | BDR5U0 | |
| 11235 | IA45Y | |
| | | |
Proportion of transactions that contains the itemset in Y given that X and Y are independent.
Rule: {KLYT6} → {IA45Y}
⅘ of the transactions that contains IA45Y
IA45Y / |T|
E[c] = 0.8
Rule Evaluation Metrics: Expected Confidence
| | | |
| Transaction ID | Product ID | |
| 11231 | IA45Y | |
| 11231 | DDD7M | |
| 11231 | BDR5U0 | |
| 11231 | KLYT6 | |
| 11232 | TTR45H | |
| 11232 | HJL9B | |
| 11232 | DDD7M | |
| 11232 | IA45Y | |
| 11232 | BDR5U0 | |
| 11232 | KLYT6 | |
| 11233 | KLYT6 | |
| 11233 | IA45Y | |
| 11233 | DDD7M | |
| 11234 | KLYT6 | |
| 11234 | BDR5U0 | |
| 11235 | DDD7M | |
| 11235 | KLYT6 | |
| 11235 | BDR5U0 | |
| 11235 | IA45Y | |
| | | |
Confidence of the rule divided by the
expected confidence.
Rule: {KLYT6} → {IA45Y}
Lift = 0.8/0.8 = 1
Lift can be interpreted as a measure of association between the two itemsets. Values greater than 1 indicates positive correlation, values equal to 1 indicates zero correlation, and values less than 1 indicate negative correlation.
Rule Evaluation Metrics: Lift
| | | |
| Transaction ID | Product ID | |
| 11231 | IA45Y | |
| 11231 | DDD7M | |
| 11231 | BDR5U0 | |
| 11231 | KLYT6 | |
| 11232 | TTR45H | |
| 11232 | HJL9B | |
| 11232 | DDD7M | |
| 11232 | IA45Y | |
| 11232 | BDR5U0 | |
| 11232 | KLYT6 | |
| 11233 | KLYT6 | |
| 11233 | IA45Y | |
| 11233 | DDD7M | |
| 11234 | KLYT6 | |
| 11234 | BDR5U0 | |
| 11235 | DDD7M | |
| 11235 | KLYT6 | |
| 11235 | BDR5U0 | |
| 11235 | IA45Y | |
| | | |
Market Basket Analysis
Overview
“Association” analysis typically refers to products that are used one-per-customer – like personal banking products. (I have one checking account and one savings account.)
“Market Basket” analysis typically refers to products that are used many-per-customer, like groceries or essential items. (I buy many groceries every week.)
Market Basket Analysis
A
B
C
A
C
D
B
C
D
A
D
E
B
C
E
Rule
A ⇒ D
C ⇒ A
A ⇒ C
B & C ⇒ D
Support
2/5
2/5
2/5
1/5
Confidence
2/3
2/4
2/3
1/3
Source: Introduction to Pattern Discovery & SAS Institute
Barbie Doll ⇒ Candy
Introduction to the Pattern Discovery & SAS Institute
Association Recommendation
Interlude
Supervised Rule-based Models
Supervised Rule-based Models
Many interesting options exist for supervised classification with rule-based models, that are often highly interpretable. Popular approaches include:
A description of Skope rules.
Scalable Bayesian Rulelist
Source: Scalable Bayesian Rule Lists
Recommendations
Netflix Case
The Netflix Prize
The Analytics Edge, MIT
Predicting the Best User Rating
Source: The Analytics Edge, MIT
Using Other User’s Rankings
Source: The Analytics Edge, MIT
| Men in Black | Apollo 13 | Top Gun | Terminator |
Amy | 5 | 4 | 5 | 4 |
Bob | 3 | | 2 | 5 |
Carl | | 5 | 4 | 4 |
Dan | 4 | 2 | | |
Using Move Information
This technique is called Content Filtering
We saw that Amy liked “Men In Black”
Consider recommending to Amy:
Source: The Analytics Edge, MIT
Strengths and Weakness
Collaborative Filtering Systems:�
Content Filtering:�
Source: The Analytics Edge, MIT
Hybrid Recommendation Systems
Source: The Analytics Edge, MIT
Recommendation Method Used
Collaborative Filtering:
Content Filtering:
Source: The Analytics Edge, MIT
Cornerstone of these Well-known Businesses
Source: The Analytics Edge, MIT
TM
TM
TM
TM
TM
TM
The Edge of Recommendation Systems
The Analytics Edge, MIT
Reading