Recommender System-Collaborative Filtering

In this post we are about to work on building a recommender system. Here the approach is Collaborative filtering. This Algorithm we are dealing with has very interesting property called feature learning. By this i mean the algorithm starts learning by itself what features to use. For better explanation am going to use the data set I have used in the BUILDING BLOCKS OF RECOMMENDER SYSTEMS post. I strongly recommend you to go post for better understanding and for data.

Recommender System-Collaborative Filtering1 (i2tutorials)


Recommender System-Collaborative Filtering 2 (i2tutorials)

Let’s say we have collected the features x1 and x2 for each movie from n number of user there by we concluded that Romance forever movie is more romantic and it contains no action sequence, similarly we have collected enough information from many users to rate the movie as above. But what happens is it is time consuming task to make. And often we need more features than these two

So, let’s change the problem a bit and we have a data set and we don’t know the values as shown below.

Recommender System-Collaborative Filtering3 (i2tutorials)


Here we have a dataset, where movie names and how people reacted to them are known but how romantic and how action-oriented these movies are unknown so we place all these question mark. Now we gathered information from our users that how much they like action-oriented movies and how much they like romantic movies to get parameter vector of each user.

Recommender System-Collaborative Filtering4 (i2tutorials)

As the information from them implies that Rohith like romantic movies as he gave 5 rating for that and he don’t like action-oriented movies as he gave 0 rating for them. Similarly every user motioned their taste of movies they like which are represented as   ,.If we get these values form the user then there is a possibility to compute x1 and x2 values for each movie. Let’s look at first movie forget about the movie name all we know is Rohith and Srikanth love this movie as they rated 5 for the movie. And Nagaraju and Venkat hate this movie as they gave 0 rating for that. What we can infer from is, we know from feature vector that Rohith and Srikanth like romantic movies as they told it by giving 5 for romantic movies. And we know that Nagaraju and Venkat like action movies. By taking these in to consideration probably the first movie may be a romantic movie because Rohith and Srikanth liked the movie And Nagaraju and Venkat disliked the movie. Mathematically talking

Recommender System-Collaborative Filtering8 (i2tutorials)

Recommender System-Collaborative Filtering5 (i2tutorials)

Let’s try to figure out what might be the reasonable features for every movie.

Recommender System-Collaborative Filtering 6 (i2tutorials)

Recommender System-Collaborative Filtering 7 (i2tutorials)

What we can do that actually works is randomly guess some values of, now based on the initial guessed values as we learned now learn the features of movies ‘x’ .As we get some initial values of feature vector then Second method mentioned above to obtain optimal ‘θ ‘ values .Then use this optimal parameters to calculate better feature vectors and so on iterating this results in reasonable set of parameters and feature vectors. This is a basic collaborative filtering algorithm. In Later posts we will discuss how to improve this and make computationally effective.