Finding relationship among items using Association Rule
Association Rule is a rule based machine learning algorithm. It is a great way to find how things relate to each other, the easiest example we see is among food items like milk, bread and eggs. That example answers a simple question for a business, that is how to increase their sales plus make life easier for their customers.
This solution helps in lot of ways in different industries. Let us see how this problem answers the above question, which will help us to know how we can implement this methodology in our business.
Take the following table as a given dataset, where each row shows the shopping done by each customer at some ABC store.
Bread, Milk, Eggs, Coke
Bread, Yogurt, Ice Cream
Milk, Eggs, Snickers
Chips, Bread, Eggs, Milk, Ketchup
Egg, Bread, Cheese, Potatoes
Definitions we need to know before applying Association Rule.
X implies to Y, X -> Y.
Support, Fraction of transactions that contains an itemset.
Confidence, Fraction of group of items that contains an itemset.
To find the percentage of customers buying bread along with Milk and Eggs we will use simple formula.
[Milk,Eggs] -> Bread (X -> Y)
Support: Total number of rows containing
X and Y / Total number of rows = 2 / 5 = 0.4 = 40 %
Confidence: Total number of rows containing
X and Y / Total number of rows containing X = 2 / 3 =0.666 = 66.6 %
66.6 percent customer who bought Milk and Eggs also bought Bread. This helps the store to analyze which items should be put together or near in the shelf space, also making it convenient for customers.
This methodology is not only applicable to shopping, it can be applied in wide variety of ways depending on the problem.
But this approach is computationally expensive as we must create all rules (equations). So, if you have a big dataset having large number of possible combinations of itemset and planning to implement this approach, you will have to see how Apriori Algorithm works, which I will explain in my next article.
The purpose of rewriting is to help beginners to learn in an easy way and to explore how it can be implemented to solve problems other than shopping.