Download as pdf or txt
Download as pdf or txt
You are on page 1of 55

TRIBHUVAN UNIVERSITY

INSTITUTE OF SCIENCE AND TECHNOLOGY


HIMALAYA COLLEGE OF ENGINEERING
[CODE: CSC-404]
A
FINAL YEAR PROJECT REPORT
ON

“BOOK BUZZ- AN ONLINE BOOK STORE WITH RECOMMENDATION


SYSTEM USING COLLABORATIVE FILTERING”
BY

DEEPAK ARYAL [7225/072]


MADAN BHANDARI [7234/072]
PRAMOD MAHARJAN [7239/072]
RABI PUKHUTA SHRESTHA [7240/072]

A PROJECT PROGRESS REPORT SUBMITTED TO DEPARTMENT OF


COMPUTER SCIENCE AND INFORMATION TECHNOLOGY IN PARTIAL
FULFILLMENT OF THE REQUIEMENT FOR BACHELOR’S DEGREE IN
COMPUTER SCIENCE AND INFORMATION TECHNOLOGY

DEPARTMENT OF COMPUTER SCIENCE AND INFORMATION


TECHNOLOGY

November 19, 2019


DECLARATION BY CANDIDATES

We, the final year students (seventh semester) B.Sc. CSIT students of Himalaya College
of Engineering, hereby declare that the project report entitled “Book Buzz-An Online
Book Store with Recommendation System Using Collaborative Filtering” is an
ecommerce project carried out by us under the guidance and supervision of Er. Ashok
Gharti Magar, Head of Department (Electronics and Computer Department),
Himalaya College Of Engineering.
We assure that this project work embodied the result of our original work and contents
of the project have not been submitted to anybody else for the award of degree. This
project is purely of academic interest.
We have followed the guidelines provided by the university in writing the report.

Date: November 19, 2019 Signature of the candidates


Mr. Deepak Aryal
Mr. Madan Bhandari
Mr. Pramod Maharjan
Mr. Rabi Pukhuta Shrestha
SUPERVISIOR’S CERTIFICATE

This is to certify that the project entitled “Book Buzz-An Online Book Store With
Recommendation System Using Collaborative Filtering” is an ecommerce project
done by Deepak Aryal(7225), Madan Bhandari(7234), Pramod Maharjan(7239) and
Rabi Pukhuta Shrestha(7240) of B.Sc. CSIT students 2072-2076, Himalaya College Of
Engineering. It is an original project carried out under my guidance and supervision
towards the partial fulfillment of Bachelor’s degree Of Computer Science and
Information Technology.

Signature of Supervisor
Er. Ashok Gharti Magar
Head of Department (Electronics and Computer Department)
Himalaya College of Engineering
Chyasal, Lalitpur

Date:

Seal:
EVALUATION COMMITTEE

This is to certify that the project entitled “Book Buzz-An Online Book Store With
Recommendation System Using Collaborative Filtering” is an ecommerce project
done by Deepak Aryal(7225), Madan Bhandari(7234), Pramod Maharjan(7239) and
Rabi Pukhuta Shrestha(7240) of fourth year B.Sc. CSIT(2072-2076),under the
guidance and supervision of Er. Ashok Gharti Magar, Head of Department
(Electronics and Computer Department), Himalaya College Of Engineering, towards
the partial fulfillment of Bachelor’s degree Of Computer Science and Information
Technology.

Signature of HOD Signature of Supervisor


Er. Himal Chand Thapa Er. Ashok Gharti Magar
Head of Department (CSIT) Head of Department (Electronics
Himalaya College of Engineering and Computer Department)
Chyasal, Lalitpur Himalaya College of Engineering
Chyasal, Lalitpur

���������������������������
𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄 𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄𝐄
ACKNOWLEDGEMENT

We would like to thank Himalaya College of Engineering for providing us a huge


platform to gain knowledge about different aspects of Computer Science and
Information Technology.

We would like to thank our Head of Department Er. Himal Chand Thapa who
persuaded and continuously guided us during the whole course of our project. We
would also like to thank him for providing us with necessary content and classes
regarding the project. We are also grateful towards Er. Ashok Gharti Magar for acting
as our supervisor and showed immense patience and understanding throughout the
project and provided suggestions.

Last, but not least, we also take this opportunity to thank our friends and colleagues for
their support and feedback throughout this project. We thank you all.

i
ABSTRACT

Online shopping is the process whereby consumers directly buy goods or services from
a seller in real-time, without an intermediary service, over the Internet. The process is
called Business-to-Consumer (B2C) online shopping.
The developed system is a “Recommendation System Using Collaborative Filtering”
which deals with developing an e-commerce website for a bookstore for both walk-in
customers and online customers. The customer can browse by catalog, search, buy and
get a recommendation of books in the store. To facilitate online purchase a shopping
cart is provided to the user. The users are recommended based on previous users rating
using matrix factorization technique.
To develop an e-commerce website, several Technologies was studied and understood.
These include server and client-side scripting techniques, implementation technologies
such as Python, Django, HTML, CSS, Bootstrap, JavaScript, and MySQL for database
handling.

Keywords: Recommendation System, Collaborative Filtering, Matrix Factorization,


Pandas, SVD (Singular Value Decomposition)

ii
Table of Contents
ACKNOWLEDGEMENT ............................................................................................ i

ABSTRACT ..................................................................................................................ii

LIST OF FIGURES ..................................................................................................... v

LIST OF TABLES ...................................................................................................... vi

LIST OF ABBREVIATION......................................................................................vii

CHAPTER 1: INTRODUCTION............................................................................... 1

1.1 Background Theory .............................................................................................. 1

1.2 Problem Definition ............................................................................................... 2

1.3 Objective .............................................................................................................. 2

1.4 Scope and Limitation ........................................................................................... 2

1.5 Report Organization ............................................................................................. 2

CHAPTER 2: LITERATURE REVIEW................................................................... 4

CHAPTER 3: SYSTEM ANALYSIS AND FEASIBILITY STUDY ...................... 8

3.1 Requirement Analysis .......................................................................................... 8

3.1.1 Functional Requirements ............................................................................... 8

Use Case Diagram .................................................................................................. 8

Tools Required ..................................................................................................... 19

3.1.2 Non- Functional Requirements...................................................................... 9

3.2 Feasibility Analysis .............................................................................................. 9

3.2.1 Operational feasibility ................................................................................... 9

3.2.2 Technical feasibility ...................................................................................... 9

3.2.3 Economic feasibility .................................................................................... 10

3.3 Process Model .................................................................................................... 12

3.3.1 Level-0 DFD diagram.................................................................................. 12

3.3.2 Level-1 DFD Diagram ................................................................................. 13

iii
CHAPTER 4: SYSTEM DESIGN ............................................................................ 12

4.1 System Architecture ........................................................................................... 12

4.1 Data Model ......................................................... Error! Bookmark not defined.

4.1.1 ER-Diagram ................................................. Error! Bookmark not defined.

4.3 Schema Diagram ................................................................................................ 15

4.4 Class Diagram .................................................................................................... 16

4.5 Activity Diagram ................................................................................................ 17

CHAPTER 5: METHODOLOGY............................................................................ 19

5.2 Admin and Customer ......................................................................................... 19

5.2.1 Admin Side .................................................................................................. 19

5.2.2 Customer Side.............................................................................................. 20

5.3 Algorithm Used For Recommendation .............................................................. 22

5.3.1 Matrix Factorization Algorithm................................................................... 22

CHAPTER 6: IMPLEMENTATION AND TESTING .......................................... 25

6.1 Implementation................................................................................................... 25

6.2 Testing ................................................................................................................ 28

6.2.1 Unit Testing ................................................................................................. 28

6.2.2 Integration Testing....................................................................................... 33

6.2.3 System Testing ............................................................................................ 34

CHAPTER 7: CONCLUSION AND FUTURE ENHANCEMENT ..................... 35

7.1 Conclusion.......................................................................................................... 35

7.2 Future Enhancements ......................................................................................... 35

References ................................................................................................................... 36

Appendix ..................................................................................................................... 38

iv
LIST OF FIGURES
Figure 3.1 Use Case Diagram for Online Bookstore ..................................................... 8
Figure 3. 2 Level-0 DFD Diagram............................................................................... 12
Figure 3. 3 Level-1 DFD Diagram............................................................................... 13
Figure 3. 4 Level-1 DFD for Recommendation Process.............................................. 14
Figure 3. 5 Level-1 DFD for Interaction System ......................................................... 14
Figure 4. 1 System Architecture .................................................................................. 12
Figure 4. 2 ER-Diagram of the System ........................ Error! Bookmark not defined.
Figure 4. 3 Schema Diagram for Online bookstore ..................................................... 15
Figure 4. 4 Class Diagram for Online bookstore ......................................................... 16
Figure 4. 5 Activity Diagram of System ...................................................................... 17
Figure 6. 1 Add product ............................................................................................... 25
Figure 6. 2 Change product.......................................................................................... 25
Figure 6. 3 Delete product ........................................................................................... 25
Figure 6. 4 Book not found message ........................................................................... 26
Figure 6. 5 Product recommended by algorithm. ........................................................ 26
Figure 6. 6 Recommended books................................................................................. 27
Figure 6. 7 Order registered in a database ................................................................... 27
Figure 6. 8 Rating Submitted in a database ................................................................. 27

v
LIST OF TABLES
Table 6. 1 Test Case for Admin Login and logout ...................................................... 28
Table 6. 2 Test Case for User Registration .................................................................. 29
Table 6. 3 Test Case for User Login and Logout ......................................................... 29
Table 6. 4 Test Case for Search ................................................................................... 30
Table 6. 5 Test Case for Categories ............................................................................. 31
Table 6. 6 Test Case for Recommendation .................................................................. 31
Table 6. 7 Test Case for Add to Cart ........................................................................... 31
Table 6. 8 Test Case for Continue Shopping ............................................................... 31
Table 6. 9 Test Case for Checkout ............................................................................... 32
Table 6. 10 Test Case for Successful Order Submission ............................................. 32
Table 6. 11 Test Case for Book Update ....................................................................... 33
Table 6. 12 Test Case for Buying Books ..................................................................... 33

vi
LIST OF ABBREVIATION
CSS: Cascading Style Sheets
HTML: Hyper Text Markup Language
JS: JavaScript
WSGI: Web Server Gateway Interface
B2C: Business to Consumer
ERD: Entity Relationship Diagram
DFD: Data Flow Diagram
SVD: Singular Value Decomposition
np: Numpy
pd: Pandas
CF: Collaborative Filtering
COD: Cash On Delivery

vii
CHAPTER 1: INTRODUCTION
1.1 Background Theory

With the rapid development of internet technologies, the number of online books selling
websites has increased which enhanced the competition among them. This online book-
selling website helps to buy the books online with Recommendation system, which is
one of the stronger tools to increase profit and retaining buyer. The book
recommendation system must recommend books that are of buyer’s interest.
Recommendation systems are widely used to recommend products to the end users that
are most appropriate. This system uses features of collaborative filtering to produce
efficient and effective recommendations. Collaborative recommendation is probably
the most familiar, most widely implemented and most mature of the technologies.
Collaborative recommender systems aggregate ratings of objects, recognize
commonalities between users based on their ratings, and generate new
recommendations. This technology proved to be extremely useful, when it comes to
generating sales.
The system makes use of numerical ratings of books provided by the active user to
assess the similarity between users’ profiles to predict recommendations of unseen
books to active user. The system makes use of Matrix Factorization technique, which
allow us to discover the latent features underlying the interactions between user and
books. In the system, there is a group of users and a set of books, given that each users
have rated some books. The algorithm will predict how the users would rate the books
that they have not yet rated, such that proper recommendations are made for the users.
In this case, all the information we have about the existing ratings can be represented
in a matrix and the task of predicting the missing ratings can be considered as filling in
the blanks such that the values would be consistent with the existing ratings in the
matrix. The intuition behind using matrix factorization to solve this problem where
there should be some latent features that determine how a user rates a book. For
example, two users would give high ratings to a certain book if they both like the plot
and characters in the book, or if the book is a drama, which is a genre preferred by both
users.

1
1.2 Problem Definition

The traditional book ordering system is a manual and time-consuming process where
the customer has to visit a bookstore to search and purchase the books. In this tight
schedule, problems arise in finding specific books due to the inadequate distribution of
books through the bookshop. The buyer could not get a recommendation for the correct
selection of books.

1.3 Objective

The general objective of the project is to develop a web application to search and
purchase books stored online.
The Specific Objectives are listed below:
• To provide platform to view the books online.
• To purchase books online.
• To recommend a book to a user/buyer.

1.4 Scope and Limitation

User can register and create account to search books from wide collection of books
which reduce user’s searching time as books are arranged and distributed based on
categories. Books can be purchased online through COD (Cash on Delivery) method.
Recommendation system provides best rated book to the user for purchase.

For large number of data, larger server are needed to run the programs smoothly and
efficiently which we cannot implement in our local server. This project is limited to
only cash on delivery method of payment. Only highest rated books are recommended
as this system does not facilitates hybrid recommendation techniques.

1.5 Report Organization

The report is organized into seven chapters. Chapter 1 includes description about online
shopping and recommendation systems, problem statements, objectives, scopes and
limitations. Chapter 2 contains literature review about the previous work done in related
fields. Chapter 3 comprises of requirement analysis, feasibility analysis of the system.
The requirements analysis further consists of functional and non-functional

2
requirements. Economic, technical and operational feasibilities are some listed
feasibilities. Chapter 4 consists of system design which includes data model (ER-
diagram), process model (DFD diagram), schema diagram and class diagram. Chapter
5 consists of methodology that consist of system architecture and methods used in both
admin and user sides and algorithm used to build the system. Chapter 6 includes
implementation and testing of the system. Testing further comprises of unit testing,
integrated testing and system testing. Chapter 7 includes conclusions and future
enhancements.

3
CHAPTER 2: LITERATURE REVIEW
Recommender system has been so extensively used these days that it has become a
preferable choice for researchers. First paper on recommender system was published in
year 1998. Since then a significant number of papers had been published. Different
factors have been explained to increase the reliability of recommender system.
Mathwicketal., (2002) , “if online shopping meets this ideal by enabling the consumer
to accomplish the shopping task he or she has set out to perform , then consumers will
judge the Internet shopping performance positively.” [1]
Childers et al., (2001) found “‘enjoyment’ to be a consistent and strong predictor of
altitude towards online shopping experience, they have a more likely to adopt the
Internet as a Shopping medium.” [2]
According to Hoge (1993), Electronic marketing (EM) is the transfer of goods or
services from seller to buyer that involves one or more electronic methods or media.
EMarketing began with the use of telegraphs in the nineteenth century. With the advent
and mass acceptance of the telephone, radio, television, and then cable, electronic
media have become the dominant marketing force. Hoge’s (1993) idea of E-marketing
is simple but it does not touch the important aspect of customer relationship. Strauss
and Ansary (2006) defined E-marketing in their latest book as the use of information
technology in the process of creating, communicating, and delivering value to
customers, and for managing customer relationships in ways that benefit the
organization and its stake holders. [3]
Electronic Commerce (e-commerce) applications support the interaction between
different parties participating in a commerce transaction via the network, as well as the
management of the data involved in the process. [4]
The task of recommender algorithm concerns the prediction of the users rating for the
target item that the user has rated, based on the user’s ratings on observed items. The
increasing importance of e-commerce is apparent in the study conducted by researchers
at the GVU (Graphics, Visualization, and Usability) Center at the Georgia Institute of
Technology. In their summary of the findings from the eighth survey, the researchers
report that "e-commerce is taking off both in terms of the number of users Shopping as
well as the total amount people are spending via Internet based transactions". Over three

4
quarters of the 10,000 respondents report having purchased items online. The most cited
reason for using the web for personal shopping was convenience (65%), followed by
availability of vendor information (60%), no pressure from salesperson (55%) and
saving time (53%).Although the issue of security remains the primary reasons why
more people do not purchase terms online, the GVA survey also indicates that faith in
the security of e-commerce is increasing. As more people gain confidence in current
encryption technologies, more and more users can be expected to frequently purchase
items online. [5]
In year 2005 John O’Donovan, Barry Smyth [6] have taken trust as the percentage of
correct predictions that, a profile has made in general (profile-level trust) or with respect
to a particular item (item-level trust). Authors have described a number of ways in
which these different types of trust values might be incorporated into a standard
collaborative filtering algorithm and evaluated each against a tried-and-test benchmark
approach and on a standard data-set. This decreases the prediction error by 22%.
In 2008 [7] Kleanthi Lakiotaki, Stelios Tsafarakis, and Nikolaos Matsatsinis proposed
UTA-Rec. UTARec is a Recommender System that incorporates Multiple Criteria
Analysis methodologies. The system’s performance and capability of addressing
certain shortfalls of existing Recommender Systems is demonstrated in the case of
movie recommendations. UTARec’s accuracy is measured in terms of Kendall’s tau
and ROC curve analysis and is also compared to a Multiple Rating Collaborative
Filtering (MRCF) approach. Juan A.
Mucheol Kim & Sang Oh Park [8] in 2011 proposed an intelligent movie recommender
system with a social trust model. The proposed system is based on a social network for
analyzing social relationships between users and generated group affinity values with
user profiles. In experiments, the performance of this system is evaluated with
precision-recall and F-measures
In year 2012 Punam Bedi, Ravish Sharma [9] proposed Trust based Ant Recommender
System (TARS) that produces valuable recommendations by incorporating a notion of
dynamic trust between users and selecting a small and best neighborhood based on
biological metaphor of ant colonies. Along with the predicted ratings, displaying
additional information for explanation of recommendations regarding the strength and
level of connectedness in trust graph from where recommendations are generated, items

5
and number of neighbors involved in predicting ratings can help active user make better
decisions. Also, new users can highly benefit from pheromone updating strategy known
from ant algorithms as positive feedback in the form of aggregated dynamic trust
pheromone defines ‘‘popularity’’ of a user as recommender over a period of time. The
performance of TARS is evaluated using two datasets of different sparsity levels viz.
Jester dataset and MovieLens dataset (available online) and compared with traditional
Collaborative Filtering based app convince users about the product. It is an agent based
recommender system. It combines hybrid recommender system with automated
argumentation. The experimental study in conducted for book recommender system.
Recommender system is one application which is being used by many vectors and
online service providers to believe the necessity of online users. Thus the recommender
system is presented as an intelligent system, which identifies the user category having
a basis on the user information and then user interest analysis. Once such information
is obtained, in second stage, the analysis is performed to obtain the similarity group
respective to necessity products and services. To perform such kind of analysis there
are some existing techniques such as content based as well as collaborative
recommender systems. [10]
A CF-based system associates a user with a group of like-minded users based on user
interaction information over all the items, and then recommends to the user the item
enjoyed by the group. User interaction information might be provided explicitly by the
individual person or gathered implicitly by a software agent.1) Explicit user
information collection basically depends on personal input by the user. A common
feedback technique is that allows users to express their opinions.2) Implicit feedback
does not require any additional interaction by the user during the process of constructing
profiles and automatically updates as the user interacts with the system. A group of
likeminded users are said to be neighbors. [11]
In the beginning, Goldberg et al used Collaborative filtering (CF) for introducing their
filtering system that gives ability to customer for explanation their e-mails and
documents. [12]
Recommender systems become an important research area since the appearance of the
first papers on collaborative filtering in 1990s .There has been much work done both in
the industry and academic area for developing new approaches in recommender

6
systems over the last decade. The interest in recommendation system still remains high
because it constitutes a problem-rich research area and because of practical applications
that help users to deal with information overload and provide personalized
recommendations, content, and services to them. The basic assumption is that the users
with similar behavior on observed items (e.g., ratings) will have similar tastes on
unobserved items. Examples of such applications include recommendations of various
books, CDs, products at Flipkart.com, movies by Movie Lens, and news at VERSIFI
Technologies. [13]

7
CHAPTER 3: SYSTEM ANALYSIS AND FEASIBILITY
STUDY
3.1 Requirement Analysis

3.1.1 Functional Requirements


The functional requirements of book recommendation system includes allowing user to
view site without logging to the site. Books are recommend to the user using
mathematical analysis of their behavior. Book recommendation system allow users to
register and rate books and create a useful knowledge base from the data that will be
useful for making recommendation.
Use Case Diagram

Figure 3.1 Use Case Diagram for Online Bookstore

8
Figure 3. 1 shows the use case diagram for this website. User and Admin are the two
actors included in the Online Book Store where Admin is known as super user. User
can login, browse home page, rate a book, search a book, view recommended books
,manage his/her shopping carts, view profile, edit profile and logout. Admin can also
act as user so s/he can do the tasks of users and also manage users and books.

3.1.2 Non- Functional Requirements


Non-functional requirements of the project are as follows:
Performance
Being a web-based system, the performance depends on the server itself, how the server
responses to the request determine the performance of the system. The system is
efficient in resource utilization like memory, CPU, storage etc.
Scalability
The system provides different features for both admin and users. The system is able to
serve large number of users as per demand.
Reliability
The system provides reliable recommendation to the users based on matrix factorization
algorithm.
Usability
The system can be used by any user by registering to the site.
Interoperability
The system is built by integrating python using Django Framework, html, css,
bootstrap, JavaScript. So, they operate together.

3.2 Feasibility Analysis

3.2.1 Operational feasibility


The system is highly user friendly and it is much easier to interact with the user. User
does not need special training to operate the system. Therefore, the system will provide
maximum easiness.
3.2.2 Technical feasibility
This is concerned with the specifying equipment and software that successfully satisfy
the requirements. The system is technically feasible as it can be developed easily with

9
the help of available technology. The system requires HTML (Jinja template), CSS,
Bootstrap, JavaScript which is used as front-end and WSGI server, Django framework
as back-end and python as both.
3.2.3 Economic feasibility
Economic analysis is the most frequently used technique for evaluating the
effectiveness of the system. The tangible benefits proposed that the manual work and
burden is reduced maximum as possible, resulting the reduction in manpower
requirement and cost incurred on manpower as well. The system provides many
benefits that can’t be measured in terms of money for e.g. user friendliness, more
efficient user response, maintenance of database, etc.

3.3 Data Model

3.3.1 E-R diagram

10
Figure 3. 2 E-R diagram
Figure 3.2 shows the logical relationship between numbers of entities. Rating, User,
Order, Category, Book are the entities and each entity has their respective attributes.

11
CHAPTER 4: SYSTEM DESIGN
4.1 System Architecture

Figure 4. 1 System Architecture

The Figure 4.1 describes the architecture of the online bookstore with recommendation
and searching. The user request resources in the web browser in the client side, the
system processes them using the system modules and database and responses with new
view.

4.2 Process Model

4.2.1 Level-0 DFD diagram

Figure 3. 3 Level-0 DFD Diagram

12
Figure 3.2 diagram has been used for the visualization of data processing and structured
design of the Book Store process and working flow. Level-0 DFD is often used as a
preliminary step to create an overview of the Book Store without going into great detail,
which can later be elaborated. It normally consists of overall application dataflow and
processes of the Book Store process. It contains all of the user flow and their entities.
4.2.2 Level-1 DFD Diagram

Figure 3. 4 Level-1 DFD Diagram

In the Figure 3.3, each of the process has its own input and output. In Level-1 DFD we
take the process 0, Book Recommendation process and break down into number of
process as 1.0 Book Management process, 2.0 Recommendation process and 3.0
Interaction systems.

13
Figure 3. 5 Level-1 DFD for Recommendation Process
In Figure 3.4 we take the process 2.0, Recommendation process and break down into
2.1 Data Repository System and 2.2 Matrix Factorization. Data Repository System is
linked with different dataset i.e. User Dataset and Rating Dataset.

Figure 3. 6 Level-1 DFD for Interaction System

14
In Figure 3.5 we take the process 3.0, Interaction System and break down into different
process as 3.1 User Recommender Process, 3.2 Search Process and 3.3 Rating Process.

4.3 Schema Diagram

Figure 4. 2 Schema Diagram for Online bookstore

The Figure 4.3 is the visual representation of organization and structure of our database.
It contains schema objects like tables, columns, data types, relationships, primary key,
foreign keys, etc. It shows seven tables, along with their data types, relationships
between the tables, as well their primary keys and foreign keys.

15
4.4 Class Diagram

Figure 4. 3 Class Diagram for Online bookstore

The Figure 4.4 is a static structure diagram that describe the structure of our system by
showing the system’s classes, their attributes, operations (or methods) and the
relationship among the objects. In the above diagram classes are represented with boxes
that contains three compartments. The top compartment contains the name of the class
which is centered and the first letter is capitalized. The middle compartment contains
the attributes of the classes. The bottom compartment contains the operations the class
can execute. Notations are used to specify the visibility of a class member and must be

16
placed before the member’s name. In the diagram ‘+’ notations specify public visibility
while ‘-’ notation specify private visibility. Relationships like association, dependency,
aggregation, composition are represented using logical connectors between the boxes.
Relation between Category and Product that a single category can contain multiple
products. Similarly a single product can have multiple ratings and a single user can rate
multiple product. User can be admin represented by is_staff attribute or a regular user
with no staff status.

4.5 Activity Diagram

Figure 4. 4 Activity Diagram of System

17
The Figure 4.5 shows that the user can browse the website and can perform search book
or get recommendation of book. After a search if the product is available the user can
view the details of the product only if he/she is logged in or continue another successful
search. If the user is not a registered user he/she need to register to the system for their
unique account. After viewing the product if the user is satisfied with the product then
the user can add the product to the cart or continue shopping. Similarly the user can
update cart like increasing the quantity of the product or remove the product from the
cart. After that the user can continue browsing again or checkout and logout of the
system.

18
CHAPTER 5: METHODOLOGY
5.1 Tools Used

Front-end Tools
• HTML5 with Jinja Templates
It is used to display content of the website.
• CSS3
It is used as the styling tool for the website.
• JavaScript
It is used in the project to provide responsive feature.
Back-end Tools
• Python with Django Framework
It is used to build the entire project.
• MYSQL Database
It is used in the project for database design, maintenance and storage.

5.2 Admin and Customer

The system has been implemented using the Python Programming Language with
Django Framework. Here, we implemented the Matrix Factorization Algorithm based
on Collaborative Filtering technique to provide recommendations to the customers.
In the Admin and Customer side, for each features, there are classes, models, functions
or Python codes in web pages involving the requests from users or display the result on
the web pages.
5.2.1 Admin Side
1. Create Username and Password
• createsuperuser keyword is used to create admin and password.
2. Login
• Login validation is done by django authorization (django.contrib.auth)
module.
3. Manage Category (Create, Update, Delete)
• category model is created using “class Category(models.Model)” .
• attributes for categories are defined under the Category class.
• using makemigration module the class is migrated to database

19
• from database a new category can be added, existing category can be
updated or deleted.
4. Manage Book(Create, Update, Delete)
• model for book is created using “class Product(models.Model):”
• attributes of books are defined under the Product class.
• using makemigration module the class is migrated to database
• from database a new book can be added, existing book can be updated
or deleted.
5. Manage Customer
• The new customers and their status are viewed by suing Django User
model.
• New customers are saved in database through registration process using
the function def register_user(request):
• Django User model facilitates controls over users.
6. Manage Order
• Orders are stored and can be viewed from Orders Model
• class Order(models.Model) is used to build Orders Model along with
defining the attributes of the class.
7. Logout
• logout is also defined by django authorizarion (django.contrib.auth)
module.
5.2.2 Customer Side
1. Create an account for new customer(register)
• New users are registered using def register_user(request) function.
2. Login
• Registered users can login through def login_user(request) function
which is accommodate by django authorization module
django.contrib.auth authenticate, login.
3. Select category and book
• Any visitor can view book list and browse through category defined
under class Category and class Product

20
• To view book detail user must be a registered user.
• Books from database are listed in web page using
products = Product.objects.filter(available=True) in list.html
• Detail of books are presented using
product = get_object_or_404(Product, id=id, slug=slug,
available=True) in detail.html.
4. Search book
• User can search books by typing book title in the search bar
if 'search' in request.GET:
search_term = request.GET['search']
products= product.objects.filter(name__icontains=search_term)
if products:
messages.success(request,(''))
else:
messages.success(request, ('Book not found'))

• name__icontains is used to facilitates case-insensitive search


• if search_term doesn’t match any book title “Book not found message is
displayed”.
5. Rate Book and get recommendations
• User can rate books by providing star rating.
• The rating are stored in database inside Myratings Model build by
class Myrating(models.Model)
• The ratings,user_id, and product_id is used to provide recommendation
using Matrix Factorization Algorithm defined under def
Myrecommend() functions
• Following toolkit (python libraries) are used to calculate the matrix.:
 Numpy. Adds Python support for large, multi-dimensional
arrays and matrices, along with a large library of high-level
mathematical functions to operate on these arrays.

21
 SciPy is a collection of mathematical algorithms and
convenience functions built on the Numpy extension of Python.
It adds significant power to the interactive Python session by
providing the user with high-level commands and classes for
manipulating and visualizing data.
 Pandas. Software library written for data manipulation and
analysis in Python. Offers data structures and operations for
manipulating numerical tables and time series.

6. Add to cart, update cart , remove book from cart


• def cart_add(request, product_id): used to add book in cart
• def cart_remove(request, product_id): used to remove book from cart
• def cart_detail(request): used to view cart details and update book in
cart.

7. Checkout and Confirm order


• def order_create(request):is used to checkout and confirm the order
• the order are stores in Orders Model in database.

5.3 Algorithm Used For Recommendation

5.3.1 Matrix Factorization Algorithm


The algorithm used in this system is Matrix Factorization Algorithm. It is a class
of collaborative filtering algorithms used in recommender systems. Matrix
factorization algorithms work by decomposing the user-item interaction matrix into the
product of two lower dimensionality rectangular matrices. In the system it is used for
recommending the books to the customers. It recommend the product that are highest
rated by the customers. When the customers wants to get the recommended books this
algorithm recommends the books that are highest rated among all the available books
in the system. This helps to save time of customers as only the best books are
recommended.

22
The idea behind matrix factorization is to represent users and items in a lower
dimensional latent space.
Technique:
Singular Value Decomposition (SVD++)
It is model-based approach that factorize the user-item rating matrix as the product of
two lower dimensional matrices, the first one has a row for each user, while the second
has a column for each item. The row or column associated to a specific user or item is
referred to as latent factors. It compress user-item matrix into a low-dimensional
representation in terms of latent factors. One advantage of using this approach is that
instead of having a high dimensional matrix containing abundant number of missing
values we will be dealing with a much smaller matrix in lower-dimensional space.
Algorithm:
Inputs:
Total users and Total ratings are taken in data frame along with user and product id.
Output:
Sorted rating indexes and list of recommended products.
Process:
Myrecommend( )
Step 1:Normalizing Y and R where Y=total rating and R=Total users stored in database.
Step 2:An array X and Theta is created with specified shape and filling with random
values.
Step 3:X and Theta are converted into 1D array.
Step 4: Cost function and Gradient function is calculated
Step 4:Result array is obtained by optimizing coficostFunc,Myflat,cofiGrad and
arguments. (Y,R,Mynu,Mynf,Mylambda) with specified iteration.
Step 5:The obtained result is reshaped into 1D array resX, resTheta
Step 6:Prediction_matrix is returned with dot product of resX and resTheta. Ymean and
prediction_matrix is returned from Myrecommend( ).
Step 7:Calculate my_prediction array by using flatten( ) function on Ymean
Step 8:Sorting my_prediction array value using np.argsort to form pred_indx_sorted
Step 9: pred_indx_sorted is the sorted 1D array of ratings indexs which is then
evaluated by slicing each element with slicing function from bottom to top

23
Step 10 : Condition like “case” and “when” is used to check if the correct product is
returned
Step 11:Product_list is displayed if the product is present in Product_list and satisfied
by the condition of Step 10.

24
CHAPTER 6: IMPLEMENTATION AND TESTING
6.1 Implementation

Book Management
In database admin can create new category and add books. Books can further be
managed (edit, delete).

Figure 6. 1 Add product

Figure 6. 2 Change product

Figure 6. 3 Delete product

Book Searching
User can search books by typing book title in the search bar. If book is available in
database, it is displayed otherwise a message “Book not found” is displayed.

25
Figure 6. 4 Book not found message

Book Recommendation
A user get recommended books when they choose “Get Recommendation”.

Figure 6. 5 Product recommended by algorithm.

26
Figure 6. 6 Recommended books

Order Placement
An order is placed when a user submits the order. Order include the products and user
information.

Figure 6. 7 Order registered in a database

Rating Submission
User can rate a book based on their preferences. Ratings are submitted in database.

Figure 6. 8 Rating Submitted in a database

27
6.2 Testing

6.2.1 Unit Testing


Separately each and every functional module is tested and the result of that module is
analyzed. The module interface is tested to ensure that the information flows in and out
of the program under unit test. Each unit of the software is tested to verify that the
detailed design for the unit has been correctly implemented. Unit testing can be given
by following test cases. Some test cases are as follows:

Table 6. 1 Test Case for Admin Login and logout

Test Case Input Expected Result Test Result


Successful Username = kapeed, Successful Login Admin
Admin Login Password = of admin successfully logged
kapeed123 in
Admin Login Username = kapeed, A message “Please A message “Please
Fail Password = enter the correct enter the correct
kapeed1234 username and username and
password for a password for a staff
staff account. Note account. Note that
that both fields both fields may be
may be case- case-sensitive.” is
sensitive.” should displayed
be displayed
Successful Click logout option The page should be The page
Admin Logout redirected to admin redirected to admin
login page login page.

28
Table 6. 2 Test Case for User Registration

Test Case Input Expected Result Test Result


Successful Username= madan10, A message” You A message”
User First Name=Madan, have been You have been
Registration Last Name=Bhandari, Registered!!!” Registered!!!”
Email should be is displayed
Address=mdns@gmail.com, displayed
Address=Sallaghari,
Bhaktapur,
Phone Number=9841168126
Password=madan123
Confirm
Password=madan123
User Username= madan10, A message” A message”
Registration First Name=Madan, ERROR ERROR
Fail Last Name=Bhandari, Registering... Registering...
Email The two The two
Address=mdns@gmail.com, password fields password fields
Address=Sallaghari, didn't match.” didn't match.” is
Bhaktapur, should be displayed
Phone Number=9841168126 displayed
Password=madan123
Confirm
Password=madan1234

Table 6. 3 Test Case for User Login and Logout

Test Case Input Expected Result Test Result


Successful User Username = The login page The login page is
Login madan10, should redirect to redirected to

29
Password = homepage with homepage with
madan123 logged in status logged in status
and a message and a message
“You have been “You have been
logged in!!!” logged in!!!” is
should be displayed.
displayed.
User Login Fail Username=rabee, A message “Error A message “Error
Password=rabe123 login in - Please login in - Please
Try Again!!!” Try Again!!!” is
should be displayed.
displayed.
Successful User Click Logout option The page should The page is
Logout redirect to redirected to
homepage without homepage without
logged in status logged in status
and a message and a message
“You have been “You have been
logged out!!!” logged out!!!” is
should be displayed
displayed.

Table 6. 4 Test Case for Search

Test Case Input Expected Result Test Result


Searching Search keyword = All the book whose All the book whose
“Life” title contains the title contains the
keyword “Life” keyword “Life” are
should be displayed displayed

30
Searching failed Search keyword = A message “Book A message “Book
“abcdefg” not found”should not found” is
be displayed displayed

Table 6. 5 Test Case for Categories

Test Case Input Expected Result Test Result


Book Browsing Specific category Only the book Only the book
based on is clicked belong to clicked belong to clicked
Categories category should be category is
displayed. displayed.

Table 6. 6 Test Case for Recommendation

Test Case Input Expected Result Test Result


Get Recommended Get recommended A page with A page with
Books book option is recommended recommended
clicked book based on book based on
highest ratings highest ratings is
should be displayed.
displayed.

Table 6. 7 Test Case for Add to Cart

Test Case Input Expected Result Test Result


Add to cart Click on Add to Book should be Book is added to
cart button of book added to user’s cart. user’s cart.

Table 6. 8 Test Case for Continue Shopping

31
Test Case Input Expected Result Test Result
Continue Shopping Click on Continue The page should The page is
Shopping button redirect to home redirected to home
on cart page page and user page and user can
should be allowed add more books in
to add more books the cart.
in the cart.
Table 6. 9 Test Case for Checkout

Test Case Input Expected Result Test Result


Checkout Click Checkout The page should The page is
button on cart page redirect to create redirected to create
order page and user order page and user
should be asked to is asked to enter
enter contact and contact and address
address details for details for
confirmation. confirmation.

Table 6. 10 Test Case for Successful Order Submission

Test Case Input Expected Result Test Result


Submit Order Click Submit order The page should The page is
button redirect to page redirected to page
which display the which display the
message” Your message” Your
order has been order has been
successfully successfully
completed” along completed” along
with order id. with order id.

32
6.2.2 Integration Testing
The system was tested again to know whether it is functioning properly or not after
integration. In integration Testing two units have been generalized; admin login and
update books.

Table 6. 11 Test Case for Book Update

Test Case Input Expected Output Test Result


Admin Login Username= Admin panel Admin panel is
kapeed, should be displayed
Password = displayed
kapeed123
Book Update Add, delete or edit Books should be Books is added to
books. added to the the database, edited
database and and deleted.
displayed to the
browser, should be
edited and deleted
on click.

Table 6. 12 Test Case for Buying Books

Test Case Input Expected Output Test Result


Customer Login Username= Homepage with Homepage with logged
madan10, logged in status in status is displayed
Password = should be displayed
madan123

33
Customers getting Click Get Customer should get Highest rated books are
recommendations recommendation recommended books recommended
based on highest
ratings.
Customer buying Select the book, click Order should be Order is submitted and
book add to cart, checkout submitted and registered in database.
and submit order registered
sequentially. successfully
6.2.3 System Testing
System testing not needed.

Under system testing, the system as a whole was tested to ensure that the system is
functioning correctly and efficiently after all the required modules were developed and
integrated and to make sure it meets all the requirements. In this testing, whole
application was tested to check the errors. The system was tested by the data supplied
by users. System testing reveals errors and omission in the system requirement
definition because the real data exercise the system in different ways from the data
presented during testing phase. From the user perspective, the system testing was done
testing by first registering the user. After valid registration, the user was able to login
to their account using valid credentials. The user could browse books according to their
interest. They could search the product using particular keyword and even browse
books based on specific categories of their interest. User adds the product of interest to
user’s cart and confirms order by checking out with proper contact and address details.
User can also get recommendation based on highest rated books from the catalog of
book. The user can log out any time the user wants to. From the admin perspective, the
admin logs in and can manage the products. The admin can add the product, delete or
edit the product. The admin also checks for the users, order and order details.

6.3 Result Analysis

34
CHAPTER 7: CONCLUSION AND FUTURE
ENHANCEMENT

7.1 Conclusion

The project has been developed successfully and the performance of the system has
been found good. The system provides platform to view the books online and can
purchase them. The books are recommended to the users using matrix factorization
technique. The system is efficient in maintaining customer’s details, reduces the work
load of the shopkeeper to know the quantity of books available and also keep the records
of how many books are purchased and sold.

7.2 Future Enhancements

New features could be added to this project for making this project more productive,
reusable and flexible which include online payment service and hybrid
recommendation.

35
References

[1] C. M. N. a. R. E. Mathwick, "The effect of dynamic retail experiences on


experimental perceptions of value; an dynamic internet and catalog
comparison," Journal of Retailing, vol. 78, no. 1, pp. 55-60, 2002.
[2] T. C. C. P. J. a. C. S. Childers, "Hedonic and utilitarian motivations for online
retail shopping behavor," Journal of Retailing, vol. 77, no. 4, pp. 511-535,
2001.
[3] M. M. Salehi, "Dissimilarity of E-marketing VS traditional marketing," 2012.
[Online]. Available: https://studylib.net/doc/8411741/dissimilarity-of-e-
marketing-vs-traditional-marketing. [Accessed 23 June 2019].
[4] Park, D.-H. & -K.-Y., "A Literature Review and Classification of
Recommender Systems on Academic Journals," 2011. [Online]. Available:
https://www.sciencedirect.com/science/article/pii/S0957417412002825.
[Accessed 23 June 2019].
[5] M sharma,Smann, "A survey of Recommender systems :Approaches and
Limitations," 2013. [Online]. Available:
https://www.semanticscholar.org/paper/A-Survey-of-Recommender-
Systems%3A-Approaches-and-Sharma-
Mann/fa41dc4b60eccedf1c41e2ae488044827dd79384. [Accessed 23 June
2019].
[6] B. S. John O'Donovan, "Trust in recommender systems," Proceedings of the
10th international conference on Intelligent user interfaces, 2005.
[7] K. Lakiotaki, "UTA-Rec: A Recommender System based on Multiple Criteria
Analysis," RecSys’08, pp. 219-225, 2008.
[8] S. O. P. Mucheol Kim, "Group affinity based social trust model for an
intelligent movie recommender system," Multimedia Tools and Applications,
vol. 64, no. 2, pp. 505-516, May, 2013.

36
[9] R. S. Punam Bedi, "Trust based recommender system using ant colony for
trust computation," Expert Systems with Applications: An International
Journal, vol. 39, no. 1, pp. 1183-1190, January, 2012.
[10] Parul,k .khanna, "Literature Survey: Recommender Systems," 2015. [Online].
Available:
https://www.researchgate.net/publication/314838509_A_Brief_survey_on_Re
commender_System. [Accessed 23 June 2019].
[11] Jiajun.Bu,Xin.Shen,Bin.Xu,chunchen,XiaofeiHe,DengCai, "Improving
Collaborative Recommendation via User-Item subgroups," 2016. [Online].
Available: https://www.scribd.com/document/159689611/A-Survey-of-
Recommendation-System-Research-Challenges. [Accessed 23 June 2019].
[12] A .H Rafsanjani,NSalim,A R Aghdam,K B Fard, "Recommendation system: a
Review," Algorithms and Methods in recommendation systems, 2013.
[13] G..Adomavicius,A Tuzhilin, "Recommendation Technologies:Survey of
Current Methods and Possible Extensions," 2017. [Online]. Available:
https://www.computer.org/csdl/journal/tk/2005/06/k0734/13rRUxDIthy.
[Accessed 23 June 2019].

37
Appendix
Admin Login Page

Admin Panel

38
Product (Book Management)

User Interface

39
Book List

User Registration

40
User Login

Book Detail and Rating

41
Book Search (Game)

Book Search Failed (Book not available in database)

42
Recommended Books

Cart

43
Checkout

Order Submission

44

You might also like