DeepMoviesAI: A Deep Learning-Based Movie Recommender System
By: Harshita Pandey
Tags: Machine Learning, Naturallanguageprocessing, Deep Learning

Did you know that Netflix awarded a $1 million prize to a developer team in 2009 for an algorithm that increased the accuracy of the company’s recommendation engine by 10 percent? Although we still are a long way to implement this ourselves, let's build up the basics and see how simple deep learning techniques can be used to produce surprisingly good results. Authors: Harshita Pandey (MT19012), Vineet Joshi (MT19020) (IIIT, Delhi)

Why do we need Recommendation Systems?

In a world, where the number of choices can be overwhelming, the recommender systems help users discover and evaluate items of interest, and create a delightful user experience across all domains by providing individualized recommendations. Over the years recommendation systems have been one of the most prevalent research directions in the digital television domain and a huge advantage to tech giants like Netflix or Amazon, by guiding their users in a personalized way in a large space of possible options.

We tried to create a deep learning-based movie recommendation system that learns latent embeddings for representing movies and users and based on their interaction recommend the items. We also included movie specific meta-data to add trending results to our recommendations. Our movie recommendation system is a filtering system that performs both content-based and collaborative filtering of data to provide recommendations to users regarding movies.

Content-Based Filtering

A content-based filtering system recommends movies based on their similarity to what a given user has liked in the past. It is based on the profile of the user’s preferences and the movie description.

Collaborative Filtering

A collaborative filtering system recommends movies based on similarity measures between users and recommends movies that a similar user rated highly.

Unlike content-based models, which recommends movies similar to a user’s interest, collaborative filtering is not a great indicator of what the user actually likes. It is more helpful in recommending items new to the user’s taste which the user might like.

About the Dataset

The dataset used in this project is the MovieLens 20M Dataset. MovieLens is one of the most popular datasets for recommendation system studies across the world. This dataset consists of a set of CSV files, which describe the ratings and free-text tagging activities from MovieLens, a movie recommendation service. It contains 20000263 ratings, by randomly selected users across 27278 movies.

Being a standard dataset for a recommendation, the dataset was already preprocessed where each user, uniquely identified by an userId has rated at least 20 movies. All the users who have rated less than 1000 movies were removed from the dataset, reducing the size from 20M to 12 lakhs. This not only made the computations less expensive but ensured that each user had a significant contribution.

Total Movies Per Genre

Distribution Of Movie Ratings

User Rating Behaviour

Content-Based Recommendation System

The idea behind the Content-Based Recommendation System is to recommend movies based on the comparison between the content of the movie and the user’s preferences. Each movie in the dataset is characterized by sets of genres and tags, having a total of 20 genres in the entire dataset.

For generating movie recommendations for a user, we measured the similarity between the movies based on their genres and recommended movies that were similar to movies they had already watched. Different similarity measures, including Cosine Distance, Euclidean Distance, and Manhattan Distance were used to compute the similarity between the movies. Cosine Distance gave the least mean square error and thus was used for the final recommendations. We had chosen TF-IDF to create a vectorizer of a movie which later was used as a feature space.

Deep Learning Content-Based Recommendation System

Since the content-based recommendation system learns a classifier for the user’s likes and dislikes based on the user’s preference, the tags provide a better insight about the same. Each movie is characterized by a set of tags having a total of 30022 unique tags in the dataset. Not every tag is relevant so we need to keep only the most relevant tags. Each movie is thus represented by 15020 features, including 15000 top relevant tags and 20 unique genres.

To efficiently compress the data and reduce the dimensions of the data, we have used autoencoders. The architecture consists of an encoder and a decoder, both of which are fully connected feed-forward neural networks. The architecture was implemented in Keras with dense layers having the activation function as Relu. The model was compiled with Mean Squared Error loss using the Adam optimizer and trained for 500 epochs with a batch size of 128.

Autoencoder Network For Learning Movie Representations

We later used the encoder part of the architecture to reduce the input dimensions and compress the 15020 features of the movies into an encoded representation of 1000 features for the entire dataset. For generating movie recommendations for a user, we measured the similarity between the movies based on these 1000 features including the genres and tags, where cosine distance was used as the similarity measure and recommended movies that were similar to movies they had already watched.

Collaborative Recommendation System

Although most of the collaborative filtering approaches are based on the singular value decomposition of the user-item matrix, we decided to go for the deep learning-based approach. This is the generalization of the singular value decomposition where we try to learn an embedding that minimizes the predicted rating loss. The model first individually learns the user and the movie embedding and then passes the concatenated results into a bunch of deep network layers the help in learning the relations.

The architecture was implemented in Keras with embedding layers and dense layers trained with Mean Squared Error loss using Adam optimizer and a learning rate of 0.01 for 5 epochs with a batch size of 128.

Collaborative Filtering Architecture

Popularity Based Recommendation System

In order to compare the performance of the previous two models, we decided to implement popularity-based systems as this does not follow any heuristic or user-specific information. A popularity-based system recommends any product to the user that has greater than 300 ratings in our training data.

Random Recommendation System

In order to compare the performance of the previous models, we decided to set up a baseline by randomly recommending items to users as relevant and not.

Results

Although many performance metrics have been developed for recommender systems, we used precision@k and recall@k for our study at this moment. Precision@k helps us figure out that if k items are recommended to a user then the number of relevant items for the user our of k, whereas Recall@k helps us find that out of total relevant items for the user, how many are recommended in the top k.