Theoretical Introduction to Recommendation Systems in Python

How To Calculate Dot Product In Python (1)

Hello reader! Today, we will learn about recommendation systems in Python.

By the end of this article, you’ll know:

What is it, how they work, what is the need, their classification, which python modules will be needed, and much more. So, read this article till the end to know all the basics about the recommendation systems. Let’s begin

1. What is a recommendation system?

Recommendation systems, or recommender systems, as the name suggests, are the systems that recommend something to their user. These are the tools that provide suggestions for items such as what items to buy, or what songs to listen to, or which movie you should watch.

This is something that each one of us has experienced on some platform or the other. Have you ever noticed that the advertisement that you are seeing today on social media, be it Instagram, Facebook, or YouTube, is for the same item that you searched for today morning? If not, do observe now. Say, if you search for sneakers online on Google and the next time you’ll open YouTube, the first thing you will see will be the advertisement for sneakers. This is a great example of a recommendation system.

So, a recommendation system is an information filtering system that predicts what a user might like to see or buy or read.

2. How do recommendation systems work?

Now that we have understood what a recommendation system is, let’s move further and try to look at how they work.

Recommender systems are one of the most important applications of data science and machine learning. The primary goal of these systems is to provide users with a personalized experience.

It is used by almost every major tech company. Amazon uses this system for recommending their products to their users, youtube uses it to recommend you videos based on your history (similar to videos you have watched), Netflix, Amazon Prime, Hotstar uses it to recommend you movies based on different algorithms, Spotify uses it for music recommendation.

These platforms mostly recommend you items based on your history, or what genre you generally like and choose to view, etc.

But say if you are a new user, then also these platforms show some recommendations. These recommendations are based on their bestsellers or for songs, it might be top 20 like that.

2.1. Mechanism of a Recommendation System

The steps involved to make recommender systems work are:

  • Data collection

This step involves the collection of data from users or different sources so that the system can personalize the experience of the user based on the data obtained.

It can be done in two ways:

First, explicitly. This data is provided intentionally by the user in the form of movie reviews, ratings, etc.

Second, implicitly. This data is collected from users only but not intentionally. It is gathered from other available data streams such as search history, order history, clicks, etc.

  • Data storage

After the data is collected, we need to store that data efficiently and in an organized way. The data is much larger in quantity, so it should be managed properly. The more the amount of data, the better is the recommendation system.

The type of data collected decides its storage. It might be a standard SQL database or No SQL database.

  • Data filtration

After storing the data, the next step is of filtering the data. We need to filter the data to extract the relevant information that will help in making the final recommendation.

The data is filtered using one of the several algorithms that exist. We will be discussing different algorithms for filtering the data in the next section.

2.2 Classification of Data

Recommender systems recommend items on different bases, to understand that, they are mainly classified into 3 categories:

  1. Simple recommender systems
  2. Content-based recommender systems
  3. Collaborative filtering recommender systems

2.2.1 Simple recommender systems

These systems recommend an item in a generalized manner. i.e., these recommendations are the same for every user regardless of their history. Recommendations are based on popularity, Such as top 10 IMDb rated movies, or maybe genre, such as top 5 songs of a particular genre, like that.

2.2.2 Content based recommender systems

These systems recommend you an item based on your history. It uses metadata to recommend to you an item similar to the one you’ve watched or liked in the past. One most experienced example of this is your YouTube feed. It shows videos that are similar to the videos you’ve watched already. Also, OTT platforms such as Netflix, Hotstar, etc use this system.

2.2.3 Collaborative filtering recommender systems

This algorithm does not use a particular user’s preference. It is widely used. It recommends a particular user an item that he/she may like based on the rating given to that item by other users who have a similar taste.

Say, for example, two users A and B exist. Both use a book recommendation system and both are asked to give ratings to few books. They give similar ratings. Like both have given 5 stars to a fictional novel and 3 stars to a non-fictional one. Then this algorithm will identify the books that are read by user A but not B, and then recommend those books to user B. This is how this filtering works and it does not require any item metadata.

3. Libraries needed to implement a recommendation system in python

Now that you know almost everything about recommender systems. Let us study some python basics. In this section, we will discuss the python libraries needed to implement a basic recommender system.

  • Scikit learn: It is an open-source machine learning library in python that provides simple tools for predictive data analysis.
  • Pandas: It is an open-source library in python mainly used for analysis and manipulation of data.
  • Numpy: It is a python library facilitating the working in the domain of linear algebra, and matrices and arrays.

4. Why is a recommendation system needed?

A recommendation system is widely used for increasing revenues. Tech companies put a lot of money to make their recommendation engines effective. It helps users buy more relevant products. Movies or songs recommender systems keep recommending movies so that the user stays engaged with their platform.

Recommendation systems help organizations to make their business decisions effectively.

These systems are of much help to the users also. The user doesn’t have to waste time to make a choice. The system does it for them.


Congratulations, you made it to the end. You have learned the basic theory about recommendation systems.

I hope this article was helpful to you.