Saturday, 23 June 2018

Recommendation System I

Market Basket Analysis/  Apriori Algorithm

Social media evolution has increased the scope of business, but what ultimately it’s basic math and science which came out as winner to enhance what technology is providing us, Success of Data Science industry is a result of that.

Let’s take a tour at the simplest recommendation and association system in Data Science and Machine Learning, how it enables us to sell more.


Association Rules are part of data mining for long, but the real popularity came with following famous story broke.

A very well known store was looking to increase the sales and found out one of the most nonidentical things getting sold together, e.g on afternoon the sales of diapers went together with beer most of the times, the reason was the working fathers sent to market by their wives to get baby things and since its after work and one is already tired and need some sleep so probably beer, boom , once could never have thought about this.

The idea is to find these uncommon patterns and combinations with the audiences and playing with the mind for advantages, works in the music stores, product sellers, small business and marketing.

Here is another point of view, either you can put the products together or you can separate them e.g bread and bread have huge probability of selling together , so keep them apart in store and let customer see other things meanwhile searching for them , chances of selling in creases.

Maths at background

The basic challenge is  understanding the combination of the items based on what others have already bought and seeing what combination will increase business,  suppose we had 10 users in my store.

The ulterior motive is obviously is to sell more and we use 3 metricsto calculate what should we recommend to the person who buys item from us.

For my set , answer is if we keep beer with cigarettes, there are chances to sell beer 34% more than selling it alone, which means every 3 cigarettes selling you could sell one beer , which looks good but it depends on data set ,and numerous other conditions as well. May be the one I prepared is taken on a Friday or Saturday evening .

The point is if your data is correct you are good to go.

Algorithm and Code Flow (R)

Now let’s see how we can understand the algorithm flow. This includes three step process of making the combinations.

Step 1: You need to set up a minimum support,which means the items which are getting bought together some more , we obviously do not want all combinations .We will set up a limit while coding which means the objects above a threshold of occurrence together should be seen forming a rule.

Step 2: Take all rules and select the one with a threshold of confidence higher than minimum, again mathematically confidence gives us a possibility of Y to happen when X has happened, so we may want to maximize the possibility of certain percentage i.e maybe 40% or more chances to filter out the best possible rules

Step 3: Arrange the data in descending order of lift to get yourself the best rules to sell X more.

  • Obvious in stores selling grocery, music stores and enterprise software solutions.
  •  Friends suggestions on social media (however they incorporate a lot of other  sophisticated  algorithms as well, we will try to uncover them in next posts)
  •  Product suggestions for e commerce.
  • Brand placements and marketing.

Following articles on recommendation

Let me know your thoughts.


Post a comment