The What, Why and How of recommendation systems

December 6, 2017

Author: Mathias Longo

The What, Why and How of recommendation systems

Machine Learning is the new dive of technology, it is trending topic in almost every IT website, and more and more professionals are willing to start working as Machine Learning Engineers or Data Scientist. Machine Learning, though, is a huge area with lots of sub-disciplines. The most coarse division is Supervised (Classification and Regression) and Unsupervised (Clustering) algorithms. In this post we are going to talk about one specific Unsupervised technique, which along the last few years has gained many adepts, Recommendation Systems. Today we can see them in great diversity of websites, or even we cannot but they are there. But.. What is a Recommender, why do websites actually care about them, and how do they work? We are going to address all these questions in detail.


What is a recommendation system?

Recommendation systems, as everything in IT, has several and disparate definitions, but the one that I like the most is given by this post:

Recommender systems are systems that help users discover items they may like.

Quite simple and straightforward. When you read some news, watch a movie on Netflix, or simply by something on Amazon you will get some messages like:

  • You will also probably like this
  • Frequently bought together
  • Products related to this item
  • Customers who bought this item also bought
  • Because you have seen X you might also like Y
  • Recommended for you

There are a plethora of messages that can be shown to you, but in the end they are basically the same, they are just recommending you an item to be consumed. And that’s because this intricate systems have a profile of the users, and they know what kind of items they tend to consume. Thus, they just try to come up with items you will more probably like, instead of the most popular, or just a random set of items that might not be of your taste.

But… Why are websites so concerned about their recommendation systems?

Money! Didn’t you know that already? Do you think Netflix would have given a one million dollar prize if they hadn’t been sure that the result they obtained from such competition would increase their revenue by a sum much larger than that? I don’t think so either.


E-commerces, such as Amazon or Ebay in US and MercadoLibre in Latin America, are putting a lot of money into it. They are building great teams just to focus on improving the accuracy of their recommenders, because by doing so, users are much more tempted to buy more things. That’s why when you buy something like a bicycle you get a warm message like this one: “you might also be interested in buying this wonderful helmet”. I bet you that somehow it has happened to you and, what’s more, you were caught by this powerful trap and ended up buying such suggested product. In the end, it’s just a matter of happiness. Yes, people like spending money, so the recommendations are just trying to stimulate that part of the brain that makes you feel happier when buying some stuff.


But not only e-commerces improve their revenues by implementing recommendation systems. Other platforms that provide a variety of possibilities to the user can also take advantage of good recommendations, like Netflix or The New York Times. But they are not selling anything, so why would they worry about such complex systems? Again, it’s all about money. By providing good suggestions, either for movies, tv shows or news, these websites are encouraging the user to stayed engaged, and hence they can show more ads, or simply catch more clients.


How does it really work?

There are bunch of techniques that can be used when it comes to creating a recommendation system, some of them are pretty simple, and some others use abstruse mathematical models. Lets just enumerate some of them:

  • Popularity recommenders: probably the easiest approach to create a recommender is by simply recommending the most popular items. For example, for Netflix it would be the most popular movies, for Amazon the most sold items and so on. Within this simple strategy, there are also several options: the recommender can suggest the trending items (such as Youtube does) which are the most popular items in the very few last hours or days; or there might be recommendations for each category the user tends to search on.

The pro of this approach is the simplicity, which also means less computational usage and they are also really easy to keep updated. The cons are lack of personalization, poor accuracy on recommendations, which also means less profits generated :/


  • Content-Based Recommendation Systems: In order to improve the final accuracy, a new and more intuitive approach was adopted. Content-Based recommenders uses two components: user profile and item representation. The latter one is basically some way of describing the item in a vector of numbers, if we are talking about a post, for example, the post might be represented by the words and categories it contains. For movies, it might be the genre, the actors, and so on. Complementing the representation, a normalization technique is used, to eliminate the impact of very popular items. One of such techniques is TF-IDF representation, other one is Jaccard Normalization, depending on the application..
    The user profile, which is basically some kind of aggregation over all the items’ vector he or she has previously visited, usually a ponderate mean. Once there is a vector representation for each item, and each user has its own profile as well, the algorithm searches over all the items to get the most similar ones to the user we want to make recommendations.

This algorithm tends to work really well when there aren’t so many items, and we don’t know so much about the user so far. However, when there are many items (that is the common case) this approach is computationally expensive, and the recommendations start getting worse.


  • Collaborative-Filtering: it is the evolution of content-based.. Broadly speaking, it takes into account the interaction between the different users and items, and takes that information to come up with very insightful recommendations. There are two variants: user-user collaborative filtering and user-item collaborative filtering.
    For example, let’s suppose that we want to make recommendations for the user U who has watched movies <X, Y, Z>. The former alternative looks for “similar” users to base recommendations on the movies watched by them. To continue with the example, apart from U there other two users U1 and U2, and they have watched the movies <X, Y, Z, T> and <X, R, T, S>, respectively. By simply looking at their history, we can infer that the most similar user to U is U1, because the have seen almost the same movies, so with the User-User approach we would recommend item T.
    On the other hand, User-Item technique measures the similarity between items, based on the people that interact with them, and returns the most similar items to the items user U usually looks for. For the example, this approach would also recommend T, since it’s the most similar item to <X, Y, Z>.
  • There are several ways of measuring distances, and aggregating metrics from users, but basically that is the approach taken by a collaborative filtering. Usually, the User-User strategy returns more unexpected items, and the User-Item approach tends to return more predictable items, let’s say if you are buying a computer it will probably recommend you headphones or a mouse.


This has been a brief introduction to Recommendation Systems, in later posts we will dig deeper in more advanced techniques, like Matrix Factorization or combination of recommenders. We will also start depicting some code to have a lower level insight of how a recommender works.

Published on December 6th, 2017

Last updated on April 1st, 2021