Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 59

Measuring Association Rule Performance

Recommended resources

Welcome to the next module in our course. In the previous lessons, we focused on supervised classification algorithms, culminating in building a decision tree to predict outcomes based on a series of explicit rules. We now pivot from prediction to discovery, entering the realm of unsupervised learning where the goal is to find inherent structures and patterns within the data itself.

This lesson introduces you to Association Rule Mining, a technique you described as formalizing "subconscious action." Its purpose is to uncover relationships between items in large datasets. Your objective for this lesson is to calculate the support, confidence, and lift for a given association rule from a set of transactions. These three metrics are the cornerstone of evaluating the strength and significance of any pattern you discover.

Understanding Association Rules

At its core, association rule mining is about finding "if-then" patterns. The classic example is "market basket analysis," where a retailer might find that "if a customer buys bread and butter, then they also tend to buy milk." These rules are expressed in the form , where is the "if" part (antecedent) and is the "then" part (consequent).

The data for this analysis is typically in a transactional format, where each transaction is a collection of items. This could be items in a shopping cart, activities on a given day, or characteristics of a single client visit.

A simple table of transactional data. Each `CustomerOrderID` represents a unique transaction, and the `Product` column lists the items within that transaction.

To determine if a rule is "interesting," we don't rely on guesswork. We quantify its properties using three key metrics: Support, Confidence, and Lift. A concise article from GeeksforGeeks provides the formal definitions we will use.

Association Rule - GeeksforGeeks

This article clearly defines the three fundamental metrics used to evaluate association rules. It provides the standard formulas and a simple numerical example that will anchor our calculations.

Please read the entire page. Focus on the section Rule Evaluation Metrics to understand the formulas for Support, Confidence, and Lift. Then, carefully review the example calculations for the rule \{ \text{Milk}, \text{Diaper} \} \rightarrow \{ \text{Beer} \}.

Let's summarize the roles of these three metrics:

  1. Support: This tells you how popular an itemset is. It's the fraction of all transactions that contain the itemset. A rule with low support might be statistically significant but applies to so few cases that it's not practically useful.

  2. Confidence: This measures the reliability or predictive power of the rule. It's the probability of finding in a transaction, given that it also contains .

  3. Lift: This measures how much more likely is to be purchased when is purchased, compared to its overall popularity. It quantifies the "interestingness" of the rule by correcting for the baseline frequency of the consequent.

    • Lift > 1: Positive correlation. The items appear together more often than expected by chance.
    • Lift = 1: No correlation. The items are independent.
    • Lift < 1: Negative correlation. The items appear together less often than expected.

Now, let's apply these calculations to our two scenarios.


Application 1: Bra-Fitting Business Product Associations

Let's analyze your sales data to discover which products are frequently bought together. This can inform product placement, marketing bundles, and recommendations.

Consider the following 10 transactions from your business:

Transaction ID Items Purchased
1 Plunge Bra, Strapless Bra, Fitting Service
2 Balconette Bra, Fitting Service
3 Plunge Bra, Nipple Covers
4 Strapless Bra, Fitting Service, Nipple Covers
5 Plunge Bra, Balconette Bra
6 Plunge Bra, Fitting Service, Nipple Covers
7 Balconette Bra, Nipple Covers
8 Plunge Bra, Strapless Bra
9 Plunge Bra, Fitting Service
10 Strapless Bra, Fitting Service

Let's investigate the rule: Fitting Service Nipple Covers. This rule asks: "When a customer pays for a fitting service, are they also likely to buy nipple covers?"

Here, and .

1. Calculate Support Counts:

  • Total number of transactions = 10.
  • Count of transactions containing (Fitting Service): Transactions 1, 2, 4, 6, 9, 10. So, .
  • Count of transactions containing (Nipple Covers): Transactions 3, 4, 6, 7. So, .
  • Count of transactions containing both and : Transactions 4, 6. So, .

2. Calculate the Metrics:

  • Support ():

    Interpretation: The combination of a fitting service and nipple covers appears in 20% of all sales.

  • Confidence ():

    Interpretation: 33.3% of customers who purchase a fitting service also buy nipple covers in the same transaction.

  • Lift ():

    Interpretation: A lift less than 1 indicates a negative association. Customers are actually less likely to buy nipple covers with a fitting service than they are to buy nipple covers in general. This rule is not interesting and may even suggest that the fitting service addresses issues that nipple covers are used for, making the covers redundant.


Application 2: Intimacy Management in a Polyandrous Relationship

Now, we'll apply the same metrics to your research on relationship dynamics. Here, a "transaction" is a recorded significant interaction or event, and the "items" are the participants and key activities that occurred.

Consider the following 10 recorded events:

Event ID Participants & Activities Recorded
1 Hinge, Partner A, Intimacy, Deep Conversation
2 Hinge, Partner B, Shared Meal
3 Hinge, Partner A, Shared Meal
4 Hinge, Partner B, Intimacy, Conflict
5 Hinge, Partner A, Partner B, Shared Meal
6 Hinge, Partner A, Intimacy, Shared Meal
7 Hinge, Partner B, Intimacy, Deep Conversation
8 Hinge, Partner A, Deep Conversation
9 Hinge, Partner A, Intimacy, Shared Meal
10 Hinge, Partner B, Shared Meal

Let's investigate the rule: . This rule asks: "When an event involves Partner A and intimacy, does it also tend to involve a shared meal?"

Here, and .

1. Calculate Support Counts:

  • Total number of events = 10.
  • Count of events containing (Partner A AND Intimacy): Events 1, 6, 9. So, .
  • Count of events containing (Shared Meal): Events 2, 3, 5, 6, 9, 10. So, .
  • Count of events containing both and : Events 6, 9. So, .

2. Calculate the Metrics:

  • Support ():

    Interpretation: The combination of Partner A, intimacy, and a shared meal occurs in 20% of all recorded events.

  • Confidence ():

    Interpretation: In 66.7% of events that include Partner A and intimacy, a shared meal also takes place. This indicates a fairly reliable pattern.

  • Lift ():

    Interpretation: A lift of 1.11 (which is > 1) signifies a positive association. The occurrence of a shared meal is about 11% more likely when Partner A and intimacy are involved than would be expected if the events were independent. This suggests a subtle but real connection, perhaps indicating that sharing a meal is a common post-intimacy activity for this dyad.


Conclusion

In this lesson, you've learned to quantify the strength and interest of associations within transactional data. By calculating support, confidence, and lift, you can move beyond simple observation to rigorously evaluate the patterns that emerge from your data, whether in commerce or in human relationships.

Key Takeaways:

  • Support measures the overall frequency of an itemset.
  • Confidence measures the conditional probability of a rule being correct.
  • Lift measures how much more likely the items are to co-occur than by random chance, making it a powerful tool for identifying truly significant relationships.

Today, we manually calculated these metrics for a pre-defined rule. But in a real dataset, how do you efficiently find the most promising rules to begin with? You can't test every possible combination. The next lesson will address this by introducing the Apriori principle, an elegant algorithm for systematically identifying all frequent itemsets in a dataset, which is the foundational step for generating strong association rules.