Support
Support(A to B) = P(A and B)
= transactions with both / ALL transactions
First measure to compute. Says how widespread the pattern is, and therefore whether it is worth a business decision.
- both
- Count of transactions containing every item in the rule
- ALL
- Total number of transactions, the denominator that distinguishes support from confidence
Confidence
Confidence(A to B) = P(B | A)
= transactions with both / transactions with A
How reliable the rule is when the antecedent is present. Not symmetric: reversing the rule changes it.
- A
- The antecedent, the left-hand side
- transactions with A
- The conditioning denominator
Lift
Lift(A to B) = P(B | A) / P(B) = Confidence(A to B) / Support(B)
= P(A and B) / ( P(A) x P(B) ) <- shows it is symmetric
> 1 real association | = 1 independent | < 1 negative association
The ranking measure. Always sort rules by lift, then check the count before believing one.
- Support(B)
- The consequent's own frequency, the baseline being divided out
- symmetry
- Lift(A to B) = Lift(B to A), so lift cannot tell you which way to act
Apriori in R
rules <- apriori(trans, parameter = list(support = 0.005,
confidence = 0.3,
minlen = 2))
rules_sorted <- sort(rules, by = "lift", decreasing = TRUE)
inspect(head(rules_sorted, 10))
Generating rules in bulk. Minimum count for a rule = support x number of transactions.
- support
- Minimum fraction of baskets; 0.005 of 10,000 is 50 baskets
- confidence
- Minimum reliability; 0.3 means the rule must hold 30 % of the time
- minlen
- Minimum items in the rule; 2 excludes single-item results