A Movie Recommendations: A Collaborative Filtering Approach Implemented in Python

<table>
<tbody>
<tr class="odd">
<td>ARTICLE INFO</td>
<td></td>
<td>ABSTRACT</td>
</tr>
<tr class="even">
<td><p><em>Article history:</em></p>
<p>Received</p>
<p>Revised</p>
<p>Accepted</p>
<p>Online first</p>
<p>Published 1 March 2024</p></td>
<td></td>
<td>In-home entertainment, selecting the perfect movie is a pervasive challenge, amplified by many streaming platforms like Netflix and Amazon. This study introduces a groundbreaking Movie Recommendation System with Collaborative Filtering (MRS-CF), meticulously implemented in Python. Employing Item-Based Collaborative Filtering with Cosine Similarity, the system assesses inter-movie relationships based on user-submitted titles, explicitly focusing on genre distinctions. The core contribution of MRAS-CF lies in its ability to expedite the movie selection process, swiftly presenting users with a curated list of ten recommended movies strategically organised by descending similarity. Augmented with individual similarity scores, this system is crafted to optimise the user’s movie-watching experience. Thirty participants were evaluated through the Perceived Ease of Use (PEOU). The PEOU results underscore the profound contribution of MRS-CF, revealing elevated user satisfaction across all dimensions. This research illuminates the potent impact of the Movie Recommendation System with Collaborative Filtering, emphasising its role as a transformative tool for refining and enhancing personalised movie recommendations.</td>
</tr>
<tr class="odd">
<td><p><em>Keywords:</em></p>
<p>Collaborative filtering</p>
<p>Recommendation system</p>
<p>Movie selection</p>
<p>Cosine similarity</p>
<p><em>DOI:</em></p>
<p>10.24191/jcrinn.v9i1</p></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

# Introduction

The World Wide Web has witnessed substantial growth, expanding both in the vastness of its knowledge space and the number of users it attracts. Consequently, navigating this expansive realm to locate pertinent information and effectively managing the abundance of data for informed decision-making has become increasingly challenging (Walek & Fojtik, 2020).

The surge in information volume has prompted a heightened focus on predictive filtering, refinement, and the coordinated delivery of pertinent content to users. Predictive methods have been employed to discern and gather information based on users’ preferences. Moreover, in recent years, there has been growing interest in ranking and organising information according to individual user interests (Wu et al., 2018).

Even though there were plenty of movie recommendation web-based systems available, like Netflix, YouTube and so on, this movie recommendation system cannot provide movies based on the user interest in the current time as it always recommends movies based on the users’ watching history (Husin et al., 2023). Also, the existing collaborative filtering used in the movie recommender system could only manage a small amount of data to provide detailed recommendations to the user (Parthasarathy & Sathiya Devi, 2023). This led to a problem where the system always recommends the same movie according to the user’s watching history. The current technique cannot handle the number of movies available as the current collaborative filtering cannot cope with the existence of the sparse matrix.

This paper proposed a Python-based system that recommended movies to users according to the users’ preferences, movie similarities, and ranking using the Collaborative Filtering and cosine similarity technique. This was because Collaborative Filtering was a recommendation tool that collected information on the search movie titles from related movies to determine the movies that were similar to it in terms of genre. The fundamental principle of Collaborative Filtering was that the movie title the user entered and submitted was the same as the user preferred.

# background

This section briefly provides background on recommendation systems, collaborative filtering, user similarity computation, rating prediction and Pyhton.

## Recommendation System

A recommendation system was an information filtering system that sorted items based on the similarity of items and user preferences. The first work on recommendation systems came in the mid-1990s. It has become a vital study topic (Shani & Gunawardana, 2011). Over the last decade, commerce and research have collaborated to create novel ways to enhance the quality of recommender systems (Gogna & Majumdar, 2015). Due to overflowing issues, the recommendation system has become an integral feature of e-commerce and social platforms in the latest generations. In an era of big data, recommendation systems have evolved to help users find exciting items based on interests or preferences (Parthasarathy & Sathiya Devi, 2023).

Besides that, recommender systems analyse detailed data to forecast user preferences for different components (Razak et al., 2019). Following that, based on these findings, (Lu et al., 2015) provided predictions and adjusted the contents of the presented webpage as much as feasible to match the user’s interest and request together with the similarity of the items that the user rated or liked. It was one of the justifications for why various businesses and web applications had recently introduced systems that analysed user behaviour and interest in certain things and items to recommend the best service, solutions, or content. The goal was, of course, to enhance these corporations’ revenues and profits. It was used in various fields, including online education, e-commerce, etc. YouTube, Amazon.com, Netflix, Facebook, and others were such services. Nevertheless, according to (Walek & Fojtik, 2020), it was primarily concerned with broadcasting services and online digital movies. Amazon and Netflix were two of the most renowned adopters of recommender systems.

## Collaborative Filtering

Another primary approach in the Recommendation System was the Collaborative Filtering algorithm. It collected and analysed enormous amounts of information on all users’ behaviours and preferences and then predicted the items where users would like similar items to other similar users (Guo et al., 2017). Collaborative Filtering (CF) forecasts a user’s rating for web applications by considering other users’ evaluations of the products (Yao et al., 2014). International and domestic researchers and specialists have conducted an in-depth study on Collaborative Filtering suggestions; thus, Collaborative Filtering recommendation algorithms were numerous. Each Collaborative Filtering recommendation algorithm has a unique working concept; in practice, various Collaborative Filtering recommendation algorithms offer distinct advantages, while flaws such as data sparsity, cold boot, poor scalability, and others were evident (Guo et al., 2017). Data sparsity problems could occur when users rank only a few items. Most recommender systems group the ratings of similar users. However, due to a massive lack of resources or acute awareness to evaluate objects, the presented user-item matrix has vacant or undetermined ratings up to 99%, according to (Isinkaye et al., 2015). As a result, recommender systems may make irrational suggestions if no reviews or ratings are provided. The cold start problem also occurs during collaborative filtering, where the term “cold start” comes from the automotive industry. It had difficulties starting when the engine was cold but ran perfectly once it reached the ideal temperature. A similar situation applies to Recommender Systems. A Recommender System does not operate optimally when inadequate data or content is provided (Isinkaye et al., 2015).

## User Similarity Computation

In Collaborative Filtering recommendation systems, user similarity was determined using the widely utilised cosine similarity technique. If a user does not review items, the user’s ratings are assigned to 0 (Parthasarathy & Sathiya Devi, 2023). This method would find the similarities between the movie items and suggest the movie is like the valid movie title entered by the user regarding the movie genre and similarity based on the movie from the datasets. Figure ‎1 shows how the user similarity between user and item data worked in the system’s modules.

![](65ba4de56e4bc_media/media/image1.png)

Figure 1. Modules of the user similarity and item data. Taken from (Özbal et al., 2011).

## Rating Prediction

The rating prediction was computed on an unrated user item obtained from the active user’s neighbours K items. In rating prediction, it wanted to forecast the implicit and interacting information elements simultaneously (Schein et al., 2002). It can be measured by the degree of resemblance between users. Then, based on user similarity values, a set for the first k users near the active user will be generated (Parthasarathy & Sathiya Devi, 2023). Rating prediction was under the Memory-Based Collaborative Filtering method; users store the entire grouping of previously rated things. This data was saved as a user-item matrix (Özbal et al., 2011). This method will recommend movies depending on the dataset’s movie rating information.

## Python Based 

Python was a powerful programming language frequently used to create websites and applications, automate operations, and analyse data (Blank et al., 2003). Python was a powerful programming language. It could develop a wide range of applications and was not specialised for any particular problem. This adaptability, along with its ease of use for beginners, has established this as one of the most widely used programming languages. Python was frequently used to create the back end of web-based application elements, which the user did not seem to see. Python’s function in website development may include transmitting and receiving information from websites, analysing and dealing with datasets, URL navigation, and encryption. Python provides several libraries for website development. Django and Flask are two popular ones.

# A MOVIE recommendation system – python-based

This section will explore the methodology and approach for designing the Python-based movie recommendation system. There are four critical steps to developing a movie recommendation system, as described in the following section.

## Step 1: Data Collection – Secondary and Online Survey

This study collected data through the survey and secondary dataset related to movies. The data that was obtained from the study was recorded.

***Online Survey***

A survey was conducted using Google Forms involving nine questions with two parts of questions. Forty-five respondents responded to the study, with 28 females and 17 males. The survey showed that most respondents think this movie recommendation system was interesting to use to satisfy movie recommendations. Figure 2, Figure 3 and Figure 4 show some of the questions available in the survey.

![](65ba4de56e4bc_media/media/image2.png)

Figure 2. Question on “Difficult in Finding Movie”.

![](65ba4de56e4bc_media/media/image3.png)

Figure 3. Question on “Movie Recommendation Not Accurate”.

![](65ba4de56e4bc_media/media/image4.png)

Figure 4. Question on “Interest in Movie Recommendation System Development”.

From the survey, most of the respondents agreed about developing this movie recommendation system with collaborative filtering. This movie recommendation system would be interesting to use.

***Secondary Dataset***

This study also used the dataset that was available online. The dataset used was known as the MovieLens dataset gathered by the GroupLens Research Project at the University of Minnesota. This data set consisted of 4802 movies with all data related to the movie: movie ID, movie title, genre, and release date. It also provided the average user rating for each movie in the dataset.

**Step 2: Development of A Movie Recommender System**

The approaches used in developing the recommender system in this project were Collaborative Filtering, cosine similarity and Item-based recommendation.

***Collaborative Filtering***

This study used a Collaborative Filtering Algorithm. The system can automatically recommend movies to users based on the movie genre analysed from the movie title that the user had entered. It is worth noting that, even with a collaborative filtering approach, similarities were not discovered using user ages or other information about individuals or products. It was determined strictly based on a user’s direct or indirect preferences for an item. For example, two users might be deemed comparable despite a significant age gap if they offer the same genre to 10 movies. With this, an item-based collaborative filtering algorithm was used to ensure the movies’ genre could be used to recommend movies with the highest similarity rating value.

***Item-Based Recommendation***

Item-based Collaborative Filtering has been an excellent method that generates precise recommendations. The primary concept behind this method was to seek things comparable to those that users already had submitted. This study used this approach to compare the movie genre from the movie title the user submitted to locate the identical movie according to the genre by applying it to the Cosine Similarity.

***Cosine Similarity***

Next, Cosine Similarity was used to determine the degree of similarity between the two elements. The Cosine Similarity provided a value that quantifies the similarity between two components, with -1 being the least similar and one being the most similar. The datasets must be imported into the project environment to identify the similarity. To read the data from the datasets, pandas must be installed to ensure that the data can be accessed using the functions and methods found in the pandas. For instance, the Cosine Similarity function was used to identify the similarity of the movies based on the genre. The code in Figure 5 demonstrates how to import pandas and use the function to determine which movies were comparable to the needed film based on their genre.

![](65ba4de56e4bc_media/media/image5.png)

Figure 5. Import Pandas and Cosine Similarity Function.

**Step 3: Python GUI Design**

Python has a plethora of frameworks and provides several possibilities for designing a Graphical User Interface (GUI). The most used GUIs in Python were Tkinter, wxPython, and JPython. These GUIs have a toolkit and package that must be imported into the environment. In this project, the GUI was used as a Tkinter.

***Tkinter Library***

Tkinter is the most widely used of all the GUI techniques. It was a standard Python interface to the Python-supplied Tk GUI toolkit. Python with Tkinter was the quickest and most effortless approach to constructing Graphical User Interface (GUI) applications. Tkinter extends the Tk GUI toolkit with a robust object-oriented interface. This toolkit came with 15 types of widgets.

***Flask Framework***

This study was developed using the Python programming language, so it can only be viewed and run in the Python environment. The Flask framework was used in this project to enable this system to operate in a web browser. Its environment needed to be activated in the cmd to use the Flask. Figure 6 shows starting this framework by specifying the project file name. Once activated, this framework provided a web host server to run the system.

![](65ba4de56e4bc_media/media/image6.png)

Figure 6. Activate Flask Framework.

## Step 4: GUI – A Movie Recommendation System

This section discusses the interface of the main system page. Figure 7 shows the system’s main page with a text box area where users can enter the movie title. It also came with two buttons: the submitted button and the reset button. Users must click the submit button to get the recommendation once they enter the movie title.

![](65ba4de56e4bc_media/media/image7.png)

Figure 7. Main Page.

Once users click the submit button, it will redirect them to the recommendation page, listing ten similar movies to the movie title offered by the users. The list of recommended movies was in descending order from the most similar movie to the least equal movie. It would also display the movie releases, as shown in Figure 8. On the other hand, Figure 9 shows the recommended similarity score of the movie, where value 1 indicates the most similarity. In contrast, value -1 indicated the least similar movie. This similarity score was displayed in the running Flask framework in the cmd. However, as this system uses the dataset data, the users need to submit a valid movie title just like in the dataset. Suppose the users offered an invalid movie title. In that case, the system will display some title suggestions of the user’s submitted title, as shown in Figure 10. A go-back-to-the-homepage button was available where users could try again and present a valid movie title.

![](65ba4de56e4bc_media/media/image8.png)

Figure 8. List of Movie Recommended Page.

![](65ba4de56e4bc_media/media/image9.png)

Figure 9. Similarity Score.

![](65ba4de56e4bc_media/media/image10.png)

Figure 10. Valid Movie Title Suggestion.

# evaluation of a movie recommendation

To validate the proposed movie recommendation system, we have conducted a Perceived Ease of Use (PEOU) test on Thirty respondents from different backgrounds. The PEOU indicates the degree to which the Movie Recommendation System with Collaborative Filtering is considered relatively simple to use and understand. Please note that this testing was conducted online through Google Forms. All 30 respondents must watch the Movie Recommendation System with Collaborative Filtering demonstration video. Then, they need to answer the question in the Google Form provided.

## Perceived Ease of Use (PEOU)

Five questions were available for the Perceived Ease of Use (PEOU) section used to measure the degree to which this Movie Recommendation System with Collaborative Filtering is considered relatively easy to use and understand. Here are the results obtained from the respondents and the graph for each available question, as in Figure 11.

![](65ba4de56e4bc_media/media/image11.png)

Figure 11. Mean Score for Perceived Ease of Use.

The chart in Figure 11 depicts the mean score for the Perceived Ease of Use assessment criterion. The findings indicated that most respondents thought the Movie Recommendation System with Collaborative Filtering was simple. The mean score may demonstrate it for each question, more significant than 4.0 but less than the agreed-upon scale. The respondents believe the Collaborative Filtering and Recommendation System for Movies is simple to use and explore. The mean score was 4.8.

Additionally, respondents found that the interactions between the Movie Recommendation System and Collaborative Filtering were evident and intelligible, with a mean score of 4.7. Utilising the system took less mental effort, with a mean score of 4.9. With a mean score of 4.8, the system enables them to operate it independently. Most respondents believed this method was simple, with a mean score of 4.7 indicating its applicability. Thus, the overall findings of Perceived Ease of Use suggested that most participants believed the Movie Recommendation System with Collaborative Filtering was simple since it did not require much mental effort.

# conclusion

In conclusion, we introduced a Python-based movie recommendation system. Despite receiving positive feedback from the testing results, respondents provided valuable suggestions and recommendations for enhancing the system. This highlights that although the Movie Recommendation System utilising Collaborative Filtering is functional, there is room for improvement in various features for future use.

For future enhancements, we plan to leverage a larger dataset to elevate the movie recommendation system to a higher standard of excellence and perfection. By incorporating a more extensive and diverse data collection, we aim to enhance the functionality and precision of our movie recommendation algorithm, providing users with even more accurate and personalised suggestions.

# Acknowledgements/Funding 

The authors would like to acknowledge the support of Universiti Teknologi Mara (UiTM), Shah Alam, Selangor, Malaysia, for providing this research's facilities and financial support.

# Conflict of interest statement

The authors declared that they have no conflicts of interest to disclose.

# 

# References

Blank, D., Kumar, D., Meeden, L., & Yanco, H. (2003). Pyro: A Python-based versatile programming environment for teaching robotics. *Journal on Educational Resources in Computing (JERIC)*, *3*(4), 1-es.

Gogna, A., & Majumdar, A. (2015). A comprehensive recommender system model: Improving accuracy for warm and cold start users. *IEEE Access*, *3*, 2803–2813.

Guo, B., Xu, S., Liu, D., Niu, L., Tan, F., & Zhang, Y. (2017). Collaborative filtering recommendation model with user similarity filling. *2017 IEEE 3rd Information Technology and Mechatronics Engineering Conference (ITOEC)*, 1151–1154.

Husin, M. R. M., Razak, T. R., Malik, A. M. A., Nordin, S., & Abdul-Rahman, S. (2023). Hybrid Collaborative Movie Recommendation System. *2023 4th International Conference on Artificial Intelligence and Data Sciences: Discovering Technological Advancement in Artificial Intelligence and Data Science, AiDAS 2023 - Proceedings*, 274–280. https://doi.org/10.1109/AIDAS60501.2023.10284679

Isinkaye, F. O., Folajimi, Y. O., & Ojokoh, B. A. (2015). Recommendation systems: Principles, methods and evaluation. *Egyptian Informatics Journal*, *16*(3), 261–273.

Lu, J., Wu, D., Mao, M., Wang, W., & Zhang, G. (2015). Recommender system application developments: a survey. *Decision Support Systems*, *74*, 12–32.

Özbal, G., Karaman, H., & Alpaslan, F. N. (2011). A content-boosted collaborative filtering approach for movie recommendation based on local and global similarity and missing data prediction. *The Computer Journal*, *54*(9), 1535–1546.

Parthasarathy, G., & Sathiya Devi, S. (2023). Hybrid Recommendation System Based on Collaborative and Content-Based Filtering. *Cybernetics and Systems*, *54*(4), 432–453.

Razak, T. R., Halim, I. H. A., Jamaludin, M. N. F., Ismail, M. H., & Fauzi, S. S. M. (2019). An Exploratory Study of Hierarchical Fuzzy Systems Approach in A Recommendation System. *Jurnal Intelek*, *14*(2), 174–186. https://doi.org/10.24191/JI.V14I2.233

Schein, A. I., Popescul, A., Ungar, L. H., & Pennock, D. M. (2002). DNA extraction from plant leaves with Minilys. *Proceedings of the 25th Annual International ACM SIGIR Conference on Research and Development in Information Retrieval-SIGIR*, *2*, 253–260.

Shani, G., & Gunawardana, A. (2011). Evaluating recommendation systems. *Recommender Systems Handbook*, 257–297.

Walek, B., & Fojtik, V. (2020). A hybrid recommender system for recommending relevant movies using an expert system. *Expert Systems with Applications*, *158*, 113452. https://doi.org/10.1016/J.ESWA.2020.113452

Wu, C.-S. M., Garg, D., & Bhandary, U. (2018). Movie recommendation system using collaborative filtering. *2018 IEEE 9th International Conference on Software Engineering and Service Science (ICSESS)*, 11–15.

Yao, L., Sheng, Q. Z., Ngu, A. H. H., Yu, J., & Segev, A. (2014). Unified collaborative and content-based web service recommendation. *IEEE Transactions on Services Computing*, *8*(3), 453–466.
