Once the Apriori algorithm has identified frequent item sets, we can start mining association rules. Since we are focusing on item sets of size 2, the association rules will take the form{A} -> {B}
, where the purchase of item A implies a likelihood of item B being bought as well. This technique is commonly used in recommender systems to suggest products based on customers’ previous purchases.
Three key metrics for evaluating association rules are support, confidence, and lift. Let’s define each using our example.
- Support:
- This metric indicates the percentage of total orders that contain a particular item set.
- In our example, the set {apple, egg} appears in 3 out of 5 orders, giving
2. Confidence:
- This metric measures how often item B is purchased given that item A was purchased, calculated as:
For our example:
- Confidence of
apple -> egg
:
Here, 100% of orders containing egg
also contain apple
. Confidence can help determine the strength of an association, but it does not account for the popularity of both items.
3. Lift:
Lift measures the strength of a relationship between two items by comparing the observed co-occurrence with the expected co-occurrence if they were independent. It is directionless (i.e., lift from A to B equals lift from B to A) and is calculated as follows:
For {apple, egg}
, we calculate lift as:
The interpretation of lift values:
- Lift = 1: No relationship (items co-occur as expected by chance).
- Lift > 1: Positive relationship (items co-occur more often than by chance).
- Lift < 1: Negative relationship (items co-occur less often than by chance).
In our example, a lift of 1.25 suggests that apple
and egg
appear together 1.25 times more than if they were occurring independently, indicating a positive association.
In summary, Apriori and association rule mining help uncover valuable insights from transaction data. These metrics — support, confidence, and lift — offer meaningful ways to evaluate item relationships and can be used to drive recommendations and understand purchasing patterns.