You are on page 1of 55

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

Jnana Sangama, Belgavi-590018

A Project Phase -II(18CSP83)


Report on
“MACHINE LEARNING BASED BOOK
RECOMMENDATION ENGINE IN
PYTHON”
Submitted in partial fulfillment of the requirement for award of degree
of
BACHELOR OF ENGINEERING
in
INFORMATION SCIENCE AND ENGINEERING
by

M ANILA 1EP20IS049
SHRAVANI S L 1EP20IS083
AYESHA MUSKAN KHAN M 1EP20IS107

Under the guidance of

Sindhuja M
Asst. Professor
Dept. of ISE, EPCET

DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING


Jnana Prabha, Bidarahalli, Virgo Nagar Post, Bengaluru, Karnataka 560049
2023-24
DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING
Jnana Prabha, Bidarahalli, Virgo Nagar Post, Bengaluru, Karnataka 560049

CERTIFICATE

This is to certify that the project work phase II (18CSP77) entitled “MACHINE LEARNING
BASED BOOK RECOMMENDATION ENGINE IN PYTHON” is a bona fide work carried
out by M ANILA [1EP20IS049], SHRAVANI S L [1EP20IS083] and AYESHA MUSKAN
KHAN
M [1EP20IS107] in the partial fulfillment of the requirements of VIII semester of BACHELOR
OF ENGINEERING in INFORMATION SCIENCE AND ENGINEERING, VISVESVARAYA
TECHNOLOGICAL UNIVERSITY, Belagavi, during the year 2023-24. It is certified that corrections/
suggestions indicated for internal assessment have been incorporated in this Project Phase II (18CSP83)
report deposited in the department library. The project report has been approved as it satisfies the academic
requirements prescribed for the University.

Prof. Sindhuja M Prof. Kemparaju Dr. Mrityunjaya V Latte


Project Guide N HOD - ISE Principal,
Department of EPCET, Bangalore EPCET, Bangalore
ISE

External Viva:

Name of the Examiners Signature with date

1.

2.
ACKNOWLEDGEMENT

Any achievement, be it scholastic or otherwise does not depend solely on individual efforts but on
the guidance, encouragement, and cooperation of intellectuals, elders, and friends. I want to take
this opportunity to thank them all.
We would like to express our sincere thanks to the management of EPCET for providing the
necessary infrastructure and creating a good environment.
We express our gratitude to Dr. Mrityunjaya V Latte, Principal, and EPCET who has always been a
great source of inspiration.

We would like to express our sincere thanks to Prof. Kemparaju N, Professor and Head of the
Department of Information Science and Engineering, EPCET for his valuable suggestions and
encouragement to do our best in this project work.

We would like to express our gratitude towards our guide Prof. Sindhuja M, Assistant Professor,
Department of ISE, and the project coordinator Prof. Neelima Sahu Assistant Professor,
Department of ISE for their valuable guidance and constant supervision in completing the project
work phase II successfully.

We would like to extend our thanks to all the faculty members of the ISE department for their
valuable input as reviewers during the project work.

Finally, we would like to thank our parents and friends for their support and encouragement in
completing the project work phase II.

M ANILA [1EP20IS049]
SHRAVANI S L [1EP20IS083]
AYESHA MUSKAN KHAN M [1EP20IS107]
ABSTRACT
This project presents a web app that gives book suggestions to users based on their likes and ratings.
It uses two methods to make the suggestions: popularity-based filtering and collaborative filtering.
The first method suggests books that are rated high by everyone, while the second method suggests
books that are similar to a chosen book, based on other users' ratings. The web app is built with
Flask, a Python web framework, and uses data about books and ratings. The data is processed to fit
the methods. The web app has two features- one that shows popularity-based suggestions, and
another that takes a book name and shows collaborative filtering suggestions. The goal of this
project is to create a useful and easy book recommender system that can help online bookstores or
libraries by giving personalized book tips to their customers, based on their preferences.
CONTENTS

Chapter
Description Page No.
No.
1 Introduction 1

1.1 Introduction To The Project 1

1.2 Background 6

1.3 Existing System 9

1.4 Proposed System 9

1.5 Problem Statement 10

1.6 Aim of the Project 10

1.7 Objectives of the Project 10

1.8 Summary 10

1.9 Python Programming Language 11

2 Literature Survey 13

3 Requirements Specification 16

3.1 Software Requirements 17

3.2 Hardware Requirements 17

3.3 Functional Requirements 19

3.4 Non-Functional Requirements 19

4 System Analysis 21
4.1 System Analysis 21
4.2 System Architecture 21

4.3 Modules to be implemented


23

4.4 Activity Diagram


24

4.5 State Transition Diagram


25

4.6 Flow Chart


26

4.7 Use Case Diagram


27
5
System Implementation
28

5.1 Recommendation Of Books to the User


28

5.2 Code Snippet


30
6
Verification and Validation
40

6.1 Functional Testing


40

6.2 Usability Testing


40

6.3 Interface Testing


41

6.4 Compatability Testing


41

6.5 Performance Testing


41
7
Results 42

Conclusion 45

References 46
LIST OF FIGURES
Fig. No. Description Page No.

Content-Based Filtering
1.1 2
1.2 Collaborative-based Filtering
3

1.3 Hybrid Filtering Method 4

1.4 Various Books to be Recommended


8

3.5 PyCharm 17

3.6 Python 18

4.1 System Architecture 22

4.2 Activity Diagram 24

4.3 State Transition Diagram 25

4.4 Flow Chart of Book Recommendation using ML Algorithms 26

4.5 Use Case Diagram 27

7.1 Home Page 42

7.2 Top 50 Books 42

7.3 Recommendation Page 43

7.4 Asking For Recommendation 43

7.5 Recommended Books 44


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Chapter 1

INTRODUCTION
1.1 Introduction to the Project
The Project is about a machine learning-based recommendation system for book selection using user-based
collaborative filtering algorithm. A machine learning-based recommendation system is a type of system that
uses patterns and trends in data to predict a user's interests or preferences. It essentially learns from past user
behavior to make these predictions. For example, in an online shopping scenario, the system would analyze a
user's past purchases, browsing history, and ratings. It would then use this information to recommend products
that the user might be interested in. This could include items that are similar to those the user has bought or
liked in the past, or items that other users with similar tastes have shown interest in. The goal of these systems is
to provide personalized recommendations that improve the user experience, increase user engagement, and
ultimately drive more sales or usage. They are a key component of many online platforms, including e-
commerce sites, streaming services, and social media platforms. They help users navigate through large
amounts of information and make choices that are most relevant to them.

This aims to provide an overview of the recommendation systems that are currently used in the online book
shopping domain and to propose a simple and understandable system for book recommendations that help
readers choose the right book to read next. This focuses on the information analysis challenge of the
recommendation system and uses a user-based collaborative filtering approach to measure the similarity
between users and recommend books based on their ratings. User-Based Collaborative Filtering is a technique
used in recommendation systems to predict the items that a user might like based on the ratings given to those
items by other users who have similar tastes.

The first step is to find users who are similar to the target user. This similarity can be calculated using various
methods. Once similar users are identified, the system predicts the rating of an item for the target user that they
haven't rated yet. This prediction is based on the weighted average of the ratings of the item by the users who
are similar to the target user. The weights are the similarity scores between the target user and each of the
similar users. This approach is often used in many websites for building their recommendation systems. This
compares different similarity measures, such as Pearson correlation coefficient, constrained Pearson correlation,
cosine similarity, and Jaccard similarity, and evaluates their performance in recommending books to a user.
This presents the overall architecture and implementation of the proposed system and demonstrates its
effectiveness and efficiency.

Dept of ISE, EPCET 2023-24 Page 1


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

1.1.1 What is a Recommendation System


A recommendation engine is a class of machine learning that offers relevant suggestions to the
customer. Before the recommendation system, the major tendency to buy was to take a suggestion from friends.
But Now Google knows what news you will read, YouTube knows what type of videos you will watch based on
your search history, watch history, or purchase history.
A recommendation system helps an organization to create loyal customers and build trust in the desired
products and services for which they came to your site. The recommendation system today is so powerful that it
can handle new customers too who have visited the site for the first time. They recommend the products which
are currently trending or highly rated and they can also recommend the products which bring maximum profit to
the company.
1.1.2 Types Of Recommendation System
A recommendation system is usually built using 3 techniques which are content-based filtering, collaborative
filtering, and a combination of both.
 Content-Based Filtering
The algorithm recommends a product that is similar to those used as watched. In simple words, In this
algorithm, we try to find items that look alike.
For example, a person likes to watch Sachin Tendulkar's shots, so he may like watching Ricky Ponting's
shots too because the two videos have similar tags and similar categories. Only it looks similar to the
content and does not focus more on the person who is watching this. Only it recommends the product
which has the highest score based on past preferences.

Fig 1.1 Content-Based Filtering

Dept of ISE, EPCET 2023-24 Page 2


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

 Collaborative-based Filtering
Collaborative-based filtering recommender systems are based on past interactions between users and
target items. In simple words here, we try to search for the look-alike customers and offer products
based on what his or her lookalike has chosen. Let us understand with an example. X and Y are two
similar users and X users have watched A, B, and C movies. If the Y user has watched B, C, and D
movies then we will recommend A movie to the Y user and D movie to the X user.
YouTube has shifted its recommendation system from content-based to collaborative-based filtering
techniques. If you have sometimes there are also videos which are not at all related to your history but
then also it recommends it because the other person similar to you has watched it.

Fig 1.2 Collaborative-based Filtering

 Hybrid Filtering Method


It is a combination of both the above methods. It is a too complex model that recommends products based
on your history as well based on similar users like you.
Some organizations use this method like Facebook which shows news that is important for you and others
in your network and the same is used by LinkedIn too.

Dept of ISE, EPCET 2023-24 Page 3


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Fig 1.3 Hybrid Filtering Method

1.1.3 What is a Book Recommendation System


A Book Recommendation System is a type of recommendation system that suggests books to readers
based on their interests. It's used by online platforms that provide e-books, like Google Play Books, Open
Library, Goodreads, etc. Here's a detailed explanation:
A recommendation system is a class of machine learning that offers relevant suggestions to the user. It helps an
organization create loyal customers and build trust by offering them the desired products and services. They can
even handle new customers who visit the site for the first time by recommending trending or highly rated
products. A book recommendation system is designed to recommend books of interest to the reader. It predicts
the reader's interest and recommends books accordingly. It can take into account many parameters like book
content and book quality by filtering user reviews.
In essence, a book recommendation system aims to enhance the reading experience by suggesting books that
align with the reader's preferences and reading history. It plays a crucial role in helping readers discover new
books.

Dept of ISE, EPCET 2023-24 Page 4


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

1.1.4 Why do we need it


• Enhanced User Experience: The primary goal of a recommendation system is to enhance the user
experience by presenting appealing options that align with individual preferences.
• Increased User Retention: Matching recommendations well can help improve overall user
satisfaction, making the consumer more likely to use the website or app again.
• Discovery of New Books: A book recommendation system can help users discover new books that
they might not have found on their own.
• Personalization: Recommendation systems act as an automated form of a customer assistant that not
only shows the product you asked for but also shows ones that are somehow related or you might also
like.
• Increased Sales: One of the best-known users and pioneers of recommendation systems is Amazon.
Amazon uses recommendations to personalize the online store for each customer, which results in 35%
of Amazon’s revenue.
• Improving Literacy Skills: A book recommendation system can provide students with an opportunity
to review what they have read by retelling, based on their understanding and perspectives, which can
greatly improve their literacy skills, reading comprehension, and recollection.
• Supporting Reading Habits: The fundamental reason for this project is to support folks who have an
interest in reading and to influence those individuals who are inculcating the habit of reading.
1.1.5 Where to use it
A book recommendation system can be utilized in various contexts to enhance the reading experience and
streamline the discovery of books. Here are some areas describing where this system can be applied:
 Online Bookstores and Libraries:
Online bookstores and libraries can integrate a book recommendation system to suggest titles to readers
based on their browsing history, past purchases, or preferences. This personalized approach helps users
find books that align with their interests, leading to increased satisfaction and potentially higher sales for
bookstores.
 Educational Institutions:
Educational institutions, such as schools and universities, can use book recommendation systems to
guide students towards relevant literature for their courses or research topics. By analyzing the
curriculum and individual student profiles, the system can recommend books that supplement their
learning and academic growth.
 Reading Apps and E-Readers:
Reading applications and e-readers can incorporate recommendation algorithms to suggest new books to
users based on their reading habits. This feature keeps readers engaged by providing a continuous stream

Dept of ISE, EPCET 2023-24 Page 5


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

of curated content that matches their reading style and genre preferences.
 Book Clubs and Reading Communities:
Book clubs and reading communities can leverage recommendation systems to select their next group
read. By considering the collective tastes and previous discussions of the group, the system can propose
books that are likely to spark interest and lively conversation among members.
In each of these scenarios, a book recommendation system serves as a valuable tool for connecting
readers with books that resonate with them, fostering a culture of reading and exploration within the
literary world.

1.2 Background
A book recommendation system works by using machine learning algorithms to suggest books that align with a
user's preferences. Here's a step-by-step explanation:
 Data Collection: The first step is to collect data about the books and the users. This includes
information about the books (like author, genre, publication year, etc.), user interactions (like ratings,
reviews, purchase history, etc.), and user demographics (like age, location, etc.).
 Data Preprocessing: The collected data is then preprocessed to handle missing values, remove outliers,
and convert text data into a format that can be used by the machine learning algorithms¹.
 Exploratory Data Analysis (EDA): EDA is performed to understand the data better. This includes
finding the top-rated books, the most prolific authors, the distribution of ratings, etc.
 Building the Recommendation Model:
• Content-Based Filtering: This algorithm recommends books that are similar to the ones the
user has interacted with in the past. For example, if a user likes a particular author's book, they
may like other books by the same author.
• Collaborative Filtering: This algorithm recommends books based on the past interactions of
other users who have similar preferences. For example, if two users have read similar books
and one of them reads a new book, that new book may be recommended to the other user.
• Hybrid Filtering: This combines both content-based and collaborative filtering to make
recommendations.
 Making Recommendations: The recommendation model is then used to predict the user's interest and
recommend books accordingly. The system can take into account many parameters like book content
and book quality by filtering user reviews.
 Evaluation and Updating: The performance of the recommendation system is evaluated using metrics
like precision, recall, F1-score, etc. The system is regularly updated with new data to ensure that the
recommendations stay relevant.
In essence, a book recommendation system works by understanding the user's preferences and using

Dept of ISE, EPCET 2023-24 Page 6


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77
this understanding to recommend books that the user might enjoy.

Dept of ISE, EPCET 2023-24 Page 7


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

1.2.1 Evolution of Book Recommendation System


Book recommendation systems are a type of recommendation systems that suggest books to readers
based on their interests. The first book recommendation system was Tapestry, which was proposed in 1992 by
Goldberg et al. It was based on collaborative filtering, which means that it used the ratings and reviews of other
users to recommend books. However, collaborative filtering had some limitations, such as the cold start
problem and the sparsity problem. To overcome these issues, content-based filtering was introduced, which
used the features and attributes of the books, such as author, genre, and keywords, to recommend books.
Content-based filtering was more personalized, but it also suffered from some drawbacks, such as the
overspecialization problem and the lack of serendipity.
To combine the advantages of both methods, hybrid filtering was developed, which integrated collaborative
filtering and content-based filtering in various ways. Hybrid filtering improved the accuracy and diversity of
book recommendations and became the dominant approach in the field. Nowadays, book recommendation
systems use advanced machine learning techniques, such as deep learning and natural language processing, to
further enhance the quality and efficiency of book suggestions.
1.2.2 The Future of Book Recommendation System
The future of book recommendation systems is promising and exciting, as they are constantly evolving
and improving with new technologies and techniques. Here are some possible trends and directions for the
future of book recommendation systems:
 Deep Learning:
Deep learning is a branch of machine learning that uses neural networks to learn from complex and
large- scale data. Deep learning can enhance the performance and accuracy of book recommendation
systems by capturing the latent features and preferences of users and books, as well as the contextual
and temporal information. For example, deep learning can help recommend books based on the user's
mood, location, time, or social network.
 Natural Language Processing (NLP):
NLP is a field of computer science that deals with the interaction between human language and
computers. NLP can improve the quality and diversity of book recommendations by analyzing the
textual content of books, such as the title, summary, genre, author, and reviews. For example, NLP can
help recommend books based on the semantic similarity, sentiment, or topic of the books.

 Personalization and Serendipity:


Personalization and serendipity are two important aspects of book recommendation systems that aim to
satisfy the user's needs and preferences, as well as to surprise and delight the user with novel and
unexpected suggestions. Personalization and serendipity can be achieved by using hybrid filtering,

Dept of ISE, EPCET 2023-24 Page 8


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77
which

Dept of ISE, EPCET 2023-24 Page 9


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

combines content-based and collaborative filtering, as well as by incorporating user feedback, diversity,
and exploration⁵. For example, a book recommendation system can personalize the recommendations
by considering the user's reading history, goals, and interests, and also introduce some serendipitous
recommendations by suggesting books that are outside the user's comfort zone, but still relevant and
appealing.
In essence, the future of book recommendation systems is driven by the advancement of machine
learning, natural language processing, and user-centric design, which can provide more relevant,
diverse, novel, and serendipitous book suggestions to readers.

Fig 1.4 Various Books to be Recommended

Dept of ISE, EPCET 2023-24 Page 10


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

1.3 Existing System


 The existing system is a book recommendation system with TensorFlow, a framework for building
machine learning models.
 The system uses collaborative filtering to predict user ratings for books based on their past ratings and
the ratings of other similar users.
 The system also uses TensorFlow Recommenders, a library that simplifies the workflow of building a
recommender system.
1.3.1 Disadvantages of Existing System
 It may suffer from the cold start problem, which means it cannot recommend books to new users or
new books to existing users, because there is not enough rating data for them.
 It may not capture the content features of the books, such as genre, author, or theme, which may
affect the user's preference and satisfaction.
 It may not handle sparse or skewed data well, which means there may be many missing or
imbalanced ratings in the user-book matrix, affecting the accuracy and diversity of the
recommendations.

1.4 Proposed System


 The proposed system is a book recommendation system that uses user-based collaborative filtering
(UBCF) to suggest books to readers based on their preferences and ratings.
 The system uses different similarity measures, such as Pearson correlation coefficient, constrained
Pearson correlation, cosine similarity, and Jaccard similarity, to compute the similarity between users
and find the nearest neighbors.
 The system then applies the deviation from the mean method to predict the ratings for the books that the
target user has not rated yet and generates the top n recommendations based on the sorted scores.
 The system also uses the content of the books, such as genres and authors, to enhance the
recommendation quality.
 The system aims to provide an efficient and reliable way to help users find the right books to read.
1.4.1 Advantages of Proposed System
It can provide personalized recommendations that match the user's interests and tastes.
It can handle sparse data by using cosine similarity, which only considers the co-rated items between
users and ignores the missing ratings.
It can leverage the rich content information of books, such as genres, authors, and tags, to enhance the
recommendation quality and diversity.

Dept of ISE, EPCET 2023-24 Page 11


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

1.5 Problem Statement


This project typically addresses the challenge of providing personalized book recommendations to users
based on the preferences and behaviors of similar users. It involves analyzing user ratings, identifying
patterns, and predicting which books a user might like, considering the likes and dislikes of users with
similar tastes. The goal is to enhance user satisfaction by recommending books that align with individual
preferences, thereby improving the overall experience of discovering and selecting books.

1.6 Aim of the Project


We develop a book recommendation system using user-based collaborative filtering and various
similarity measures.

1.7 Objectives of the project


 To design and implement a machine learning based recommendation system for book selection using
user-based nearest neighbor.
 To apply the deviation from mean method to predict the ratings of books that a user has not rated yet,
based on the ratings of other similar users.
 To generate the top n recommendations for a user, based on the predicted ratings and the user's
preferences.
 To evaluate the accuracy and efficiency of the proposed system using the Goodreads-books dataset and
various metrics, such as recall, precision, F-score, and mean average precision.
 To provide a user-friendly interface for the online book portal, where users can browse, rate, and
receive recommendations for books.

1.8 Summary
It suggests a simple and understandable system for book recommendations that help readers find the
right book to read next. It also compares different similarity measures and evaluates the performance of
the proposed system. The purpose of this project is to enhance the user experience and satisfaction in
online book shopping and to contribute to the field of recommender systems.

Dept of ISE, EPCET 2023-24 Page 12


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

1.9 Python Programming Language


Python is a very popular general-purpose interpreted, interactive, object-oriented, and high-level
programming language. Python is a dynamically typed and garbage-collected programming language. It was
created by Guido van Rossum during 1985- 1990. Like Perl, Python source code is also available under the
GNU General Public License (GPL).

These are the Advantages of Learning Python:


 Interpreted Nature: Python code is executed by an interpreter, which means there's no need for prior
compilation. This feature is shared with languages like PERL and PHP.
 Interactive Experience: Python allows for interactive coding sessions, where programmers can write
and test their code in real time using the Python prompt.
 Object-Oriented Design: Python supports object-oriented programming (OOP), a paradigm that
organizes code within objects, enhancing modularity and reusability.
 Beginner-Friendly: Python is known for its simplicity, making it an ideal starting point for novice
programmers. It's versatile enough to develop various applications, from text processing to web
browsers and games. Guido van Rossum created Python between 1985 and 1990, and its source code is
open under the GNU General Public License (GPL).

Characteristics of Python
 Versatile Programming: Python accommodates various programming paradigms, including functional,
structured, and object-oriented programming (OOP).
 Scripting & Compilation: It serves both as a scripting language for quick tasks and can be compiled
into byte code for larger software projects.
 Dynamic Data Types: Python offers advanced dynamic data types and facilitates on-the-fly type
checking. Memory Management: The language automates garbage collection, managing memory
efficiently without manual intervention.
 Integration Capabilities: Python seamlessly integrates with other languages like C, C++, and Java, and
technologies such as COM, ActiveX, and CORBA.
 Dynamic Typing: Its dynamic typing system allows for flexible variable assignments, streamlining the
coding process.
 OOP Support: Python's support for OOP principles aids in structuring and reusing code, enhancing
maintainability and scalability.

Dept of ISE, EPCET 2023-24 Page 13


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Applications of Python
Python is a versatile and powerful programming language that has many applications in the real world.
Some of the most common and popular applications of Python are:
 Web and Internet Development: Python can be used to create web applications, websites, web
services, and web crawlers. It has many frameworks and libraries that support web development, such
as Django, Flask, Pyramid, Bottle, and Beautiful Soup.
 Machine Learning and Artificial Intelligence: Python is one of the most widely used languages for
machine learning and artificial intelligence. It has many tools and libraries that facilitate data analysis,
data visualization, and algorithm development, such as NumPy, SciPy, pandas, matplotlib, seaborn,
scikit-learn, TensorFlow, and Keras.
 Game Development: Python can be used to create 2D and 3D games, as well as game engines and
scripting. It has many libraries and modules that support game development, such as pygame, panda3D,
cocos2D, and PyOpenGL.
 Desktop GUI Development: Python can be used to create graphical user interfaces for desktop
applications. It has many libraries and frameworks that provide GUI components, such as Tkinter,
wxPython, PyQt, PySide, PyGUI, and Kivy.
 Enterprise/Business Applications: Python can be used to develop enterprise-level and business
applications that are scalable, extensible, and readable. It has many libraries and frameworks that
support enterprise development, such as Odoo, Tryton, SCons, Buildbot, Roundup, and Trac.
 Educational Purposes: Python can be used to teach and learn programming, as well as to develop
educational resources and software. It has a simple syntax, a beginner-friendly nature, and a wide range
of applications. It also has libraries and frameworks that support education, such as Software Carpentry,
IPython, and Jupyter.
 Database Access: Python can be used to access and manipulate data from various databases, such as
SQL, NoSQL, and cloud databases. It has many libraries and modules that provide database
connectivity, such as SQLite, MySQL, PostgreSQL, MongoDB, and SQLAlchemy.
 Network Programming: Python can be used to create network applications, such as web servers, email
clients, FTP clients, and socket servers. It has many libraries and modules that support network
programming, such as socket, requests, urllib, twisted and, feedparser.

Dept of ISE, EPCET 2023-24 Page 14


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Chapter 2

LITERATURE SURVEY
2.1 Related Work
1. Title: Book Recommendation System with TensorFlow
Author: Anandaraj A, Yeshwanth Ram P, Sri Ram Kumar K, Revanth. M, Praveen R

Abstract:
This paper proposes a solution for recommending books to customers using the internet tool. The
internet tool allows the system to collect and analyze the customer's preferences and feedback. The
system can quickly and easily perform online recommendation filtering, which is the latest technique for
recommendation. The system filters, ranks, and delivers the most relevant books to the customers. The
system helps the websites to sell more books and increase their profit. The system uses the ratings of
each customer to understand their opinions on the books. The system overcomes the challenge of
implementing Content-Based Collaborative Filtering, which is a difficult task to combine.
Recommender systems have to filter, prioritize, and deliver relevant information to customers. This
paper proposes a solution using TensorFlow, a framework for building machine learning models.
TensorFlow can enhance the collaborative filtering process by adding more features and capabilities.
The system uses TensorFlow techniques to enhance the collaborative filtering process.
Disadvantages:
The Drawback here is that it does not compare its results with other existing recommender systems or
provide any evaluation metrics such as precision, recall, or F-score. Therefore, it is hard to assess the
performance and effectiveness of their proposed method.
2. Title: Cloud-Based Collaborative Filtering Algorithm For Library Book
Recommendation System
Author: Anoop A, N Ayush Ubale

Abstract:
A library book recommendation system is a system that helps libraries to manage their books more
efficiently. It is a website that allows the admin to create a system that can store and access books from
the database. The system uses a collaborative filtering algorithm to categorize the books and recommend
the best-rated (5-star rating) books to the user. The user can log in to their account using a password that
is sent to their valid email address. The user can then update their profile and view the books by subject

Dept of ISE, EPCET 2023-24 Page 15


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Each category shows one or more of the best-rated books to the user, so they can find the books they are
interested in more easily. The user can also chat with other users online to get suggestions about the
books. They can also request to borrow and return the books from the admin, who will deliver the books
to their home. The user can also rate and review the books they have borrowed. The system is free and
reliable and offers home delivery of books by requesting to borrow them.
Disadvantages:
The paper does not address the limitations of accuracy as a performance metric for classification
problems. Accuracy is not a good metric for classification problems because it does not account for the
nature or frequency of errors. Accuracy can be misleading when the data is imbalanced or the costs of
different errors are unequal. Other metrics are more sensitive to these issues, such as precision, recall,
F1-score, or ROC curve.

3. Title: Efficient Recommendation System for Book Selection


Author: Madhuri Kommineni, P. Alekhya, T. Mohana Vyshnavi, V. Aparna, K Swetha,
V Mounika

Abstract:
A recommender system is a type of internet tool that helps users find what they want on the web based
on their preferences. Recommender systems are very important for e-commerce websites because they
help users choose the right products. A good recommendation process can also increase sales and
customer loyalty. However, some existing methods may collect irrelevant data and make the users
unhappy or dissatisfied. This paper gives a general overview of the recommender systems used in the
online book shopping domain. It also proposes a simple and easy system for book recommendations that
can help readers find the next book they want to read. The paper focuses on the information analysis
challenge for the administration recommendation system, which deals with network resources that are
connected and growing fast. The paper also presents the overall architecture of the proposed system and
its implementation with a model design.
Disadvantages:

This paper does not represent the diverse tastes and ratings of all book readers, as it may favor certain
genres, authors, or languages. It may also have many gaps in the ratings, tags, or genres, which can
make the system less accurate and prone to cold start problems. Information might too large or complex
to handle efficiently, or too dynamic to keep up with. The data may pose privacy risks, as it may reveal
personal information about the users or be exposed to attacks or manipulation by malicious users.

Dept of ISE, EPCET 2023-24 Page 16


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

4. Title: Embedding Model Design for Producing Book Recommendation

Author: Reza Rahutomo, Anzaludin Samsinga Perbangsa, Haryono Soeparno, Bens


Pardamean

Abstract:

To foster user engagement, internet platforms often tailor content suggestions to individual preferences.
The crux of this personalization lies in recommendation systems, which craft a lineup of content by
analyzing user interactions. Notably, user-provided ratings serve as a crucial dataset for discerning
favored content. This study delves into the mechanics of book recommendations, employing a
collaborative filtering approach that incorporates these ratings. An experiment conducted on a randomly
chosen user’s past behavior yielded a quintet of book suggestions with a 59% accuracy rate. This
research contributes valuable insights for the advancement of Binus University’s content
recommendation system within its corporate learning framework.

Disadvantages:

The embedding model achieved an accuracy of 59%, which indicates there is room for improvement in
the recommendation system's performance. The paper mentions that the embedding model is a basic
architecture, which may limit its ability to capture complex patterns in user preferences compared to
more advanced models.

Dept of ISE, EPCET 2023-24 Page 17


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Chapter 3

REQUIREMENT SPECIFICATIONS

System requirement specification (SRS) is a document that describes the features and behavior of a software or
system. It defines what the software or system should do and how it should perform, based on the needs and
expectations of the stakeholders (users, customers, developers, etc.). It includes both functional and non-
functional requirements, as well as any constraints or assumptions that affect the design and development of the
software or system.

System Requirement Specification (SRS) is a central report, which frames the establishment of the product
advancement process. It records the necessities of a framework as well as has a depiction of its significant
highlight. An SRS is essentially an association's seeing (in composing) of a client or potential customer's
framework necessities and conditions at a specific point in time (generally) before any genuine configuration or
improvement work. It's a two-way protection approach that guarantees that both the customer and the
association comprehend the alternate's necessities from that viewpoint at a given point in time.

An SRS serves as a blueprint and a reference for the software or system, guiding the design, validation, and
communication processes. It helps to ensure that the software or system meets the requirements and satisfies the
stakeholders. An SRS typically follows a standard format and structure, such as the IEEE 830-1998, which
covers topics such as introduction, overall description, specific requirements, appendices, and index. An SRS
should be clear, concise, consistent, complete, correct, and verifiable.

The SRS talks about the item however not the venture that created it, consequently the SRS serves as a premise
for later improvement of the completed item. The SRS may need to be changed, however, it does give an
establishment to proceed with the creation assessment. In straightforward words, programming necessity
determination is the beginning stage of the product improvement action.

The SRS means deciphering the thoughts in the brains of the customers – the information, into a formal archive
the yield of the prerequisite stage. Subsequently, the yield of the stage is situated of formally determined
necessities, which ideally are finished and steady, while the data has none of these properties. A requirements
specification document outlines the features, functionalities, and constraints of a software project. It typically
includes user needs, system behavior, and acceptance criteria. Clear requirements help guide development and
ensure stakeholders' expectations are met.

Dept of ISE, EPCET 2023-24 Page 18


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

3.1 Hardware Requirements:

 CPU : Intel i5 or AMD Ryzen


 Hard Disk : 512 GB SSD
 RAM : 6 GB or 8 GB
 Input Device : Keyboard, Mouse

3.2 Software Requirements


 Operating System : Windows 10/11
 IDE : PyCharm
 Libraries used : pandas, flask, pickle
 Version Used : Python 3.11

3.2.1 PyCharm
PyCharm is developed by JetBrains, is a renowned Integrated Development Environment (IDE) specifically
tailored for Python programming. Offering a plethora of features, it simplifies and enhances the development
process for Python applications. With intelligent code assistance, including syntax highlighting, code
completion, and error highlighting, PyCharm empowers developers to write clean and efficient code. The IDE
also incorporates a robust set of integrated tools for testing, profiling, and debugging, supporting popular testing
frameworks such as pytest and unittest.

Fig 3.5 PyCharm

Dept of ISE, EPCET 2023-24 Page 19


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

3.2.2 Python
Python is a dynamic, interpreted (bytecode-compiled) language. There are no type declarations of variables,
parameters, functions, or methods in source code. This makes the code short and flexible, and you lose the
compile-time type checking of the source code. Python tracks the types of all values at runtime and flags code
that does not make sense as it runs. Python is a modern computer programing language. It bears some
similarities to Fortran, one of the earliest programing languages, but it is much more than Fortran. Python
allows you to use variables without declaring them (i.e., it determines types implicitly), and it relies on SMART
RESCUE AND SURVEILANCE ROBOT USING AI AND ML indentation as a control structure. Python was
developed by Guido Van Rossum, and it is free software. But Python is also free in other important ways, for
example you are free to copy it as many times as u like, and free to study the source code, and make changes.

Fig 3.6 Python


3.2.3 Pandas
Pandas is a Python library that provides data structures and functions for working with tabular data, such as
spreadsheets or SQL tables. It is built on top of NumPy, a library that supports multi-dimensional arrays and
mathematical operations. Pandas enable you to perform data manipulation and analysis, such as cleaning,
filtering, merging, grouping, aggregating, and visualizing data. Pandas also supports reading and writing data
from various formats, such as CSV, JSON, Excel, and SQL. Pandas are widely used for data science, machine
learning, and statistics, as it integrate well with other libraries, such as matplotlib, seaborn, scikit-learn, and
TensorFlow.

3.2.4 Flask
Flask is a Python web framework that allows you to create and deploy web applications with ease. It is based on
the Werkzeug WSGI toolkit and the Jinja2 template engine, which provide low-level and high-level
functionality respectively. Flask is designed to be minimal and flexible, letting you choose the components and
extensions that suit your needs. Flask supports various features, such as routing, templating, testing, debugging,
error handling, and deployment Flask is widely used for developing web applications, such as blogs, APIs,
dashboards, and more.

Dept of ISE, EPCET 2023-24 Page 20


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

3.2.5 Pickle
Pickle is a Python module that allows you to serialize and deserialize Python objects into a binary format.
Serialization is the process of converting an object into a stream of bytes that can be stored or transmitted.
Deserialization is the reverse process of reconstructing an object from a stream of bytes. Pickle can handle
various types of Python objects, such as lists, dictionaries, functions, classes, and more. Pickle can be useful for
saving the state of an object, transferring data between processes, or persistently storing data. You can use the
pickle.dumps() function to serialize an object into a bytes object, and the pickle.loads() function to deserialize a
bytes object into an object¹. You can also use the pickle. dump() and pickle.load() functions to write and read
pickled objects to and from a file.

3.3 Functional Requirements


 User Profiles: Ability to create and manage user accounts with preferences and reading history.
 Book Database: A comprehensive collection of books with details like title, author, genre, and ISBN.
 Recommendation Engine: Algorithms to suggest books based on user preferences, ratings, and behavior.
 Search and Filter: Features to search for books and filter results by various criteria such as genre or
author.
 Wi-Fi
 Browser Compatibility
 Internet Connectivity

3.4 Non-Functional Requirements


Non-functional prerequisites are the functions offered by the system. It incorporates time imperatives and
requirements on the improvement procedure and principles. Given below are the non-functional requirements:

 Performance: This includes factors like response time, latency, and throughput. A good voice assistant
should provide quick and near-instantaneous responses to user queries or commands while handling
multiple user interactions without significant delays.

 Scalability: The system should be scalable to accommodate varying user loads and adapt to increased
demand without compromising performance. It should efficiently handle a growing number of users
interacting with the voice assistant simultaneously.

Dept of ISE, EPCET 2023-24 Page 21


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

 Reliability: It involves the system's ability to operate consistently and predictably without failure. The
voice assistant should maintain its functionality even under stressful conditions, minimizing downtime
and ensuring continuous availability.

 Security: Protecting user data, maintaining privacy, and preventing unauthorized access are crucial.
Encryption, secure authentication mechanisms, and adherence to data privacy regulations are vital
aspects of non-functional requirements related to security.

 Accuracy and Naturalness: The generative AI integrated into the voice assistant should generate
responses that are accurate, coherent, and contextually relevant. Natural language generation should
mimic human-like conversational patterns to enhance user engagement.

 Adaptability and Customizability: The system should adapt to user preferences, allowing
personalization of interactions and customization based on individual user needs or environments.

 Resource Utilization: Efficient use of computational resources like memory, CPU, and bandwidth is
essential. Optimizing resource consumption ensures the system operates effectively without
unnecessary overhead.

 Compatibility and Interoperability: Compatibility with different devices, operating systems, and
platforms ensures a broader user base can access and use the voice assistant. Interoperability allows
seamless integration with other systems or applications.

 Usability and User Experience: A user-friendly interface, intuitive interactions, and minimal
cognitive load contribute to a positive user experience. The voice assistant should be easy to use and
navigate, catering to users of varying technical abilities.

Dept of ISE, EPCET 2023-24 Page 22


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Chapter 4
SYSTEM ARCHITECTURE
4.1 System Analysis

System development is an organized process encompassing stages like planning, analysis, design,
implementation, and maintenance. System analysis involves gathering and interpreting data, pinpointing
issues, and breaking down a system into its elements to understand its goals. It's a problem-solving
approach that enhances the system's performance and ensures each component functions effectively to
fulfill its intended role. The analysis delineates the system's required operations. Meanwhile, system design
entails devising a new business system or revamping an existing one by outlining its components or
modules to meet specific needs. Before this, a comprehensive understanding of the current system is
crucial, as well as determining the optimal use of computers for effective operation. System design is
centered on achieving the system's goals.

4.2 System Architecture

The software architecture of a book recommendation system is designed to provide personalized book
suggestions to users based on their preferences and reading history. At its core, the system comprises several
interconnected modules that work in tandem to deliver accurate and relevant recommendations. The key
components in the software architecture of a book recommendation system using a User-Based Collaborative
Filtering (UBCF) approach are:

 User Preferences: Collecting and analyzing user preferences and ratings for books. User preferences in
book recommendation systems are crucial for providing personalized and relevant suggestions. Here are
the key points regarding user preferences: Content-Based Filtering, Collaborative-Based Filtering,
Hybrid Filtering, and User Interaction. These methods aim to align recommendations with individual
user interests, enhancing the reading experience.
 Similarity Measures: Calculating similarity between users based on their preferences to identify like-
minded readers. It computes the similarity between users based on their ratings and preferences.
 Collaborative Filtering: Using UBCF to predict items (books) that a user might like based on ratings
given by similar users.
 Data Management: Handling the storage, retrieval, and analysis of user data and book information. A
robust database stores and organizes the collected data, ensuring quick retrieval and efficient handling of
large volumes of information. It typically includes tables for users, books, authors, genres, and ratings.

Dept of ISE, EPCET 2023-24 Page 23


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

 Feedback Loop: Incorporating user feedback to refine and improve the recommendation process. An
essential aspect of the architecture is the feedback loop, which allows the system to learn from user
interactions. As users engage with the recommendations, their responses are fed back into the system to
refine future suggestions.

 Security and Privacy: Ensuring user data protection is a critical component, with measures in place to
safeguard personal information and comply with privacy regulations.

Fig 4.1 System Architecture

Dept of ISE, EPCET 2023-24 Page 24


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

4.3 Modules to be Implemented


Book Recommendation Engine using User-Based Collaborative Filtering (UBCF) typically involves several key
modules:
 User Profile Module: This module collects and stores data on individual users, including past behavior,
preferences, and ratings. It's crucial to understand what each user likes and dislikes.

 Item Profile Module: Similar to the user profile, this module keeps track of the attributes of the books,
such as genre, author, publication year, and other metadata that might influence a user's preference.

 Ratings Matrix Module: Here, the system creates a matrix to represent the ratings given by users to
different books. This matrix is sparse as not all users rate all books, but it's essential for finding correlations
between users.

 Similarity Computation Module: This module calculates the similarity between users based on their
ratings and preferences. Common algorithms used here include Pearson correlation, cosine similarity, and
Euclidean distance.

 Neighborhood Formation Module: After computing similarities, this module selects a 'neighborhood' of
users with similar tastes to a given user. The size of this neighborhood can affect the quality of
recommendations.

 Recommendation Generation Module: Leveraging the neighborhood, this module predicts the ratings a
user might give to unrated books and generates a list of recommendations. Predictions are usually based on
the weighted average of ratings from similar users.

 Evaluation Module: This module assesses the performance of the recommendation system, often using
metrics like Mean Absolute Error (MAE) or Root Mean Squared Error (RMSE), to ensure the quality of
recommendations.

 Feedback Module: Finally, this module captures user feedback on the recommendations provided, which
can be explicit (through ratings) or implicit (through click-through rates), to refine and improve the
recommendation process.

Dept of ISE, EPCET 2023-24 Page 25


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

4.4 Activity Diagram


An activity diagram is a type of diagram that shows the flow of actions and events in a system or a process. It is
used to model the dynamic behavior and logic of a system, such as the steps involved in a use case, a business
process, or an operation. An activity diagram can also show the conditions, decisions, loops, and concurrency
that affect the flow of actions. Activity diagrams are graphical representations of workflows of stepwise
activities and actions with support for choice, iteration, and concurrency. In the Unified Modeling Language,
activity diagrams are intended to model both computational and organizational processes (i.e., workflows), as
well as the data flows intersecting with the related activities.

Fig 4.2 Activity Diagram

Dept of ISE, EPCET 2023-24 Page 26


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

4.5 State Transition Diagram


A state diagram is a type of diagram used in computer science that shows the different states of an object or
a system and the events or conditions that cause the object or system to change from one state to another. It
is also known as a state machine diagram or a state chart diagram and related fields to describe the behavior
of systems. State diagrams require that the system described is composed of a finite number of states;
sometimes, this is indeed the case, while at other times this is a reasonable abstraction. State diagrams are
used to give an abstract description of the behavior of a system. This behavior is analyzed and represented
by a series of events that can occur in one or more possible states. A state transition diagram is a type of
diagram. A state transition diagram can be used to model the behavior of a class, a subsystem, a package, or
a whole system.

Fig 4.3 State Transition Diagram

Dept of ISE, EPCET 2023-24 Page 27


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

4.6 Flow Chart


A flowchart is simply a graphical representation of steps. It shows steps in sequential order and is widely
used in presenting the flow of algorithms, workflow, or processes. Typically, a flowchart shows the steps as
boxes of various kinds, and their order by connecting them with arrows. It originated from computer
science as a tool for representing algorithms and programming logic but has extended to use in all other
kinds of processes. Nowadays, flowcharts play an extremely important role in displaying information and
assisting reasoning. They help us visualize complex processes, or make explicit the structure of problems
and tasks. A flowchart can also be used to define a process or project to be implemented.

Fig 4.4 Flow Chart of Book Recommendation using ML Algorithms

Dept of ISE, EPCET 2023-24 Page 28


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

4.7 Use Case Diagram


A use case is a methodology used in system analysis to identify, clarify, and organize system requirements. The
use case is made up of a set of possible sequences of interactions between systems and users in a particular
environment and related to a particular goal. A use case document can help the development team identify and
understand where errors may occur during a transaction so they can resolve them.

Fig 4.5 Use Case Diagram

This is a book recommendation system, where readers with overlapping reading preferences are connected.
The system would then suggest books that one reader enjoys to the other, using visual elements like book
icons and connecting lines to represent the shared likes and recommendations. It’s a visual metaphor for
how book recommendation systems can predict and cater to reader preferences based on commonalities in
their reading history.

Dept of ISE, EPCET 2023-24 Page 29


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Chapter 5

SYSTEM IMPLEMENTATION

5.1 Recommendation of Books to the User


The Implementation of a Book Recommendation System Step by Step:

Step 1: Data Collection and Preprocessing:

> Gather data on user preferences, such as books they’ve read, ratings, and other relevant information.
> Clean and preprocess the data by handling missing values, removing duplicates, and ensuring consistency.

Step 2: User-Item Matrix Creation:

> Construct a matrix where rows represent users and columns represent items (in this case, books).
> Populate the matrix with user-item interactions (e.g., ratings, likes, or purchase history).

Step 3: Similarity Calculation:

> Compute similarity between users or items. Common methods include:


 Cosine Similarity: Measures the cosine of the angle between two vectors (user profiles or item
features).
 Pearson Correlation: Measures linear correlation between user/item vectors.
 Jaccard Similarity: Used for binary data (e.g., liked/disliked items).
> The goal is to find users with similar reading preferences.

Step 4: User-Based Collaborative Filtering:

> Identify a target user for whom we want to make recommendations.


> Find similar users based on their reading history (using the similarity metrics).
> Recommend books that similar users have enjoyed but the target user hasn’t read yet.

Step 5: Item-Based Collaborative Filtering:

> Instead of finding similar users, find similar books/items.


> Recommend books similar to those the target user has already liked.

Dept of ISE, EPCET 2023-24 Page 30


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Step 6: Matrix Factorization (SVD, ALS):

> Decompose the user-item matrix into latent factors (user and item embeddings).
> Use these embeddings to predict missing ratings or recommend items.

Step 7: Content-Based Filtering:

> Consider book features (e.g., genre, author, publication year) to recommend similar books.
> If a user likes a mystery novel, recommend other mystery novels.

Step 8: Hybrid Approaches:

> Combine collaborative filtering and content-based methods for better recommendations.
> Weighted averages or ensemble techniques can be used.

Step 9: Evaluation Metrics:

> Assess recommendation quality using metrics like Mean Absolute Error (MAE), Root Mean Squared
Error (RMSE), or precision/recall.
> Split data into training and test sets for evaluation.

Step 10: Deployment and Real-Time Recommendations:

> Deploy the recommendation system in a production environment.


> Continuously update user profiles and recompute recommendations as new data arrives.
> Serve recommendations in real time to users.

The Success of a Recommendation System depends on the quality of data, choice of algorithms, and thorough
evaluation. Each step involves careful design and tuning to create an effective system that enhances user
experiences.

Dept of ISE, EPCET 2023-24 Page 31


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

5.2 Code Snippet

5.2.1 Home Page

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Book Recommender System</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
crossorigin="anonymous">
</head>
<style>
a, u {
text-decoration: none;
}
a:hover {
background-color: #c5805c;
}
.card{
margin-bottom: 30px;
width: 250px;
box-shadow: 0 15px 25px rgba(129, 124, 124, 0.2);
height: 300px;
display: flow-root;
border-radius: 5px;
backdrop-filter: blur(100px);
background-color: rgba(255, 255, 255,
0.2); text-align: center;
}

.background{
height: 150px;
margin-bottom:30px;

Dept of ISE, EPCET 2023-24 Page 32


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

margin-right: auto;
margin-left: auto;
}

.book-name{
color:rgb(0, 0, 0);
text-shadow: 1.5px 1px #ffffff;
font-family:Verdana;
}
.book-details{
color: #000000;
text-shadow: 1px 1px #a9a9a9;
font-family:Bahnschrift;
}
.page{
border:none;
display:inline-flex;
background-color: #b9b9b9;
border-radius:5px;
color: #030303;
position: relative;
text-shadow: 1px 1px #e1e1e1;
margin-bottom: 10px;
}
ul li{
font-family: "Times New Roman";
font-size: 20px;
}
.navbar-brand{
font-size: 40px;
text-align: center;
text-shadow: 3px 3px #000000;
color: #ffffff;
position: relative;

Dept of ISE, EPCET 2023-24 Page 33


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

background-size: cover;
font-family: "Times New Roman";
background-image: url('https://th.bing.com/th/id/OIP.VvYd74xJf-
55NBR6EcOzyQHaE8?rs=1&pid=ImgDetMain') height:100% width:100% opacity:60%;
background-repeat:repeat;
}
img{ floa
t: left;
width: 100px;
height: 100px;
position:absolute;
background-repeat: no-repeat, repeat;

}
.text-top50{
color: #d3d3d3;
text-shadow: 3px 3px #2c2c2c;
position: relative;
text-align: center;
}
</style>
<body style="background: radial-gradient(circle, rgb(98,76,95) 0%, rgb(53,84,79) 100%);" >
<img src="https://c.wallhere.com/photos/c4/8c/books_library_bokeh_depth_of_field-74960.jpg!d"
style="position:fixed;width:100%; display:flex;height: 100%;background-position: center;background-size:
cover;">
<nav class="nav-bar">
<p class="navbar-brand"><strong>MY BOOK RECOMMENDER</strong</p>
<ul class="nav navbar-nav">
<li style="display: inline;margin:10px;padding:10px"><a class="page" href="/">Home</a></li>
<li style="display: inline;margin:10px;padding:10px"><a class="page"
href="/recommend">Recommend</a></li>
<li style="display: inline;margin:10px;padding:10px"><a class="page">Contact</a></li>
</ul>
</nav>

Dept of ISE, EPCET 2023-24 Page 34


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

<div class="container">
<div class="row">
<div class="col-12" >
<h1 class="text-top50" style="text-align: center; font-family:'Times New Roman', Times,
serif"><strong>Top 50 Popular Books</strong></h1>
</div>

{% for i in range(book_name|length) %}
<div class="col-3" style="margin:50px">
<div class="background">
<div class="card" style="width:380px ;height:270px;" >
<div class="card-body">
<img class="card-img-top" src="{{ image[i] }}" style="width:150px;height:240px;
position:relative;margin-right: 10px">
<h6 class="book-name"><strong>{{ book_name[i] }}</strong></h6>
<p class="book-details"> {{ author[i] }}</p>
<p class="book-details"> Votes - {{ votes[i] }}</p>
<p class="book-details">Rating - {{ rating[i] }}</p>
</div>
</div>
</div>
</div>
{% endfor %}

</div>
</div>
</body>
</html>

Dept of ISE, EPCET 2023-24 Page 35


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

5.2.2 Recommendation Page


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Book Recommender System</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
crossorigin="anonymous">
</head>
<style>
button:hover{ color:dark
orange;
}
a, u {
text-decoration: none;
}
a:hover {
background-color: #ff8f56;
}
.card{
margin-bottom: 30px;
width: 250px;
box-shadow: 0 15px 25px rgba(129, 124, 124, 0.2);
height: 300px;
display: flow-root;
border-radius: 5px;
backdrop-filter: blur(100px);
background-color: rgba(254, 95, 95,
0.2); text-align: center;
}

.background{
height: 150px;

Dept of ISE, EPCET 2023-24 Page 36


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

margin-bottom:30px;
margin-right: auto;
margin-left: auto;
}

.book-
name{ color:black
;
text-shadow: 1px 1px #ffffff;
font-family:Verdana,serif;
}
.book-details{
color: #000000;
text-shadow: 1px 1px #aedade;
font-family:'Bahnschrift,serif';
}
.page{
border:none;
display:inline-flex;
background-color: #b9b9b9;
border-radius:5px;
color: #030303;
position: relative;
text-shadow: 1px 1px #e1e1e1;
margin-bottom: 10px;
}
ul li{
font-family: "Times New
Roman",serif; font-size: 20px;
}
.navbar-brand{
font-size: 40px;
text-align: center;
text-shadow: 3px 3px #3f3030;
color: #ffffff;

Dept of ISE, EPCET 2023-24 Page 37


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

position: relative;
background-size: cover;
font-family: "Times New
Roman",serif; background-
repeat:repeat;
}
img{ floa
t: left;
width: 100px;
height: 100px;
position:absolute;
background-repeat: no-repeat, repeat;
}
.text-top50{
color: #d3d3d3;
text-shadow: 3px 3px #2c2c2c;
position: relative;
text-align: center;
}
</style>
<body style="background: radial-gradient(circle, rgb(98,76,95) 0%, rgb(53,84,79) 100%);" >
<img src="https://c.wallhere.com/photos/c4/8c/books_library_bokeh_depth_of_field-74960.jpg!d"
style="position:fixed;width:100%; display:flex;height: 100%;background-position: center;background-size:
cover;" alt="alternateimage">
<nav class="nav-bar">
<p class="navbar-brand"><strong>MY BOOK RECOMMENDER</strong</p>
<ul class="nav navbar-nav">
<li style="display: inline;margin:10px;padding:10px"><a class="page" href="/">Home</a></li>
<li style="display: inline;margin:10px;padding:10px"><a class="page"
href="/recommend">Recommend</a></li>
<li style="display: inline;margin:10px;padding:10px"><a class="page">Contact</a></li>
</ul>
</nav>
<div class="container">
<div class="row">

Dept of ISE, EPCET 2023-24 Page 38


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

<div class="col-12" >


<h1 class="text-top50" style="text-align: center; font-family: 'Times New
Roman',serif"><strong>Recommend Books</strong></h1>
<form action="/recommend_books" method="post">
<div class="input-group mb-3">
<span class="input-group-text" id="inputGroup-sizing-default"
style="width:200px;background:#b9b9b9;text-align: center; font-family: 'Times New Roman';color:
#030303;text-shadow: 1px 1px #e1e1e1;font-weight: bold;font-size: 18px">Type Book Name Here</span>
<input name="user_input" type="text" class="form-control" aria-label="Sizing example input"
aria- describedby="inputGroup-sizing-default" >
<button type="submit" class="btn btn-warning">Submit</button>
</div>
</form>
</div>
{% if data %}
{% for i in data %}
<div class="col-3" style="margin:none">
<div class="background">
<div class="card" style="width:300px ;height:200px;" >
<div class="card-body">
<img class="card-img-top" src="{{i[2]}}" style="width:100px;height:180px;
position:relative;margin-bottom:20px">
<h6 class="book-name"><strong>{{i[0]}}</strong></h6>
<p class="book-details"> {{i[1]}}</p>
</div>
</div>
</div>
</div>
{% endfor %}
{% endif %}
</div>
</div>
</body>
</html>

Dept of ISE, EPCET 2023-24 Page 39


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

5.2.3 Python Code


from flask import Flask, render_template, request
import pickle
import numpy as np

popular_df = pickle.load(open('popular.pkl', 'rb'))

pt = pickle.load(open('pt.pkl', 'rb'))
books = pickle.load(open('books.pkl', 'rb'))
similarity_score = pickle.load(open('similarity_score.pkl', 'rb'))

app = Flask( name )

@app.route('/')
def index():
return render_template("index.html",
book_name=popular_df['Book-Title'].to_list(),
author=popular_df['Book-Author'].to_list(),
image=popular_df['Image-URL-M'].to_list(),
votes=popular_df['num-ratings'].to_list(),
rating=popular_df['avg-rating'].to_list()
)

@app.route('/recommend')
def recommend_ui():
return render_template('recommend.html')

@app.route('/recommend_books', methods=['GET','POST'])
def recommend():
user_input = request.form.get('user_input')
index = np.where(pt.index == user_input)[0][0]
similar_items = sorted(list(enumerate(similarity_score[index])), key=lambda x: x[1], reverse=True)[1:5]

Dept of ISE, EPCET 2023-24 Page 40


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

data = []
for i in similar_items:
item = []
temp_df = books[books['Book-Title'] == pt.index[i[0]]]
item.extend(temp_df.drop_duplicates('Book-Title')['Book-Title'].to_list())
item.extend(temp_df.drop_duplicates('Book-Title')['Book-Author'].to_list())
item.extend(temp_df.drop_duplicates('Book-Title')['Image-URL-M'].to_list())

data.append(item)

print(data)
return render_template("recommend.html", data=data)

if name == " main ":


app.run(debug=True)

Dept of ISE, EPCET 2023-24 Page 41


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Chapter 6

VERIFICATION AND VALIDATION


Software testing is a critical evaluation process aimed at informing stakeholders about the quality of the
software product or service being examined. It offers an unbiased, independent perspective on the software,
helping businesses to recognize and comprehend the potential risks associated with its deployment. The process
involves running a program or application to detect any bugs or defects, and ensuring the software is ready for
deployment. The execution of software testing assesses various attributes of a software or system component.
Generally, these attributes measure the degree to which the component or system being tested:
 Fulfills the criteria that influenced its design and development,
 Accurately processes all types of inputs,
 Executes its functions within an acceptable timeframe,
 Is user-friendly,
 Can be installed and operated in its designated environments, and
 Delivers the outcomes desired by its stakeholders.

6.1 Functional Testing


 The hardware interface has been set up without issues.
 A stable connection to the database has been achieved.
 Navigation through the application is seamless, precise, and swift.
 Every form within the application functions as intended.
 In instances of incorrect input, the system reliably displays warning messages.
 Consistently, the correct data is retrieved from the backend following any action taken within the
application.

6.2 Usability Testing


 The application offers seamless navigation, resulting in a user-friendly interface.
 User inputs are collected through dropdown menus, ensuring the system receives accurate information.
 The system effectively manages any incorrect inputs.
 Additionally, the application's content is reliable, sourced from verified providers.
 The datasets used for crop prediction are both precise and evenly distributed, enhancing the
application's robustness.

Dept of ISE, EPCET 2023-24 Page 42


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

6.3 Interface Testing


 The software seamlessly interfaces with the hardware, ensuring that any malfunctions trigger a
relevant notification.
 It manages disruptions, whether they originate from the server or the user, with effectiveness.
 Moreover, the system adeptly addresses instances of incorrect login details by informing users
through suitable prompts.
 Overall, the user experience is designed to be intuitive and user-friendly.

6.4 Compatability Testing


 This software functions seamlessly across all browsers that support JavaScript.
 Additionally, it ensures full compatibility with any desktop computer that has the necessary drivers
pre- installed.

6.5 Performance Testing


 The system operates effectively at moderate speeds, ensuring a secure connection while safeguarding
user information.
 Transitioning between screens is both rapid and seamless.
 User inputs are accurately received, and responses are promptly recorded.
 Additionally, the system excels in capturing real-time information, facilitating immediate data capture
for accurate crop and demand forecasting tailored to user needs.

Dept of ISE, EPCET 2023-24 Page 43


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Chapter 7

RESULTS

Fig 7.1 Home Page

Fig 7.2 Top 50 Books

Dept of ISE, EPCET 2023-24 Page 44


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Fig 7.3 Recommendation Page

Fig 7.4 Asking For Recommendation

Dept of ISE, EPCET 2023-24 Page 45


MACHINE LEARNING BASED BOOK RECOMMENDATION ENGINE IN PYTHON 18CSP77

Fig 7.5 Recommended Books

Dept of ISE, EPCET 2023-24 Page 46


CONCLUSION

The conclusion of the book recommendation system using a user-based collaborative filtering approach is that it
is a personalized method, relying on the similarity between users’ interactions with items. It identifies users
with similar profiles and recommends items popular among these users. While this method is sensitive to
recorded interactions and can provide highly personalized recommendations, it requires significant
computational power due to the large number of users. Moreover, the user preferences may change over time,
making the system less deterministic. Despite these challenges, the user-based collaborative filtering approach
remains a valuable tool for providing tailored book recommendations. Given more information regarding the
books dataset, namely features like Genre, Description, etc., we could implement a content-filtering based
recommendation system and compare the results with the existing collaborative-filtering based system. We
would like to explore various clustering approaches for clustering the users based on Age, Location, etc., and
then implement voting algorithms to recommend items to the user depending on the cluster into which it
belongs.

Page 47
REFERENCES
[1] R. C K and K. C. Srikantaiah, "Similarity-Based Collaborative Filtering Model for Movie
Recommendation Systems," 2021 5th International Journal on Intelligent Computing and Control
Systems (2021).
[2] Huaxuan Zhao, Hongchen Wu, Jingzhi Li, Huaxiang Zhang And Xinjun Wang. "A High-Accuracy and
Dynamic Scheme for Real-Time Book Recommendation System". SPECIAL SECTION ON Advanced
Data Mining Methods For Social Computing, January 2020.
[3] Anoop A, N Ayush Ubale. "Cloud Based Collaborative Filtering Algorithm For Library Book
Recommendation System". Proceedings of the Third International Journal on Smart Systems and
Inventive Technology (2020).
[4] Huayong Liu, Nianlai Jiao. "A Hybrid Book Recommendation Algorithm Based on Context awareness
and Social Network". In 3rd International Journal on Advanced Electronic Materials, Computers and
Software Engineering (AEMCSE 2020).
[5] Kitti Puritat, Kannikar Intawong. "Development of an Open Source Automated Library System with
Book Recommendation System for Small Libraries". In International Journal on Digital Arts, Media and
Technology with ECTI Northern Section Journal on Electrical, Electronics, Computer and
Telecommunications Engineering (ECTI DAMT & NCON 2020).
[6] JiabeiLi, TianweiXu, Juxiang Zhou. "A personalized Recommendation Algorithm for College Books
based on User Interest". In IEEE 2nd International Journal on Computer Science and Educational
Informatization (CSEI 2020).
[7] M. Li, H. Wu, and H. Zhang, ‘‘Matrix factorization for personalized recommendation with implicit
feedback and temporal information in social e-commerce networks,’’ IEEE Access (2019).
[8] Murthy, K.V.S.S.R., &Satyanarayana, K.V.V ,”Intusion detection mechanism with machine learning
process “ International Journal of Engineering and Technology(2018).
[9] Narsinga rao, M.R.,Venkatesh Prasad ,V.,Sai Teja,P.,Zindavali,M. , Chandra Reddy, O,” A survey on
Prevention of Overfitting in convolutional neural networks using machine learning techniques”
International Journal of Engineering and Technology(2018).

Page 48

You might also like