E-commerce analytics: Product Recommendation Engines

Have you ever came across a business offering you more when you have already purchased one product or service. I get offers even from my hairdresser. Saloons offering head massage or facial when you go for a hair-cut. Many times, offers get converted to revenue for saloons. This is a perfect daily life example of product/service recommendations. We could see such relevant offers more when we purchase products online from Amazon, Flipkart etc.

One of the premier examples of product recommender is a contest organised by Netflix with prize money of $1,00,000. One can easily get an idea about business benefit Netflix might have earned by paying a huge amount as prize money for improving their movie recommendation engine.


In layman terms, the outcome of this technique is a simple set of product/service rules based on customer product purchasing behaviour. e.g. if a customer bought milk, then will he is going to buy eggs too? In this data analytics technique, what is being purchased with what is been analysed? Is buying one specific item increases chances of buying other items? We will explore business grocery dataset to get such answers.

Product recommendation engines are also known by few other names such as Apriori Algorithm, Affinity Analysis, Association rules, Market basket analysis. We will not go in technical details of how it will work in this blog. The objective is to make aware smaller & medium organisations about the topic & how it adds value to the business.

Why is this technique useful?

Acquiring a new customer is always costly for any business than keeping an existing customer. By this technique, businesses can increase revenue from the existing customers on the basis of customer product buying rules. Product & services up-selling, cross-selling can be one of the very intuitive use cases of basket analysis. In addition to this product combos, shop floor/website layout can also be suggested accordingly. Last but not least, products can be suggested based on real-time purchasing behaviour.

Technical Definitions

Here is the basic technical terms useful in this analysis are as below

  • Support: The fraction of which our itemset occurs in our dataset.
  • Confidence: Probability that a rule is correct for a new transaction with items on the left.
  • Lift: The ratio by which by the confidence of a rule exceeds the expected confidence.
    Note: if the lift is 1 it indicates that the items on the left and right are independent.

Do not worry if these terms goes off your head. You will get over them soon!

R shiny playground

R shiny toy product has been used for the demonstration purposes. R — an open source tool can easily be downloadable from cran website if you want to learn more about it, but it is not required for this demo purpose. We had used R package called ‘arules’ from Michael Hahsler who has implemented this algorithm in R. There’s a public data of buying records in a grocery store which will be used for this exercise using Shiny Demo App.

How to play with R shiny Demo product

Step 1: Open R Shiny App

Step 2: Upload grocery dataset public data (If you have your own dataset, make sure to change format as per sample dataset)

Step 3: Select input data features

a) Unselect header as provided dataset does not contain header ( if your dataset has header, please select accordingly)

b) Select space separator as sample dataset having space separation.

c) Keep all default values as it for now if you find them too technical.

Step 4: Explore shiny app tabs such as top 25 item frequency, basket analysis rules, sorting rules option e.g lift, support etc.

Step 5: Find out specific product rules e.g select beer from select product drop down. All the product rules for selected product will be displayed under product combo check. This feature can be used for creating specific product combos.

Step 6 (Optional): if you understand technical terms mentioned above, try to play with them to see the affect on rules

Conclusion & business scope

Is n’t it amazing! How a very simple analytical technique can provide what customer might need to add to the cart real time. This is very basic toy example of product recommendations based on arules algorithm. Advanced recommender engines make use of other data points from customer behaviour in addition to advanced algorithms such as factorisation machines, collaborative filtering etc. Now you can fairly co-relate how amazon recommends different products. Any small business can make use of this technique to add value to business in some of the other ways:

  • Product combos suggestions for marketing campaign.
  • Website or store layout re-alignment e.g if eggs bought with milk, re-organise accordingly
  • Product cross-selling, real time web/App product recommendations.

We here at DataToBiz with team of machine learning experts can support your business to solve problems by providing affordable machine learning platform on your business data. Contact Us for more info.

Become a Data Driven Leader

Learn how our experts can help

Explore Possibilities


  1. Pingback: Nevin Manimala
  2. Pingback: Steven K. Martinez

Leave a Reply

Your email address will not be published. Required fields are marked *