0% found this document useful (0 votes)
7 views17 pages

Movie Recommendation System Project

The document presents a mini project on a 'Movie Recommendation System' developed by Miss. Ahire Rasika Vinod as part of her Bachelor of Engineering degree. The project aims to provide users with movie recommendations based on metadata and past ratings using the scikit-learn library in Python. It discusses the methodologies, technologies used, and the importance of recommendation systems in helping users discover movies they might enjoy.

Uploaded by

rasikaahire2704
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views17 pages

Movie Recommendation System Project

The document presents a mini project on a 'Movie Recommendation System' developed by Miss. Ahire Rasika Vinod as part of her Bachelor of Engineering degree. The project aims to provide users with movie recommendations based on metadata and past ratings using the scikit-learn library in Python. It discusses the methodologies, technologies used, and the importance of recommendation systems in helping users discover movies they might enjoy.

Uploaded by

rasikaahire2704
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

A Mini Project

On
‘‘MOVIE RECOMMENDATION SYSTEM”

Submitted in partial fulfillment of the requirements of the degree of

BACHELOR OF ENGINEERING

Miss. Ahire Rasika Vinod


PRN No: 72265935M

Guide by
[Link] Saeed

Department of Computer Engineering


Maulana Mukhtar Ahmad Nadvi Technical Campus, Malegaon- 423 203 (A.Y
2023-24)
C E R T I F I C AT E

This is to certify that the Mini Project report entitled ‘Movie Recommendation
System ’ submitted by Ahire Rasika Vinod, in the fulfillment of the requirement
for the award of degree of Bachelor of Engineering computer Engineering of
MMANTC, Malegaon, affiliated to the Savitribai Phule Pune University is a
record of his own work.

Name of the Guide Name of the Head Principal


Prof. Talha Saeed
Dr. Salman Baig [Link] Husain

Date :
Place :
DECLARATION

We declare that this written submission represents my ideas in my own words and where others' ideas or
words have been included, I have adequately cited and referenced the original sources. I also declare that I
have adhered to all principles of academic honesty and integrity and have not misrepresented or fabricated or
falsified any idea/data/fact/source in my submission. I understand that any violation of the above will be cause
for disciplinary action by the Institute and can also evoke penal action from the sources which have thus not
been properly cited or from whom proper permission has not been taken when needed.
(Name of student)
(Signature)
(Roll No.)

Date:
Place:
Acknowledgement

It is my great pleasure to acknowledge sense of gratitude to all, who have made it possible for us to complete
this mini project work with success. It gives me great pleasure to express my deep gratitude to my Project
guide Prof. Talha Saeed for his support and help from time to time during Project work.

It is my pleasure to acknowledge sense of gratitude to Head of Department Dr. Salman Baig and
co-ordinator Prof. Faizi Razi for their great support and encouragement in seminar work. I would also like
to thank my Principal Dr. Naveed Husain for his valuable recommendations.

I would like to express my gratitude towards our dear parents for their support, and constant encouragement.

At last but not in least, we would like to thank everyone who directly and indirectly helped and motivated us
to work on this project.
Movie Recommendation System

PROBLEM STATEMENT:

Develop a movie recommendation model using the scikit-learn library in python.

OBJECTIVE:

The objective of this recommendation system is to provide satisfactory movie recommendations to users while
keeping the system user friendly i.e. by taking minimum input from users. It recommends the movies based on
metadata of the movies and past user ratings.

TECHNOLOGY USED:

Machine Learning Library:

Pandas
numpy
difflib
AST
scikit-learn

Requirements:

Python .6
THEORY

What is scikit-learn?

Scikit-Learn is a free machine learning library for Python. It supports both supervised and unsupervised
machine learning, providing diverse algorithms for classification, regression, clustering, and dimensionality
reduction. It is licensed under a permissive simplified BSD license and is distributed under many Linux
distributions, encouraging academic and commercial use.
The library is built upon the SciPy (Scientific Python) that must be installed before you can use scikit- learn.
This stack that includes:

NumPy: Base n-dimensional array package


SciPy: Fundamental library for scientific computing
Matplotlib: Comprehensive 2D/3D plotting
IPython: Enhanced interactive console
Sympy: Symbolic mathematics
Pandas: Data structures and analysis

Extensions or modules for SciPy care conventionally named SciKits. As such, the module provides learning
algorithms and is named scikit-learn.
The vision for the library is a level of robustness and support required for use in production systems. This
means a deep focus on concerns such as easy of use, code quality, collaboration, documentation and
performance.

Although the interface is Python, c-libraries are leverage for performance such as numpy for arrays and matrix
operations.
It was originally called [Link] and was initially developed by David Cournapeau as a
Google summer of code project in 2007. Later, in 2010, Fabian Pedregosa, Gael Varoquaux, Alexandre
Gramfort, and Vincent Michel, from FIRCA (French Institute for Research in Computer Science and
Automation), took this project at another level and made the first public release (v0.1 beta) on 1st Feb.
2010.

FEATURES:

The library is focused on modelling data. It is not focused on loading, manipulating and summarizing data. For
these features, refer to NumPy and [Link] popular groups of models provided by scikit-learn include:
Clustering: for grouping un labelled data such as K Means.
Cross Validation: for estimating the performance of supervised models on unseen data.
Datasets: for test datasets and for generating datasets with specific properties for investigating model
behaviour.
Dimensionality Reduction: for reducing the number of attributes in data for summarization, visualization
and feature selection such as Principal component analysis.
Ensemble methods: for combining the predictions of multiple supervised models.
Feature extraction: for defining attributes in image and text data.
Feature selection: for identifying meaningful attributes from which to create supervised models.
Parameter Tuning: for getting the most out of supervised models.
Manifold Learning: For summarizing and depicting complex multi-dimensional data.
Supervised Models: a vast array not limited to generalized linear models, discriminate analysis, naive bayes,
lazy methods, neural networks, support vector machines and decision trees
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. In 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.

Recommendation System Mechanism:

The engine of the recommendation system filters the data via different machine learning algorithms, and
based on that filtering, it can predicts the most relevant entities to be recommended. After studying the
previous behaviours of the users, it recommends products/services that the used may be interested on.

The engine’s working of a recommendation is classified in these 3 steps:


Data Collection:

The techniques that can be used to collect data are:

Explicit, where data are provided intentionally as an information (e.g. user’s input such as movies rating)

Implicit, where data are provided intentionally but gathered from available data stream (e.g. search history,
clicks, order history, etc…)

Data Storage:

It can be stored in a cloud storage such as SQL database, NoSQL database, or some other kind of object
storage. However, it depends on the data type and amount as well. The more data that the storage can have
for the model, the better recommendation system can be.
What are the different filtration strategies?

Content-based Filtering:

This filtration strategy is based on the data provided about the items. The Algorithm recommends products that
are similar to the ones that a user has liked in the past. This similarity (generally cosine similarity) is computed
from the data we have about the items as well as the user’s past preferences.

For example, if a user likes movies such as ‘The Prestige’ then we can recommend him the movies of
‘Christian Bale’ or movies with the genre ‘Thriller’ or maybe even movies directed by ‘Christopher Nolan’.
So what happens here the recommendation system checks the past preferences of the user and find the film
“The Prestige”, then tries to find similar movies to that using the information available in the database such
as the lead actors, the director, genre of the film, production house, etc and based on this information find
movies similar to “The Prestige”.

Disadvantages:

Different products do not get much exposure to the user.


Businesses cannot be expanded as the user does not try different types of products.
Collaborative Filtering:

This filtration strategy is based on the combination of the user’s behaviour and comparing and contrasting that
with other users’ behaviour in the database. The history of all users plays an important role in this algorithm.
The main difference between content-based filtering and collaborative filtering that in the latter, the interaction
of all users with the items influences the recommendation algorithm while for content-
based filtering only the concerned user’s data is taken into account. There are multiple ways to implement
collaborative filtering but the main concept to be grasped is that in collaborative filtering multiple user’s data
influences the outcome of the recommendation. and doesn’t depend on only one user’s data for modelling.

There are 2 types of collaborative filtering algorithms:

[Link]-based Collaborative filtering:

The basic idea here is to find users that have similar past preference patterns as the user ‘A’ has had and then
recommending him or her items liked by those similar users which ‘A’ has not encountered yet. This is
achieved by making a matrix of items each user has rated/viewed/liked/clicked depending upon the task at
hand, and then computing the similarity score between the users and finally recommending items that the
concerned user isn’t aware of but users similar to him/her are and liked it.
For example, if the user ‘A’ likes ‘Batman Begins’, ‘Justice League’ and ‘The Avengers’ while the user ‘B’
likes ‘Batman Begins’, ‘Justice League’ and ‘Thor’ then they have similar interests because we know that
these movies belong to the super-hero genre. So, there is a high probability that the user ‘A’ would like ‘Thor’
and the user ‘B’ would like The Avengers’.

Disadvantages:

People are fickle-minded i.e their taste change from time to time and as this algorithm is based on user
similarity it may pick up initial similarity patterns between 2 users who after a while may have completely
different preferences.

There are many more users than items therefore it becomes very difficult to maintain such large matrices and
therefore needs to be recomputed very regularly.
This algorithm is very susceptible to shilling attacks where fake users profiles consisting of biased preference
patterns are used to manipulate key decisions.

[Link]-based Collaborative Filtering:

The concept in this case is to find similar movies instead of similar users and then recommending similar
movies to that ‘A’ has had in his/her past preferences.
This is executed by finding every pair of items that were rated/viewed/liked/clicked by the same user, then
measuring the similarity of those rated/viewed/liked/clicked across all user who rated/viewed/liked/clicked
both, and finally recommending them based on similarity scores.

Here, for example, we take 2 movies ‘A’ and ‘B’ and check their ratings by all users who have rated both the
movies and based on the similarity of these ratings, and based on this rating similarity by users who have
rated both we find similar movies. So if most common users have rated ‘A’ and ‘B’ both similarly and it is
highly probable that ‘A’ and ‘B’ are similar, therefore if someone has watched and liked ‘A’ they should be
recommended ‘B’ and vice versa.

Advantages over User-based Collaborative Filtering :

Unlike people’s taste, movies don’t change.


There are usually a lot fewer items than people, therefore easier to maintain and compute the matrices.
Shilling attacks are much harder because items cannot be faked.
Data Description:

A data set (or dataset) is a collection of data. In the case of tabular data, a data set corresponds to one or more
database tables, where every column of a table represents a particular variable, and each row corresponds to
a given record of the data set in question. The data set lists values for each of the variables, such as for example
height and weight of an object, for each member of the data set. Data sets can also consist of a collection of
documents or files.

In the open data discipline, data set is the unit to measure the information released in a public open data
repository. The European Open Data portal aggregates more than half a million data sets. Some other issues
(real-time data sources, non-relational data sets, etc.) increases the difficulty to reach a consensus about it.

This dataset contain 26 million ratings from 270,000 users for all 45,000 movies listed in the Full Movie Lens
Dataset. The dataset consists of movies released on or before July 2017. Data points include cast, crew, plot
keywords, budget, revenue, posters, release dates, languages, production companies, countries, TMDB vote
counts and vote averages.
Building a Movie Recommendation System:

The approach to build the movie recommendation engine consists of the following:

Perform Exploratory Data Analysis (EDA) on the data.


Build the recommendation system.
Get recommendations.

After downloading the dataset, we need to import all the required libraries and then read the csv file using
read_csv() [Link] you visualize the dataset, you will see that it has many extra info about a [Link] don’t
need all of them. So, we choose keywords, cast, genres and director column to use as our feature set(the so
called “content” of the movie).
If you visualize the dataset, you will see that it has many extra info about a [Link] don’t need all of them.
So, we choose keywords, cast, genres and director column to use as our feature set(the so called “content” of
the movie).Now, we need to call this function over each row of our dataframe. But, before doing that, we
need to clean and preprocess the data for our use.
We will fill all the NaN values with blank string in the dataframe. Now that we have obtained the combined
strings, we can now feed these strings to a CountVectorizer() object for getting the count matrix.

At this point, 60% work is done. Now, we need to obtain the cosine similarity matrixfrom the count matrix.
Now, we will define two helper functions to get movie title from movie index and vice-versa.
Our next step is to get the title of the movie that the user currently likes. Then we will find the index of that
movie.
After that, we will access the row corresponding to this movie in the similarity matrix.
Thus, we will get the similarity scores of all other movies from the current [Link] we will enumerate
through all the similarity scores of that movie to make a tuple of movie index and similarity score.

This will convert a row of similarity scores like this- [1 0.5 0.2 0.9] to this- [(0, 1) (1, 0.5) (2, 0.2) (3, 0.9)] .
Here, each item is in this form- (movie index, similarity score). Now comes the most vital point.
We will sort the list similar_movies according to similarity scores in descending order. Since the most similar
movie to a given movie will be itself, we will discard the first element after sorting the movies.

Now, we will run a loop to print first 5 entries from sorted_similar_movies list
INPUT

Here we use the movie_dataset.csv file.


The code goes as follows:
import pandas as pd import numpy as np from sklearn.feature_extraction.text import
CountVectorizer from [Link] import
cosine_similarity df = pd.read_csv("movie_dataset.csv") features =
['keywords','cast','genres','director'] def combine_features(row): return row['keywords'] +"
"+row['cast']+" "+row["genres"]+" "+row["director"] for feature in features: df[feature] =
df[feature].fillna('')
df["combined_features"] = [Link](combine_features,axis=1) cv = CountVectorizer()
count_matrix = cv.fit_transform(df["combined_features"]) cosine_sim =
cosine_similarity(count_matrix) def get_title_from_index(index): return df[[Link]
== index]["title"].values[0] def get_index_from_title(title):
return df[[Link] == title]["index"].values[0]
movie_user_likes = "Avatar" movie_index =
get_index_from_title(movie_user_likes) similar_movies =
list(enumerate(cosine_sim[movie_index]))
sorted_similar_movies = sorted(similar_movies,key=lambda x:x[1],reverse
=True)[1:] i=0 print("Top 5 similar movies to "+movie_user_likes+" are:\n") for element in
sorted_similar_movies:
print(get_title_from_index(element[0])) i=i+1 if i>=5: break

OUTPUT

Top 5 similar movies to Avatar are:

Guardians of the Galaxy


Aliens
Star Wars: Clone Wars: Volume 1
Star Trek Into Darkness
Star Trek Beyond
CONCLUSION

Recommendation systems have become an important part of everyone’s lives. With the enormous number of
movies releasing worldwide every year, people often miss out on some amazing work of arts due to the lack
of correct suggestion.
Putting machine learning based Recommendation systems into work is thus very important to get the right
recommendations.
We saw content-based recommendation systems that although may not seem very effective on its own, but
when combined with collaborative techniques can solve the cold start problems that collaborative filtering
methods face when run independently

You might also like