Movie Recommendation System-Content Filtering

For a long time, I have been thinking about how shopping websites like Flipkart or Amazon or movie based platforms like Netflix or even on medium suggest anything based on user interest.

In this blog post, I will build a movie recommendation system using The Movie Dataset

Hearing to what Google has to say about it.

A recommender system or a recommendation system (sometimes replacing “system” with a synonym such as platform or engine) is a subclass of information filtering system that seeks to predict the “rating” or “preference” a user would give to an item

and putting in a simple language “a recommendation system suggest anything relevant based on the used interest

The recommendation system is classified into two type Content-Based and Collaborative based recommendation system. Let’s try to understand each one by one.

The idea behind Content-based (cognitive filtering) recommendation system is to recommend an item based on a comparison between the content of the items and a user profile.In simple words,I may get recommendation for a movie based on the description of other movies.

The theory behind collaborative filtering to work with collaboration with user or movie id.For example, there are two user A and B, user A likes movie P,Q,R,S and user B like movies Q,R,S,T. Since movies Q, R and S are similar to both user, therefore, movie P will be recommended to user B and movie T will be recommended to used A.

Starting with understanding of data first. I have used The Movie Dataset which has data of around 5000 movies describing there various features.Before we dive in code lets try to figure out our approach towards the solution. For the ease of understanding, I have tried my hands on content filtering approach on the same data set.

For content-based filtering, the approach is relatively simple we have to just convert the words or text in vector form and to find the closest recommendation to our given movie input title using cosine similarity.

Let’s begin with the code.

  1. Importing the Libraries which we will use for our recommender system

2. Defining the Helper function one is for getting the title from the index and another function is to return index from the title

3. Reading the dataset. For reading two procedures can be followed firstly directly copying the link(raw data) of dataset in pd.read_csv or by uploading it to the google colab. I had uploaded the dataset in google colab then used it.

4. Selecting the features for Movie recommendation system and combining it into a column.

5. Creating the count matrix of the combined column and computing the cosine Similarity based on count matrix

6. Get the index of the movie from its title.

7. Get a list of similar movies in descending order of similarity score.

8. Final step printing the similar movies as per user’s choice.

Movies similar to Avatar

The source code of this is available on my github repository.

For any queries related to my project contact me over my email id: powerakash8@gmail.com

Closing Note: I hope this blog will help you to build your own recommendation system.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store