Introduction to recommender system

If  you have seen amazon ‘s similar product section or Netflix Movie recommendation or Youtube recommended videos  or any other items which are shown on any platform based on the previous items you might have purchased or watched then you have used  one the major application of  machine learning called Recommender systems.

The core motivation behind recommender system is to built a system which will be able to predict items which might  user like ,and this prediction is done on the basis of previous history of user interacted items.

There are two methods about how to design a recommender system,

  1. Collaborative filtering: This method is solely based on the similarity between user preferences or rather between user ,this is not the most accurate method as user preference changes with time and if this happens the system can predict some very bad result.
  2. Content based: This method is based on the similarity between items ,and in real scenarios this does makes sense .

Whole idea of recommender system is built on top of a very elegant Linear algebra method called Matrix Factorization ,the idea is very simple .Let’s say We have a Matrix ‘A’ ,so by using matrix factorization we can write  A as a product of two Matrices ‘B’ and ‘C’.

A = B.C

Now Let’s build some math around it,

In Our case A will be a matrix of size n x m where n is number of users and m is total number of items present, where in  Aij  ith represnts user ‘i’  rating’s on ‘j’ item ,will be a very sparse matrix as it will be very rare that if a user have rated all the items.

A = [ ]n\ast m

We need to find B and C , the reason to find B and C is that A is a sparse matrix i.e every row is partially filled rest all values are empty and if we want to predict item for a user we need to find a way to filled those missing values and based upon those filled  values we can predict most appropriate product as product with large filled aka predicted rating will be most appropriate.

So, the Question is how to find B and C , In this situation we can use one of the most simple yet powerful loss function Squared loss , Now using squared loss we can define our objective function as follows,

minimise(\Sigma (Aij - Bi.Cj) ^{2})

Give this equation a minute and think what might B and C represents ,the answer is B is transpose of  User’s matrix where each row is d-dimensional representation of user’s and C is d-dimensional vector representation of each  item’s which makes it a item’s matrix and the dot product between ith row of B and jth row of C will predict the ith and jth value of predicted  Aij  and this Predicted matrix will not be sparse as the optimization function describe above can only approximates best not equal.

After getting the predicted rating of all the items by user j we can easily predict which item is most suitable for a user as we can now just sort the items according to predicted rating of user ‘i’ and recommend it in this manner.This implementation is one of the most simplest implementation  of a recommender system.

Matrix factorization is not just the base for recommender system it is also the base of many powerful machine learning alghorithm’s such as PCA ,k-means clustering etc.Getting a deeper understanding of machine learning is very crucial in today’s world. We will be covering may such great machine learning content in future ,so stay reading and if you are interested in machine learning then check out Machine Learning bootcamp.

 

Send a Message