Recommendation System


By EKbana on December 28, 2022

4m read
Recommender systems are one of the most successful and widespread applications of machine learning technologies in business. You can find large-scale recommender systems in retail, video-on-demand services, or music streaming services. To develop and maintain such systems, a company typically needs a group of experienced data scientists and engineers.

Building a recommendation system for a grocery store to find out what product a customer is going to purchase is quite complicated. In the case of this grocery store, the same customers can buy a different basket of products each time. In analyzing the cases to solve this problem in this recommendation system we cannot simply feed data into a machine-learning model for the recommendation. This recommendation system is not actually like other recommendation systems.

Data processing

4000 customers were selected who usually visit every month. With a higher number of visits, we could get a higher number of baskets from that customer. The data that was taken for the recommendation was the unique product in baskets in each specific transaction. There are more than 90 unique sections in the overall data. The association rule is applied in this system to identify the next section that is in the basket. The main reason to select this algorithm instead of other machine learning algorithms is to give priority to the customer choice that can be identified using past transactions and baskets. If this algorithm fails to identify the next section using the two combinations of the section then 5 similar customers are selected and the next section is identified using their baskets and transaction. The KNearest Neighbour algorithm is used to select similar customers.

Association Rule

Association rule mining is a technique to identify underlying relations between different items. Take the example of a Supermarket where customers can buy a variety of items. Usually, there is a pattern in what the customers buy. For instance, mothers with babies buy baby products such as milk and diapers. Damsels may buy makeup items whereas bachelors may buy beers and chips etc. In short, transactions involve a pattern. More profit can be generated if the relationship between the items purchased in different transactions can be identified.

For instance, if items A and B were bought together more frequently then several steps can be taken to increase the profit. For example:

  1. A and B can be placed together so that when a customer buys one of the products he doesn’t have to go far away to buy the other product.
  2. People who buy one of the products can be targeted through an advertisement campaign to buy the other.
  3. Collective discounts can be offered on these products if the customer buys both of them.
  4. Both A and B can be packaged together.

The process of identifying an association between products is called association rule mining.

KNearest Neighbour Algorithm

In pattern recognition, the k-nearest neighbors algorithm (k-NN) is a non-parametric method used for classification and regression. In both cases, the input consists of the k closest training examples in the feature space. The output depends on whether k-NN is used for classification or regression:

  1. In k-NN classification, the output is a class membership. An object is classified by a plurality vote of its neighbours, with the object being assigned to the class most common among its k nearest neighbours (k is a positive integer, typically small). If k = 1, then the object is simply assigned to the class of that single nearest neighbour.
  2. In k-NN regression, the output is the property value for the object. This value is the average of the values of k nearest neighbours.


  1. Two combinations of the section are given for specific customers.
  2. All the basket of that customer is extracted.
  3. Using Association rule find two sections with higher confidence.
  4. If the sections are found, the product from those sections is recommended, Otherwise, 5 similar customers are selected, and using the confidence from Association rule 2 sections are suggested.



Among 3000 customers almost 2000 customers scored more than 0 which means,

Score 0: No section matched

Score 1: 1 section matched

Score 3: 3 sections matched


Well, this recommender system result is appreciable as it guessed 70% of sections. This can be further optimized by understanding and analyzing section recommendations more.

Get post by email

Be the first to get resources, blog, and design inspiration delivered straight to your inbox.

We’re empowering
business growth for our clients.
Take the first step towards growth today.

Get Proposal

More From EKbana

See More See All Blog
A Beginners Guide to I...

In recent years, API testing has grown in significance as a component of software development. With the rise of micro-services and the need for sea...

May 29,2023

8m read
Streamlining Developme...

Git has revolutionized the world of version control systems, providing developers with a robust and flexible tool to manage their codebase effectiv...

May 17,2023

4m read

ClamAV is an open-source antivirus engine that is commonly used to scan files for viruses and malware. Mainly used in Linux and Unix servers, It is...

May 10,2023

7m read
Devops and IAC tools1

Historically, IT infrastructure was administered through manual processes, where IT operations personnel were responsible for setting up and uphold...

May 02,2023

8m read