Market Basket Analysis - Interpretation of mirrored association rules I have performed Market Basket Analysis on sales data, that comes from non-sequential receipts. I've read into the meaning of the different metrics, but there is one thing I don't understand. When looking at the strongest association rules, I detect a lot of mirrored rules. For example:

I'm not sure how to interpret this. Looking at confidence, it seems that people are more likely to buy pie, and then buy a cup of coffee. But how is this determined? We're talking about the same products, and my assumption would be identical values for all metrics for both rules. How can it be calculated that pie is more likely to lead to coffee, and less so the other way around? The support and lift are equal and any kind of order is not maintained when analyzing the products on receipts.
 A: The confidence for a rule $A \Rightarrow C$ with antecedent $A$ and consequent $C$ is the conditional probability $P(C|A)$ for a customer to purchase product $C$ given that they purchased product $A$. This is not a statement about whether the purchase for product $C$ is likely to occur after a purchase for product $A$ in time, but rather a statement about whether customers purchase these products together.
The confidence for the rule $C \Rightarrow A$ is related to the confidence for the mirror rule $A \Rightarrow C$ by Bayes theorem:
$$
P(C|A) = P(A|C) \frac{P(C)}{P(A)}
$$
So, the confidence for these two mirror rules is related by the ratio of the probability of purchase for products $A$ and $C$. The example that you provided suggests that purchases for coffee are about twice as likely as purchases for pie:
$$
\frac{P(\mathrm{Coffee}|\mathrm{Pie})}{P(\mathrm{Pie}|\mathrm{Coffee})} = \frac{P(\mathrm{Coffee})}{P(\mathrm{Pie})} = \frac{0.46}{0.24}
$$
The other metrics that you are measuring can be defined as follows:

*

*Antecedent support: $P(A)$

*Consequent support: $P(C)$

*Support: $P(A, C)$

*Confidence: $P(C|A)$

*Lift: $\frac{P(A, C)}{P(A)P(C)}$

*Leverage: $P(A, C) - P(A)P(C)$

*Conviction: $\frac{1 - P(C)}{1 - P(C|A)}$
Amongst these metrics, the Support, Lift, and Leverage are symmetric with respect to interchange of the two products $A \leftrightarrow C$, so we would expect those metrics to be the same for the rule and its mirror rule. On the other hand the Confidence and the Conviction are not symmetric with respect to interchange of the two products, so we would not expect those metrics to be the same for the rule and its mirror rule.
A: The existing answer explains how the table is calculated. If you are still confused, one way to look at it is to start with the number of people who bought things.
Say 100 people visited the cafe, and 36 bought coffee, 18 bought pie, and 8 bought both. Then this is how the numbers in your table are calculated, using the formulas given by b-r-oleary:




P(A)
P(C)
P(A,C)
P(C|A)
P(A,C)/P(A)P(C)
P(A,C)-P(A)P(C)
(1-P(C))/(1-P(C|A))




36/100
18/100
8/100
8/36
100 x 8/(18x36)
8/100 - (18/100)(36/100)
(1-18/100)/(1-8/36)


18/100
36/100
8/100
8/18
100 x 8/(18x36)
8/100 - (36/100)(18/100)
(1-36/100)/(1-8/18)




Out of 18 people who bought pie, 8 also bought coffee, so the confidence is 8/18. But out of 36 people who bought coffee, only 8 also bought pie, so the confidence is 8/36.
The numbers in bold are the ones which aren't necessarily equal. This is just a consequence of how they are defined. The names "support", "lift" etc. are just names, which hopefully hint at how the numbers should be interpreted.
