Understanding Movie Recommendation System

Rutvik Kalasha
4 min readDec 28, 2020

--

Everyone loves movies irrespective of age, gender, race, color, or geographical location. We all in a way are connected to each other via this amazing medium. Yet what most interesting is the fact that how unique our choices and combinations are in terms of movie preferences. Some people like genre-specific movies be it a thriller, romance, or sci-fi, while others focus on lead actors and directors. When we take all that into account, it’s astoundingly difficult to generalize a movie and say that everyone would like it. B ut with all that said, it is still seen that similar movies are liked by a specific part of the society.

Source: https://data-flair.training/blogs/data-science-r-movie-recommendation/

What is a Recommendation System?

Simply put a Recommendation System is a filtration program whose prime goal is to predict the “rating” or “preference” of a user towards a domain-specific item or item. I n our case, this domain-specific item is a movie, therefore the main focus of our recommendation system is to filter and predict only those movies which a user would prefer given some data about the user him or herself.

There are two types of recommendation systems. They are

  1. Content-Based Recommender System
  2. Collaborative Recommender System

Let us understand both of them one by one.

Content-Based Recommender System

Content-Based Recommender System works on the data generated from a user. The data can be generated either explicitly (like clicking likes) or implicitly (like clicking on links). This data will be used to create a user profile for the user which contain the metadata of the items user interacted. More the data it receives more accurate the system or engine becomes.

Collaborative Recommender System

Collaborative Recommender System makes a recommendation based on how similar users liked the item. The system will group users with similar tastes. In addition to user similarity, recommender systems can also perform collaborative filtering using item similarity.

Now, let’s take one example to understand it in deep.

How to build a popularity based recommendation system:

we will consider the Movie Lens small data set, and focus on two files, i.e., the movie and rating
Movie has three fields namely:

  1. Movie Id — It has a unique id for every movie
  2. Title — It is the name of the movie
  3. Genre — The genre of the movie

The ratings file has four fields namely:

  1. User id — The unique id for every user who has rated one or multiple movies
  2. Movie Id — The unique id for each movie
  3. Rating — The rating given to a user to a movie
  4. Timestamp — When was the rating given to a specific movie.

Here, I will be using a movie dataset which contains data of 5043 movies in 14 variations. And second is rating dataset which is containing 164730 data of movie ratings.

movie_data=pd.merge(ratings_data,movie_names,on='movie Id')
movie_data.head()

Implementation:

For our recommender system, we’ll use both of the techniques mentioned above: content-based and collaborative filtering.

To find the similarity between movies for our content based method, we’ll use a cosine similarity function. For our collaborative filtering method, we’ll use a matrix factorization technique.

Let’s test and visualize our dataset.

Now, I will create a data frame for analysis.

trend=pd.Data frame(movie_data.group by('title')['rating']mean())
trend['total number of ratings'] = pd.Data frame(movie_data.group by('title')['rating']count())
trend.head()

Below code will plot rounded-up ratings with number of movies.

plot.figure(file size =(10, 4))
ax=plot.bar(trend['rating']round(),trend['total number of ratings'],color='b')
plot.show()

A bar graph which is describing a number of reviews for the first 25 movies from our dataset.

plot.figure(file size =(10, 4))
ax=plot.subplot()
ax.bar(trend.head(25)index,trend['total number of ratings']head(25),color='b')
ax.set.sticklabels(trend.index,rotation=40,font size='12',horizontal="right")
ax.set_title("Total Number of reviews for each movie")
plot.show()

Conclusion:

So, In this tutorial I have tried to introduce you what is a recommendation Systems, what are the types of it, where and how we can use it etc. I have also took one example and implemented it in python. I hope you find this article helpful. Thank you.

--

--