Machine Learning Model for Movie Recommendation System

The primary aim of recommendation systems is to recommend applicable objects to a consumer-based totally on ancient data. If a movie is rated excessive by means of a consumer who also watched the movie you are watching now, it's miles possibly to show up inside the recommendations. The films with the highest overall scores are in all likelihood to be enjoyed by way of nearly everyone. The algorithm which does all these features is called CineMatch. For personal users, it also learns from the conduct of the person to higher expect a movie the consumer is anticipated to be fascinated in. Here we have to increase our CineMatch algorithm 10% by using fashionable collaborative filtering techniques. Keywords—Machine learningmodels,Movies,Ratings,Similarity matrix,Sparse matrix.


I. INTRODUCTION A. Motivation and Scope
We are leaving the age of facts and coming into the age of recommendation. Like many device mastering techniques, a recommender system makes a prediction based on users' ancient behaviors. Specifically, it's to expect user choice for a fixed of items based totally on past experience.

B. Need to study
Recommendation systems are getting increasingly important in today's extraordinarily busy world. People are always short on time with the myriad duties they need to accomplish within the restrained 24 hours. Therefore, the recommendation structures are vital as they help them make the right choices, without having to dissipate their cognitive resources. The reason for a recommendation system essentially is to look for content that would be thrilling to an individual. Moreover, it includes a number of things to create customized lists of beneficial and exciting content unique to every user/individual. Recommendation structures are Artificial Intelligence primarily based algorithms that skim thru all possible alternatives and create a customized listing of objects which might be thrilling and relevant to an individual.

C. Literature Survey/Review of Literature
• The two principal tasks addressed by way of collaborative filtering techniques are rating prediction and rating. In contrast, ranking fashions leverage implicit feedback (e.g. Clicks) so that you can offer the user with a customized ranked listing of encouraged items [1]. • With the increasing need for retaining confidential statistics at the same time as supplying tips, privacymaintaining Collaborative filtering has been receiving increasing attention. To make statistics proprietors experience more comfortable even as imparting predictions, various schemes were proposed to estimate pointers without deeply jeopardizing privacy. Such methods dispose of or reduce statistics proprietors' privacy, financial, and legal concerns by means of employing exceptional privacy-retaining techniques [2]. • In the spread of information, the way to quickly locate one's favorite film in a massive variety of movies end up a very essential issue. Personalized recommendation machines can play a crucial role in particular whilst the person has no clean target movie. [3]. • In this paper, we design and implement a movie recommendation machine prototype blended with the actual wishes of movie recommendation thru gaining knowledge of KNN algorithm and collaborative filtering algorithm [4]. • In this study, we examine a privacy-retaining collaborative filtering method for binary facts referred to as a randomized reaction technique. We develop a method focused on the second thing of privacy to find out faux binary rankings the usage of auxiliary and public information [5].

•
If privacy measures are provided, they may decide to grow to be worried about prediction generation processes. We advocate privacy-maintaining schemes getting rid of e-commerce sites' privateness concerns for imparting predictions on allotted data [6].
• With the improvement of the Internet and ecommerce, the recommendation machine has been widely used. In this paper, the electronic commerce recommendation system has a similar look at and makes a specialty of the collaborative filtering algorithm in the utility of personalized film recommendation system [7].

RESEARCH GAP
The data set provided quite a few rating information, and a prediction accuracy bar this is 10% better than what Cinematch algorithm can do on the equal training data set. (Accuracy is a measurement of the way closely predicted scores of films in shape subsequent actual rankings).And we have to Predict the score that a consumer would supply to a movie that she or he has not yet rated. And also Minimize the difference between predict and the actual score.

A. User-Item Sparse Matrix
In the User-Item matrix, each row represents a person and every column represents an object and every cell represents rating given with the id of a user to an item.

B. User-User Similarity Matrices
Here, two customers could be similar to the premise of the comparable ratings given with the id of each of them. If any two users are similar then it means both of them have given very comparable scores to the items due to the fact here the consumer vector is nothing however the row of a matrix which in flip contains rankings given through user to the items. Now considering cosine similarity can variety from '0' to '1' and '1' means the highest similarity, so consequently, all the diagonal elements could be '1' because the similarity of the consumer with him/herself is the highest. But there's one hassle with user-user similarity. User alternatives and tastes change over time. If any consumer favored some item one year in the past then it isn't important that he/she will like the identical object even today.

C. Item-Item Similarity Matrix
Here, two items can be comparable to the idea of the comparable rankings given to each of the items via all of the users. If any two gadgets are comparable then it means both of them had been given very comparable ratings by means of all of the users due to the fact here the item vector is nothing however the column of the matrix which in flip contains scores given with the aid of consumer to the objects. Now due to the fact cosine similarity can variety from '0' to '1' and '1' means the highest similarity, so consequently, all of the diagonal elements might be '1' due to the fact the similarity of an item with the identical item is the highest.

D. Cold Start Problem
The cold start problem concerns the personalized guidelines for users without a few past histories (new users). Providing suggestions to users with small beyond history turns into tough trouble for CF models due to the fact their studying and predictive ability is limited.

IV. SURPRISE LIBRARY MODELS A. XGBoost
However, with regards to small-to-medium structured/tabular data, choice tree primarily based algorithms are taken into consideration best-in-class proper now.. XGBoost and Gradient Boosting Machines (GBMs) are each ensemble tree techniques that follow the precept of boosting susceptible learners using the gradient descent architecture.

B. Surprise Baseline
This Algorithm predicting a random rating based totally on the data.
Predicted rating: (baseline prediction) μ : Average of all trainings in training data. bu : User bias. bi : Item bias (movie biases)

C. Suprise KNNBaseline Predictor
It is a number one collaborative filtering algorithm considering a baseline rating.
Predicted Rating: (based on User-User similarity) This is exactly same as our hand-crafted features 'SUR'-'Similar User Rating'. Means here we have taken 'k' such similar users 'v' with user 'u' who also rated movie 'i'. is the rating which user 'v' gives on item 'i'.
is the predicted baseline model rating of user 'v' on item 'i'.Generally, it will be cosine similarity or Pearson correlation coefficient.
Predicted rating (based on Item Item similarity):

D. Matrix Factorization SVD
The Singular-Value Decomposition, or SVD for short, is a matrix decomposition technique for decreasing a matrix to its constituent elements in order to ensure the next matrix calculations simpler. The SVD is used broadly both within the calculation of different matrix operations, including matrix inverse, but also as a statistics reduction approach in machine learning.
Predicted Rating: -Representation of item(movie) in latent factor space. pu -Representation of user in new latent factor space.

E. Matrix Factorization SVDpp
Here, an implicit rating describes the fact that a consumer u rated an item j, regardless of the rating value. is an object vector. For every object j, there is an object vector that is an implicit remarks. Implicit feedback in a roundabout way displays opinion by looking at consumer behavior including purchase history, surfing history, seek patterns, or even mouse movements. Implicit comments commonly denotes the presence or absence of an event Iuthe set of all items rated by user u. yj-implicit ratings. For example, there's a film 10 in which a person has just checked the info of the film and spend some time there, which will contribute to implicit rating. Now, since here our records set has now not provided us the details that for how long a person has hung out on the movie, so right here we are considering the fact that despite the fact that a user has rated some film then it means that he has spent some time on that film which contributes to implicit rating. If person u is unknown, then the bias and the elements are assumed to be zero. The equal applies for item i with , , and V. IMPLEMENTATION

A.
Reading and Storing Data The dataset I am working with is downloaded from Kaggle .https://www.kaggle.com/Netflix-inc/Netflix-prizedata.
It consists of four .txt files and we have to convert the four .txt files to .csv file. And the .csv file consists of the following attributes. MovieID: Unique identifier for the movie.
CustID: Unique identifier for the Customer.
Date: Date on which customer had watched the movie and given rating.
Once the statistics analysis was completed we have to test for empty values for the records set. By the usage of null characteristic. In Python, especially Pandas, NumPy and Scikit-Learn, we mark missing values as NaN. Values with a NaN cost are overlooked from operations like sum, count, etc. We can mark values as NaN without difficulty with the Pandas Data Frame by means of using the replace () feature on a subset of the columns we are involved in.
Then we need to do away with duplicates, Duplicates are the values which befell extra than once inside the given information. Here we should find the duplicates and dispose of it by way of duplicate characteristic

B. Performing Exploratory Data Analysis on Data
In statistics, exploratory data analysis isn't the same as initial data analysis (IDA), which focuses extra narrowly on checking assumptions required for version becoming and hypothesis trying out, and coping with lacking values and making transformations of variables as needed.

Fig. 1. Distribution of Ratings in data
The above graph shows the distribution of ratings from the data set. For example it implies that there are 2millions of ratings with a rating of 1.And similarly for the reaming ratings also. It clearly shows that there are some movies which are very popular and were rated by many users as compared to other movies.

C. Creating User-Item sparse matrix for the data
Once the data preprocessing was completed then we have to create a user-Item sparse matrix for the data. Shape of sparse matrix depends on highest value of User ID and highest value of Movie ID.Then we have to find the global average of all movie ratings, average rating per user and average rating per movie. And next we have to compute the similarity matrices, there are mainly two similarity matrices such as user-user and item-item and we have to compute both matrices with our data set.And there is a csv file which consists of movie names for the movie id's which are present in our data set.  Suppose pick a movieid with number 17767. The number with particular movieid is picked from the movie titles and will show the name of the movie. Then by using the movie-movie similarity matrix we can find the total number of ratings given to the particular movie and it will also show the similar movies.
For example the movie with movieid 17767 is American experience. The top ten similar movies for American experience are as follows.

D.
Applying Machine Learning Models Before us applying the models we have to featurize data for the regression problem. Once it was completed we have transform data to surprise models. We can't give raw data (movie, user, and rating) to train the model in Surprise library. Following are the models which we are applying for the data. 1) XGBoost was the first model which we are applying for the featurize data. When we run the model we get the RMSE and MAPE for the train and test data.  2) Surprise Baselineonly was the next model we are using. Here we are updating the train and test data with the extra feature baseline only. When we run baseline model we get the following as the output.  3) Surprise KNNBaseline was the next model we are applying for the data set. Here we have to update our data set with the features from the previous model. When we run the model we get the following as the output. From the above graph we can say that user average and movie average are most important features while baseline_user is the least important feature. And the error rates for the baseline model is as follows. 4) Matrix Factorization SVD was the next model we are using. And here we have to update our data set each time. And when we run the matrix factorization svd we get the following as the output. And the error rates for the model is as follows.    FUTURE ENHANCEMENT Tune hyper parameters of all the Xgboost models above to improve the RMSE. Here we used 10K users and 1K movies to train the above models due to my pc ram issues. In the future, I am going to run on the entire information set using cloud resources.