SlideShare une entreprise Scribd logo
1  sur  34
1
Kathmandu BernHardt College
Bafal,Kathmandu
A Project Report On
“Medical Chat Bot Using Recurrent Neural
Network”
Submitted To:
Department of Computer Science and Information Technology
(Kathmandu Bernhardt College)
Submitted By:
Karina Shakya
2
ACKNOWLEDGEMENT
Our forthright gratefulness goes to Kathmandu Bernhardt College for wholehearted support
and for giving us this opportunity to undertake this case study.
We would like to extend our sincere gratitude to our supervisor Abhimanyu Yadav,
coordinator of Department of Computer Science, Kathmandu Bernhardt College, for his
kind and co-operative support, valuable time and guidance as well as suggestions.
We would like to express our gratitude to lecturers form Department of CSIT at Kathmandu
Bernhardt College for providing suggestions for this whole work and cooperative behavior. At
the end we would like to express our sincere thanks to all our friends and others who helped
us directly or indirectly during the preparation of this report.
Karina Shakya
Lakas Maharjan
Navin Timalsina
3
Abstract
Medical care is very important for a healthy life. However, it is very difficult to seek medical
attention if you have a health problem. The recommended notion is to develop a medical
chatbot that can adopt AI to analyze the ailment and produce necessary information concerning
the condition were discussing with a doctor. Chatbot is used extensively to check the state of
health at any time. It is the same as going to a doctor and having the medication prescribed.
This paper discusses about medical chatbot using the neural network algorithm which predicts
the disease. There are many neural network algorithms that can be used to predict the disease.
Recurrent Neural Network technique is primarily used to achieve precise prediction and boost
the efficiency of the model. The system uses Natural Language Processing to achieve the style
of chatting. The proposed system is not only to meet such requirements but also to maximize
the remotely done processes using Artificial Intelligence chatbot. A chatbot provides a
conversational interface to minimize the language gap between human and machine and
provides health diagnosis on the basis of symptoms and giving proper health related tips.
Keywords: Medical chatbot, Machine Learning Algorithm, Recurrent Neural Network,
Long Short Term Memory, Natural Language Processing.
4
LIST OF ABBREVATIONS
NLP Natural Language Processing
RNN Recurrent Neural Network
LSTM Long Short Term Memory
AI Artificial Intelligence
ML Machine Learning
DFD Data Flow Diagram
UML Unified Modeling Language
DFD Data Flow Diagram
NLTK Natural Language Toolkit
5
LIST OF FIGURES
Fig 1.1 Report Organization
Fig 1.2 Use case diagram
Fig 1.3 Gantt chart
Fig 1.4. Context level
Fig 1.5. Level 1 DFD
Fig 1.6 LSTM Network
Fig 1.7 LSTM Gates
6
Chapter 1: Introduction
1.1 Introduction
Artificial Intelligence has taken over in lots of aspects in field of technology. Use of robots in
industries and automated features in gadgets that simulates human intelligence have influenced
very sectors. Similar to these, chatbots are also one of the part of innovation of AI. Nowadays
chatbots or simply bots are widely used in different kinds of business for various purpose.
Chatbot are the software application designed to interact with user via human-like text in
natural language. It is an application that is intended to provide natural and accurate reply to
the query asked by the user. The vast amount of information that is available on the internet
allows Chatbots to provide accurate and efficient information based on the user’s requirements.
Chatbots are used in domains like Customer Support, Virtual Assistance, Online Trainings,
and Online Reservations and also for general conversations.
Most of the time different organization and business uses chatbot to handle minor task and
provide customer service. Use of chatbots helps in saving up time of support staff and reduces
cost to hire staff for minor roles. Beside this chatbot can also help in attracting customer
attraction since it can initiate regular conversation with consumer just like human.
Initially, when a user posts the queries to the chatbot the bot tries to find the related reply that
are more match able with query in its database. The database of the chatbot is preloaded with
the possible queries and their corresponding replies. Based on these replies and queries in
database chatbot will try to have a conversation with the user.
Chatbots are actually intended to provide natural and accurate reply to the query asked by the
user. Chatbots are developed by implementation of different natural language processing or
NLP algorithm. . Basically, NLP is concerned with how technology can interpret and respond
to the human language inputs. In case of chatbots, NLP allows the bots to understand the user
message and respond it appropriately. For past years, developers have incorporated more
innovative techniques to enable chatbots to better understand people’s questions and provide
7
more useful responses. While today’s bots still can’t handle all customer queries, they can
respond to frequently asked questions or perform straightforward tasks.
The proposed “Medical chatbot” is an online chatbot that works in similar way as regular
chatbot but only provides health assistance to user. It is like an online medical consultant that
response to the symptoms asked by the user. The proposed system acts as an agent that replies
the user about their health issues or any other medical related issues. Based on the patterns
provided by the user, the chatbot will try to look for the accurate response since the relevant
amount of replies, queries and inputs are already present dataset.
The major focus of this chatbot is to optimize the communication behavior in smarter manner.
Beside this it is also proposed to provide immediate response for medical-aid so that user does
not have to go through different pages or sites to obtain accurate information.
1.2 Problem Statement
This project is focused to create a chatbot that will interact with the user and give them realistic
experience of chatting with medical professional. There are some medical chatbots already
exist that does not provide any direct response or medication needed for user query or illness
but redirects the user to some medical forum that shows the similar questions which are
previously answered. However, our system will provide the required response for the query by
matching the user message keyword with the keywords in database and will not exceed its
limitation.
1.3 Objective
 To build medical chatbot application using deep learning.
 To predict the probable disease by analyzing symptoms provided by user.
1.4 Scope and Limitations
1.4.1 Scope
The major scope of a medical chatbot can be assisting user for different health related subject
matter. Nowadays, use of digital device have increased a lot so a chatbot can be a simple tool
which will help user to predict possible disease in more efficient way.
8
The other scope for Medical chatbot are:
 This work can be further extended to providing information of different medicines,
treatment information.
 The chatbot can also be embedded with speech recognition feature where user can
verbally share their problem.
 The chatbot can also be extended with navigation function to locate nearby medical
centers.
 Moreover, the chatbot application can be further modified by adding user profile where
they can get connected with other user.
1.4.2 Limitation
Along with scopes and benefits this project also have some shortcomings and limitations which
are highlighted in following points:
 This program is applicable only for certain diseases.
 It will only predict the possible disease but will not prescribe any drugs or medicines.
 Based on the symptoms the chatbot will response to the queries but will not ask any
query.
 The chatbot will provide accurate disease only if multiple symptoms is provided.
1.5 Development Methodology
Artificial intelligence is the driving force behind the development of breakthrough
technologies such as self-driving cars and chatbots. Because of modern improvements in
Natural Language Processing (NLP), chatbots, also known as virtual assistants, are now a
viable alternative for improving the customer experience. In this project we have built a
chatbot that will predict the possible disease based on the symptoms provided by user.
The chatbot development methodology blends several modern frameworks and methodologies
including design thinking, AI innovation sprints, agile and waterfall software development.
9
In this project we will be following Waterfall Software Development Methodology. Waterfall
methodology is also referred to as a linear-sequential life cycle model. It is very simple to
understand and use. In a waterfall model, each phase must be completed before the next phase
can begin and there is no overlapping in the phases.
The Waterfall model is the earliest SDLC approach that was used for software development.
The waterfall Model illustrates the software development process in a linear sequential flow.
This means that any phase in the development process begins only if the previous phase is
complete. In this waterfall model, the phases do not overlap.
The sequential phases in Waterfall model are −
• Requirement Gathering and analysis − All possible requirements of the system to be
developed are captured in this phase and documented in a requirement specification
document.
• System Design − the requirement specifications from first phase are studied in this
phase and the system design is prepared. This system design helps in specifying hardware
and system requirements and helps in defining the overall system architecture.
• Implementation − with inputs from the system design, the system is first developed in
small programs called units, which are integrated in the next phase. Each unit is developed
and tested for its functionality, which is referred to as Unit Testing.
• Integration and Testing − All the units developed in the implementation phase are
integrated into a system after testing of each unit. Post integration the entire system is
tested for any faults and failures.
• Deployment of system − Once the functional and non-functional testing is done; the
product is deployed in the customer environment or released into the market.
• Maintenance − There are some issues which come up in the client environment. To fix
those issues, patches are released. Also to enhance the product some better versions are
released. Maintenance is done to deliver these changes in the customer environment.
10
The following illustration shows waterfall methodology:
Fig 1.5 Waterfall Model
1.6 Report Organization
Altogether the project is divided into four different chapters, each representing different
development phase of project. The chapter can be discussed briefly as follows:
Chapter 1: It deals with introductory part of the project and explains about what the project
is, how it came in idea, the main objective of the project that are planned to be achieved after
the completion, its scope and limitations.
Chapter 2: This chapter is all about research process carried out to do the project. It consist
the background idea for the project as well as the study process that are required for this
application to be popular among users.
Chapter 3: This chapter deals with the analysis phase. It consist of all the requirement and
feasibility analysis needed for the system.
Chapter 4: This chapter is all about the design phase. System design consist of database
design, interface design and process design that are carried out to build this application.
11
Fig 1.6: Diagram representing report organization
Chapter 1
Introduction
Chapter 2
Background Study and research
Chapter 3
System Analysis
Chapter 4
System Design
12
Chapter 2: Background Study and Literature Review
2.1 Background Study
There are two basic types of chatbot models based on how they are built; Retrieval based and
Generative based models [12].
I. Retrieval Based: A retrieval-based chatbot uses predefined input patterns and
responses. It then uses some type of heuristic approach to select the appropriate
response. It is widely used in the industry to make goal-oriented chatbots where we
can customize the tone and flow of the chatbot to drive our customers with the best
experience.
II. Generative Based: Generative models are not based on some predefined responses.
They are based on sequence to sequence neural networks. It is the same idea as machine
translation. In machine translation, we translate the source code from one language to another
language but here, we are going to transform input into an output. It needs a large amount of
data and it is based on Deep Neural networks.
In this project we will be using retrieval based model to build chatbot. We are building chatbot
using deep learning approach. The chatbot will be trained on the dataset which contains
categories (intents), pattern and responses. We use a special recurrent neural network (LSTM)
to classify which category the user’s message belongs to and then we will give a random
response from the list of responses.
Stemming and Lemmatization: Stemming and Lemmatization are Text Normalization (or
sometimes called Word Normalization) techniques in the field of Natural Language
Processing that are used to prepare text, words, and documents for further processing.
2.2 Literature Review
There are many medical chatbot that has been designed in past few years which aims at
providing medical guidance and recommends medicine based on the symptoms provided by
the user.
13
A similar paper “Pharmabot: A Pediatric Generic Medicine Consultant Chatbot” proposed by
Benilda Eleonor V. Comendador, Bien Michael B. Francisco, Jefferson S. Medenilla, Sharleen
Mae T. Nacion, and Timothy Bryle E. Serac provides a design for a stand-alone medical
Chatbot that is implemented using MS Access and Visual C# . For using the proposed design,
the user has to navigate using the four options provided by the application. This design aims
to work by converting the user input to SQL queries and execute it on MS Access to retrieve
the solution to the illness [1].
Another paper “A Self-Diagnosis Medical Chatbot Using Artificial Intelligence” proposed by
Divya S1 , Indumathi V , Ishwarya S , Priyasankari M , Kalpana Devi S provides a medical
chatbot system built in python. This system has the user dialogue is a linear design that
proceeds from symptom extraction, to symptom mapping, where it identifies the corresponding
symptom, then diagnosis the patient whether it’s a major or minor disease and if it’s a major
one an appropriate doctor will be referred to the patient, the doctor details will be extracted
from the database, the user will be identified by the login details which is stored in the database
[2].
Elomia is another AI powered chatbot which acts as a virtual therapist. This chatbot was trained
to create by the observation of past therapies conducted by doctors. Elomia assist for the
treatment related to mental health like anxiety, depression, loneliness, sleep issues etc.
Youper’s AI monitors and improves the emotional health of the user through quick
personalized conversation using psychological techniques. This chatbot app features
personalized meditation and ability to track mood and monitor emotional health [8].
14
Chapter 3: System Analysis
3.1 System Analysis
3.1.1 Requirement Analysis
1. Functional Requirement
The functional requirement of this system will include following module:
1.1 Registration Function
In this project we have created registration function where user will have to register before
entering chatbot. The user data is stored in database and through this database user is
validated.
1.2 Login Function
As mentioned above user must register for entering chatbot. Only the register user can have
access to chatbot. User should enter contact number and password to log in. The password
and contact number should matched with the data in database.
1.3 Admin Function
Admin will be in charge of maintaining database of the chatbot. The response and possible
queries will be updated and managed by the admin.
1.4 Chat Function
In this medical chatbot user can have direct conversation with the bot via chat. Just like
any other messaging application this application allows user to communicate via text.
Use case diagram
Use-case diagram is used to capture the dynamic aspects of a system. They can be used to
gather requirements of a system including internal and external influences. The stick man
represents an actor i.e. user or admin.
15
Fig 3.1 : Use case diagram for demonstrating admin and user role
2. Non-Functional Requirement
a. User Friendly: The term user-friendly is self-explanatory. Users can easily use the web
application. The application uses a simplified design and navigation, as well as simple
language on the content to improve the user-friendliness.
b. Easy Access: It can be accessed from anywhere with an Internet Connection at the time of
election.
c. Information Accuracy: The web application makes sure to avoid making mistakes during
data and informational retrieval. Thus, the system provides the accuracy of information.
16
d. Speed of Application: The speed of application depends on basically two factors: System
configuration and Internet Speed. System with good configuration will most definitely lag
performance if the Internet bandwidth is below par and vice versa.
3.1.2 Feasibility study
A feasibility study is an analysis that takes all of a project's relevant factors into account—
including economic, technical, legal, and scheduling considerations—to ascertain the
likelihood of completing the project successfully. Project managers use feasibility studies to
discern the pros and cons of undertaking a project before they invest a lot of time and money
into it [3]. The various feasibility studies are:
i. Technical
The application is technically feasible; compiles with current technology, including both
the hardware and the software. The application is supported by almost all latest devices,
and most of all, it can be run on modern-day systems.
ii. Operation
The application solves the problem faced by the target group that was underlined as the
problem statement which makes it operationally feasible.
iii. Economic
The web application is available and accessible via the Internet which makes it economically
feasible. User only requires internet connection to access the chatbot. Moreover, there are no
charges of any sorts associated with contents in the web application.
3.1.3 Analysis
The medical chatbot project is developed with different function and modules.
Data Modelling with ER diagram
An Entity Relationship Diagram (ERD) shows the relationships of entity sets stored in a
database. An entity in this context is a component of data.
17
 ER Diagram: In the ER diagram we present entities along with attributes. For this
project we have three different entities: User, Chatbot and SQLite Database. Each of
these entities have their respective attributes.
Following are the attributes of the three entities of this chatbot.
o User : Name, Contact, Password
o Chatbot: Responses, tags
o DBSQLite: user table
The ER model for this project is shown below
Fig 3.2 : ER Diagram For Medical Chatbot
Process Modelling using DFD
Process modeling involves graphically representing the processes, or actions, that capture,
manipulate, store, and distribute data between a system and its environment and among
components within a system. We have represented the entire process of system using Data
Flow Diagram (DFD).
18
A Data Flow Diagram shows what kind of information will be input to and output from the
system, where the data will come from and go to, and where the data will be stored. A data
flow diagram takes business processes and activities and uses them to create a clear illustration
of how data flows through a system. DFDs represent the flow of data from external entities
into a single system by moving and storing data from one process to another.
Through the use of data flow diagrams, a system can be decomposed into subsystems, and
subsystems can be further decomposed into lower-level subsystems.
I. Context level diagram
User using this application must input the symptoms. Then the bot uses pattern
matching to classify the text and provide possible response to user.
Fig 3.3: Context level diagram for Medical Chatbot
II. Level 1 DFD
The detailed level 1 DFD can be further used to describe the process of
application.
Fig 3.4Level 1 DFD
19
Chapter 4: System Design
4.1 Design
System design is the process of defining the architecture, modules, interface and data for a
system to satisfy specified requirements. It is important phase of system development lifecycle.
During this phase for interpretation of finding and analysis the following design and diagrams
have been developed and thoroughly reviewed. Below is the system flow diagram of our
proposed system.
Fig 4.1 : System flow diagram of Medical Chatbot
20
4.2 Algorithm Details
Natural Language Processing (NLP)
The system follows the concept of NLP (Natural Language Processing. Basically, NLP is
concerned with how technology can interpret and respond to the human language inputs. In
case of chatbots, NLP allows the bots to understand the user message and respond it
appropriately.
Some of the Natural Language Processing steps are:
Sentiment Analysis: Tries to learn if the user is having a good experience or if the after
some point the chat should be forwarded to the human.
Tokenization: The NLP divides a string of words into pieces or tokens that are linguistically
symbolic or are differently useful for the application.
Named Entity Recognition: The chatbot program model looks for categories of words, like
the name of the product, the user’s name or address, whichever data is required [5].
Normalization: The Chatbot program model processes the text in an effort to find common
spelling mistakes or typographical errors that might the user intent to convey. This gives
more human like effect of the Chatbot to the users.
In this project chatbot will be trained on the dataset which contains categories (intents), pattern
and responses. We use a special recurrent neural network (LSTM) to classify which category
the user’s message belongs to and then we will give a random response from the list of
responses.
RNN (Recurrent Neural Network)
RNN is widely used neural network architecture for NLP. It has proven to be comparatively
accurate and efficient for building language models and in tasks of speech recognition. RNNs
are particularly useful if the prediction has to be at word-level, for instance, Named-entity
recognition (NER) or Part of Speech (POS) tagging. As it stores the information for current
feature as well neighboring features for prediction. It is the first algorithm that remembers its
21
input, due to an internal memory, which makes it perfectly suited for machine learning
problems that involve sequential data.
When the points in the dataset are dependent on the other points in the dataset, the data is
termed sequential.
Because of their internal memory, RNN’s can remember important things about the input they
received, which allows them to be very precise in predicting what’s coming next. This is why
they're the preferred algorithm for sequential data like time series, speech, text, financial data,
audio, video, weather and much more. Recurrent neural networks can form a much deeper
understanding of a sequence and its context compared to other algorithms.
Fig 4.2 Recurrent Neural Network Model
A Recurrent Neural Network is a deep learning model dedicated to the handling of sequences.
Here an internal state is responsible for taking into consideration and properly handle the
dependency that exists between successive inputs, Apart from the relative elegance of the
model, it's impossible not to get captured and fascinated by it, simply from the many online
demo and examples showcasing its generative capabilities. From handwriting to movie script
generation [11].
22
In this project we have used a special recurrent neural network (LSTM) to classify which
category the user’s message belongs to and then we will give a random response from the list
of responses.
Understanding LSTM
LSTM stands for Long-Short Term Memory. It is an artificial recurrent neural network used
in field of deep learning. LSTM has feedback connections. It can process not only single data
points (such as images), but also entire sequences of data. LSTM networks are well-suited
to classifying, processing and making predictions based on time series data, since there can be
lags of unknown duration between important events in a time series. LSTM networks are a
type of recurrent neural network capable of learning order dependence in sequence prediction
problems.
At a high-level LSTM works very much like an RNN cell. Here is the internal functioning of
the LSTM network. The LSTM consists of three parts, as shown in the image below and each
part performs an individual function [10].
Fig 4.2.1 LSTM Network
The first part chooses whether the information coming from the previous timestamp is to be
remembered or is irrelevant and can be forgotten. In the second part, the cell tries to learn
23
new information from the input to this cell. At last, in the third part, the cell passes the
updated information from the current timestamp to the next timestamp.
These three parts of an LSTM cell are known as gates. The first part is called Forget gate,
the second part is known as the Input gate and the last one is the Output gate [10].
Fig 4.2.2 LSTM Gates
24
Chapter 5: Implementation and Testing
5.1Implementation
5.1.1 Tools used
The Medical Chatbot is a simple python application where all the user interfaces was designed
using Visual Studio Code with Python extension. Some of the major application tools used to
develop the application are mentioned below.
Front End Tools
 Draw.io
Draw.io is a website that provides online diagramming tool. We used this tool to create
various diagram such as use case diagram, DFD and context diagram, system flow
diagram which helps in understanding overall flow of application.
 Python
Python is interpreted high-level, general purpose programming language. Python has a
design philosophy that emphasizes code readability, notably using significant
whitespace. It provided construct that enable clear programming on both small and
large scale. It was used to develop the machine leaning model in this project.
 Tkinter
Tkinter is the standard GUI library for Python. Python when combined with Tkinter
provides a fast and easy way to create GUI applications. Tkinter provides a powerful
object-oriented interface to the Tk GUI toolkit. For this application the user interface
of chatbot was designed using tkinter.Creating a GUI application using Tkinter is an
easy task. All you need to do is perform the following steps –
o Import the Tkinter module.
o Create the GUI application main window.
o Add one or more of the above-mentioned widgets to the GUI application.
o Enter the main event loop to take action against each event triggered by the user.
25
Back End Tools
 NLTK :
NLTK is leading platform for building Python programs to work with human language data.
It provides easy-to-use interfaces to over 50 corpora and lexical resources along with
WordNet, along with a suite of text processing libraries for classification, prediction,
tokenization, stemming, tagging, parsing and semantic reasoning.
 Numpy
NumPy is a library for the Python programming language, adding support for large, multi-
dimensional arrays and matrices, along with a large collection of high-level mathematical
functions to operate on these arrays. In Python we have lists that serve the purpose of arrays,
but they are slow to process. NumPy aims to provide an array object that is up to 50x faster
than traditional Python lists.The array object in NumPy is called ndarray, it provides a lot of
supporting functions that make working with ndarray very easy. Arrays are very frequently
used in data science, where speed and resources are very important.[10]
 Keras
Keras runs on top of open source machine libraries like TensorFlow, Theano or Cognitive
Toolkit (CNTK). By the help of keras neural networks are written in Python which makes
things simpler.
 Tensorflow
TensorFlow is the most famous symbolic math library used for creating neural networks and
deep learning models. TensorFlow is very flexible and the primary benefit is distributed
computing. TensorFlow is designed in Python programming language, hence it is considered
an easy to understand framework.
SQLite Database
For this project we have used DB browser for SQLite to save our database. SQLite is a
database engine, written in the C language. It is not a standalone app; rather, it is a library that
software developers embed in their apps. As such, it belongs to the family of embedded
databases. SQLite is a C-language library that implements a small, fast, self-contained, high-
26
reliability, full-featured, SQL database engine. SQLite is the most used database engine in the
world. SQLite is built into all mobile phones and most computers and comes bundled inside
countless other applications.
5.1.2 Implementation Details
Various development technologies and tools have been used for the application
development.Initially, we imported all the required libraries. Then we initialized the arrays
and data file for the chatbot training. Then we performed preprocessing of data where we did
tokenizing and lemmatizing of the data file. Tokenizing is the process of breaking the whole
text into small parts like words. Lemmatizing is the process of converting a word into its
lemma form and then creating a pickle file to store the Python objects which we will use while
predicting. By this process we created two pickle files which included the words and files used
for training.
#tokenize each word
w = nltk.word_tokenize(pattern)
words.extend(w)
documents.append((w, intent['tag'])
if intent['tag'] not in classes:
classes.append(intent['tag'])
# lemmaztize and lower each word and remove duplicates
words = [lemmatizer.lemmatize(w.lower()) for w in words if w not in ignore_words]
words = sorted(list(set(words)))
classes = sorted(list(set(classes)))
print (len(documents), "documents")
print (len(classes), "classes", classes)
print (len(words), "unique lemmatized words", words)
pickle.dump(words,open('words.pkl','wb'))
pickle.dump(classes,open('classes.pkl','wb'))
27
After data preprocessing we created training data that will provide input and output. Our input
will be the pattern and output will be the class our input pattern belongs to. But the computer
doesn’t understand text so we will convert text into numbers.
# create our training data
training = []
# create an empty array for our output
output_empty = [0] * len(classes)
# training set, bag of words for each sentence
for doc in documents:
# initialize our bag of words
bag = []
# list of tokenized words for the pattern
pattern_words = doc[0]
# lemmatize each word - create base word, in attempt to represent related words
pattern_words = [lemmatizer.lemmatize(word.lower()) for word in pattern_words]
# create our bag of words array with 1, if word match found in current pattern
for w in words:
bag.append(1) if w in pattern_words else bag.append(0)
# output is a '0' for each tag and '1' for current tag (for each pattern)
output_row = list(output_empty)
output_row[classes.index(doc[1])] = 1
print(output_row)
28
training.append([bag, output_row])
# shuffle our features and turn into np.array
random.shuffle(training)
training = np.array(training)
# create train and test lists. X - patterns, Y - intents
train_x = list(training[:,0])
train_y = list(training[:,1])
print("Training data created")
After created training data we built deep neural network that has 3 layers. We used the Keras
sequential API for this. After training the model for 200 epochs, we achieved 100% accuracy
on our model.
# Create model - 3 layers. First layer 128 neurons, second layer 64 neurons and 3rd output
layer contains number of neurons
# equal to number of intents to predict output intent with softmax
model = Sequential()
model.add(Dense(128, input_shape=(len(train_x[0]),), activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(len(train_y[0]), activation='softmax'))
# Compile model. Stochastic gradient descent with Nesterov accelerated gradient gives good
results for this model
29
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
#fitting and saving the model
hist = model.fit(np.array(train_x), np.array(train_y), epochs=200, batch_size=5, verbose=1)
model.save('chatbot_model.h5', hist)
print("model created")
5.2Testing
Testing is the final process in system development life cycle. Here the developed system is
tested to find out error and fix them. It is one of the most important procedure of system
development life cycle. In order to verify and validate the system we performed few tests.
5.2.1 Test Cases for Unit Testing
Unit testing is a software development process in which the smallest testable parts of
an application, called units, are individually and independently scrutinized for proper
operation. This testing methodology is done during the development process by the software
developers and sometimes QA staff. The main objective of unit testing is to isolate written
code to test and determine if it works as intended.
We performed following test cases for unit testing.
Table 5.2.1: Test case for disease prediction
Test
case
Steps Input Expected
output
Actual output Status
1. Enter contact and
password in login
panel
User enters
contact=1234
Password=aaa
Log in
successful pop-
up window and
open chatbot
Log in
successful pop-
up window and
open chatbot
Pass
2. Enter contact and
password in login
panel
User enters
Contact = 1234
Password =
Password can’t
be empty
Password can’t
be empty
Pass
2. User enters
greetings
Basic greeting
terms hi,hello
etc.
Chatbot replies
with similar
greetings
Chatbot replies
with similar
greetings
Pass
30
3. User enters
multiple symptoms
Enters headache
and cough
you might be
suffering from
headache
problems,
chickenpox
you might be
suffering from
headache
problems,
chickenpox
Pass
4. User enters random
words
Enters some
random text
Bot replies I
don’t
understand you.
Bot replies I
don’t
understand you.
Pass
5. User enters single
symptoms
Enters fever Bot replies I
don’t
understand you
Tell me more
symptoms
OR
You might be
suffering from
influenza
Fail
Result Analysis
The result of different inputs were done in the unit testing. The major analysis of the testing
was the prediction of disease that is done by chatbot. We tested the bot in the devices of our
project team members. We tested few data from the dataset and obtained expected result.
Few testing cases resulted failure but that can be recovered in future. On this project we
tested the chatbot with only few symptoms from the dataset.
31
Chapter 6: Conclusion and Recommendation
6.1 Conclusion
We developed this system of Medical Chatbot to demonstrate significance of AI in health
sector. By using the concept of recurrent neural network we formed a prediction system where
chatbot will match the pattern given by user text with dataset. Even for simple health related
problem people searches for that in Google. SoE, to reduce the hustle of searching we
developed this chatbot that will give immediate reply about the query. Moreover, the chatbot
was developed to be user-friendly with minimal UI and simple user procedure.
6.2 Future Recommendation
We plan to develop more function in future. We hope to create a chatbot that will work in
larger dataset. Furthermore, we wish to enhance the chatbot with voice recognition and image
reader which will make the user easier. Moreover, we are aiming this chatbot to be developed
as an android application which will be bilingual so that user interaction will be made more
easy and wide range of audience can experience the chatbot.
32
References
1. “Pharmabot: A Pediatric Generic Medicine Consultant Chatbot” proposed by
Benilda Eleonor V. Comendador, Bien Michael B. Francisco, Jefferson S.
Medenilla, Sharleen Mae T. Nacion, and Timothy Bryle E. Serac
2. “A Self-Diagnosis Medical Chatbot Using Artificial Intelligence” proposed by
Divya S1 , Indumathi V , Ishwarya S , Priyasankari M , Kalpana Devi S
3. Will Kenton, Feasibility Study, Investopedia (2020)
4. Building Chatbot on FPT.AI platform · Documentation
5. https://chatbotsmagazine.com/what-is-the-working-of-a-chatbot-e99e6996f51c
6. Algorithm Inspection for Chatbot Performance Evaluation by Vijayaraghavan V.,
Jack Brian Cooper, Rian Leevinson J.
7. Chatbots in Healthcare: How They're Changing an Industry — Etactics
8. https://elomia.com/
9. https://medicalfuturist.com/top-12-health-chatbots/
10. https://www.analyticsvidhya.com/blog/2021/03/introduction-to-long-short-term-
memory-lstm/
11. https://builtin.com/data-science/recurrent-neural-networks-and-lstm
12. https://data-flair.training/blogs/python-chatbot-project/
33
Appendix
Figure: User Login and Register Interface
Figure: Chatbot chat GUI
34
Figure: User Database

Contenu connexe

Tendances

project report of social networking web sites
project report of social networking web sitesproject report of social networking web sites
project report of social networking web sites
Gyanendra Pratap Singh
 
A project report on chat application
A project report on chat applicationA project report on chat application
A project report on chat application
Kumar Gaurav
 
Documentation of railway reservation system
Documentation of railway reservation systemDocumentation of railway reservation system
Documentation of railway reservation system
Sandip Murari
 

Tendances (20)

project report of social networking web sites
project report of social networking web sitesproject report of social networking web sites
project report of social networking web sites
 
Major File On web Development
Major File On web Development Major File On web Development
Major File On web Development
 
Synopsis of online Attendance System
Synopsis of online Attendance SystemSynopsis of online Attendance System
Synopsis of online Attendance System
 
Social Networking Website Project Report
Social Networking Website Project ReportSocial Networking Website Project Report
Social Networking Website Project Report
 
CHATBOT FOR COLLEGE RELATED QUERIES | J4RV4I1008
CHATBOT FOR COLLEGE RELATED QUERIES | J4RV4I1008CHATBOT FOR COLLEGE RELATED QUERIES | J4RV4I1008
CHATBOT FOR COLLEGE RELATED QUERIES | J4RV4I1008
 
IRJET- College Enquiry Chatbot System(DMCE)
IRJET-  	  College Enquiry Chatbot System(DMCE)IRJET-  	  College Enquiry Chatbot System(DMCE)
IRJET- College Enquiry Chatbot System(DMCE)
 
A project report on chat application
A project report on chat applicationA project report on chat application
A project report on chat application
 
SRS FOR CHAT APPLICATION
SRS FOR CHAT APPLICATIONSRS FOR CHAT APPLICATION
SRS FOR CHAT APPLICATION
 
Chatbot Abstract
Chatbot AbstractChatbot Abstract
Chatbot Abstract
 
SAD Final Assignment
SAD Final AssignmentSAD Final Assignment
SAD Final Assignment
 
Documentation of railway reservation system
Documentation of railway reservation systemDocumentation of railway reservation system
Documentation of railway reservation system
 
AMIZONER: Final Report
AMIZONER: Final ReportAMIZONER: Final Report
AMIZONER: Final Report
 
Ppt full stack developer
Ppt full stack developerPpt full stack developer
Ppt full stack developer
 
social networking site
social networking sitesocial networking site
social networking site
 
Online Quiz System Project Report
Online Quiz System Project Report Online Quiz System Project Report
Online Quiz System Project Report
 
Final presentation on chatbot
Final presentation on chatbotFinal presentation on chatbot
Final presentation on chatbot
 
University management system
University management systemUniversity management system
University management system
 
Difference between frontend and backend
Difference between frontend and backendDifference between frontend and backend
Difference between frontend and backend
 
Online notice board
Online notice boardOnline notice board
Online notice board
 
Srs2 Job Portal
Srs2 Job PortalSrs2 Job Portal
Srs2 Job Portal
 

Similaire à Final_project_report.pdf

Medical Assistant Design during this Pandemic Like Covid-19
Medical Assistant Design during this Pandemic Like Covid-19Medical Assistant Design during this Pandemic Like Covid-19
Medical Assistant Design during this Pandemic Like Covid-19
AI Publications
 

Similaire à Final_project_report.pdf (20)

health care chatbot using data science with python
health care chatbot using data science with pythonhealth care chatbot using data science with python
health care chatbot using data science with python
 
IRJET - Artificial Intelligence based Healthcare Chatbot System
IRJET -  	  Artificial Intelligence based Healthcare Chatbot SystemIRJET -  	  Artificial Intelligence based Healthcare Chatbot System
IRJET - Artificial Intelligence based Healthcare Chatbot System
 
IRJET- A Survey Paper on Chatbots
IRJET- A Survey Paper on ChatbotsIRJET- A Survey Paper on Chatbots
IRJET- A Survey Paper on Chatbots
 
A Survey Paper On Chatbots
A Survey Paper On ChatbotsA Survey Paper On Chatbots
A Survey Paper On Chatbots
 
IRJET - Chatbot for Monitoring Mental Health
IRJET - Chatbot for Monitoring Mental HealthIRJET - Chatbot for Monitoring Mental Health
IRJET - Chatbot for Monitoring Mental Health
 
chatbots presentation .pptx
chatbots presentation .pptxchatbots presentation .pptx
chatbots presentation .pptx
 
HealthCare ChatBot Using Machine Learning
HealthCare ChatBot Using Machine LearningHealthCare ChatBot Using Machine Learning
HealthCare ChatBot Using Machine Learning
 
Ameliorating Depression through Deep Learning Conversational Agent: A Novel A...
Ameliorating Depression through Deep Learning Conversational Agent: A Novel A...Ameliorating Depression through Deep Learning Conversational Agent: A Novel A...
Ameliorating Depression through Deep Learning Conversational Agent: A Novel A...
 
A Survey on Various Types of Chatbots
A Survey on Various Types of ChatbotsA Survey on Various Types of Chatbots
A Survey on Various Types of Chatbots
 
An Intelligent Career Counselling Bot A System for Counselling
An Intelligent Career Counselling Bot A System for CounsellingAn Intelligent Career Counselling Bot A System for Counselling
An Intelligent Career Counselling Bot A System for Counselling
 
Building Virtual Assistants A Guide to Chatbot Development.pdf
Building Virtual Assistants  A Guide to Chatbot Development.pdfBuilding Virtual Assistants  A Guide to Chatbot Development.pdf
Building Virtual Assistants A Guide to Chatbot Development.pdf
 
Building Virtual Assistants A Guide to Chatbot Development.pdf
Building Virtual Assistants  A Guide to Chatbot Development.pdfBuilding Virtual Assistants  A Guide to Chatbot Development.pdf
Building Virtual Assistants A Guide to Chatbot Development.pdf
 
Building Virtual Assistants A Guide to Chatbot Development (2).pdf
Building Virtual Assistants  A Guide to Chatbot Development (2).pdfBuilding Virtual Assistants  A Guide to Chatbot Development (2).pdf
Building Virtual Assistants A Guide to Chatbot Development (2).pdf
 
IRJET - Chat-Bot Utilization for Health Consultancy
IRJET - 	  Chat-Bot Utilization for Health ConsultancyIRJET - 	  Chat-Bot Utilization for Health Consultancy
IRJET - Chat-Bot Utilization for Health Consultancy
 
IRJET- Quinn: Medical Assistant for Mental Counseling using Rasa Stack
IRJET-  	  Quinn: Medical Assistant for Mental Counseling using Rasa StackIRJET-  	  Quinn: Medical Assistant for Mental Counseling using Rasa Stack
IRJET- Quinn: Medical Assistant for Mental Counseling using Rasa Stack
 
All You Need To Know About Chatbot Development.pdf
All You Need To Know About Chatbot Development.pdfAll You Need To Know About Chatbot Development.pdf
All You Need To Know About Chatbot Development.pdf
 
Medical Assistant Design during this Pandemic Like Covid-19
Medical Assistant Design during this Pandemic Like Covid-19Medical Assistant Design during this Pandemic Like Covid-19
Medical Assistant Design during this Pandemic Like Covid-19
 
Banking botreport
Banking botreportBanking botreport
Banking botreport
 
Design of Chatbot using Deep Learning
Design of Chatbot using Deep LearningDesign of Chatbot using Deep Learning
Design of Chatbot using Deep Learning
 
IRJET- Artificial Intelligence Based Chat-Bot
IRJET-  	  Artificial Intelligence Based Chat-BotIRJET-  	  Artificial Intelligence Based Chat-Bot
IRJET- Artificial Intelligence Based Chat-Bot
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Final_project_report.pdf

  • 1. 1 Kathmandu BernHardt College Bafal,Kathmandu A Project Report On “Medical Chat Bot Using Recurrent Neural Network” Submitted To: Department of Computer Science and Information Technology (Kathmandu Bernhardt College) Submitted By: Karina Shakya
  • 2. 2 ACKNOWLEDGEMENT Our forthright gratefulness goes to Kathmandu Bernhardt College for wholehearted support and for giving us this opportunity to undertake this case study. We would like to extend our sincere gratitude to our supervisor Abhimanyu Yadav, coordinator of Department of Computer Science, Kathmandu Bernhardt College, for his kind and co-operative support, valuable time and guidance as well as suggestions. We would like to express our gratitude to lecturers form Department of CSIT at Kathmandu Bernhardt College for providing suggestions for this whole work and cooperative behavior. At the end we would like to express our sincere thanks to all our friends and others who helped us directly or indirectly during the preparation of this report. Karina Shakya Lakas Maharjan Navin Timalsina
  • 3. 3 Abstract Medical care is very important for a healthy life. However, it is very difficult to seek medical attention if you have a health problem. The recommended notion is to develop a medical chatbot that can adopt AI to analyze the ailment and produce necessary information concerning the condition were discussing with a doctor. Chatbot is used extensively to check the state of health at any time. It is the same as going to a doctor and having the medication prescribed. This paper discusses about medical chatbot using the neural network algorithm which predicts the disease. There are many neural network algorithms that can be used to predict the disease. Recurrent Neural Network technique is primarily used to achieve precise prediction and boost the efficiency of the model. The system uses Natural Language Processing to achieve the style of chatting. The proposed system is not only to meet such requirements but also to maximize the remotely done processes using Artificial Intelligence chatbot. A chatbot provides a conversational interface to minimize the language gap between human and machine and provides health diagnosis on the basis of symptoms and giving proper health related tips. Keywords: Medical chatbot, Machine Learning Algorithm, Recurrent Neural Network, Long Short Term Memory, Natural Language Processing.
  • 4. 4 LIST OF ABBREVATIONS NLP Natural Language Processing RNN Recurrent Neural Network LSTM Long Short Term Memory AI Artificial Intelligence ML Machine Learning DFD Data Flow Diagram UML Unified Modeling Language DFD Data Flow Diagram NLTK Natural Language Toolkit
  • 5. 5 LIST OF FIGURES Fig 1.1 Report Organization Fig 1.2 Use case diagram Fig 1.3 Gantt chart Fig 1.4. Context level Fig 1.5. Level 1 DFD Fig 1.6 LSTM Network Fig 1.7 LSTM Gates
  • 6. 6 Chapter 1: Introduction 1.1 Introduction Artificial Intelligence has taken over in lots of aspects in field of technology. Use of robots in industries and automated features in gadgets that simulates human intelligence have influenced very sectors. Similar to these, chatbots are also one of the part of innovation of AI. Nowadays chatbots or simply bots are widely used in different kinds of business for various purpose. Chatbot are the software application designed to interact with user via human-like text in natural language. It is an application that is intended to provide natural and accurate reply to the query asked by the user. The vast amount of information that is available on the internet allows Chatbots to provide accurate and efficient information based on the user’s requirements. Chatbots are used in domains like Customer Support, Virtual Assistance, Online Trainings, and Online Reservations and also for general conversations. Most of the time different organization and business uses chatbot to handle minor task and provide customer service. Use of chatbots helps in saving up time of support staff and reduces cost to hire staff for minor roles. Beside this chatbot can also help in attracting customer attraction since it can initiate regular conversation with consumer just like human. Initially, when a user posts the queries to the chatbot the bot tries to find the related reply that are more match able with query in its database. The database of the chatbot is preloaded with the possible queries and their corresponding replies. Based on these replies and queries in database chatbot will try to have a conversation with the user. Chatbots are actually intended to provide natural and accurate reply to the query asked by the user. Chatbots are developed by implementation of different natural language processing or NLP algorithm. . Basically, NLP is concerned with how technology can interpret and respond to the human language inputs. In case of chatbots, NLP allows the bots to understand the user message and respond it appropriately. For past years, developers have incorporated more innovative techniques to enable chatbots to better understand people’s questions and provide
  • 7. 7 more useful responses. While today’s bots still can’t handle all customer queries, they can respond to frequently asked questions or perform straightforward tasks. The proposed “Medical chatbot” is an online chatbot that works in similar way as regular chatbot but only provides health assistance to user. It is like an online medical consultant that response to the symptoms asked by the user. The proposed system acts as an agent that replies the user about their health issues or any other medical related issues. Based on the patterns provided by the user, the chatbot will try to look for the accurate response since the relevant amount of replies, queries and inputs are already present dataset. The major focus of this chatbot is to optimize the communication behavior in smarter manner. Beside this it is also proposed to provide immediate response for medical-aid so that user does not have to go through different pages or sites to obtain accurate information. 1.2 Problem Statement This project is focused to create a chatbot that will interact with the user and give them realistic experience of chatting with medical professional. There are some medical chatbots already exist that does not provide any direct response or medication needed for user query or illness but redirects the user to some medical forum that shows the similar questions which are previously answered. However, our system will provide the required response for the query by matching the user message keyword with the keywords in database and will not exceed its limitation. 1.3 Objective  To build medical chatbot application using deep learning.  To predict the probable disease by analyzing symptoms provided by user. 1.4 Scope and Limitations 1.4.1 Scope The major scope of a medical chatbot can be assisting user for different health related subject matter. Nowadays, use of digital device have increased a lot so a chatbot can be a simple tool which will help user to predict possible disease in more efficient way.
  • 8. 8 The other scope for Medical chatbot are:  This work can be further extended to providing information of different medicines, treatment information.  The chatbot can also be embedded with speech recognition feature where user can verbally share their problem.  The chatbot can also be extended with navigation function to locate nearby medical centers.  Moreover, the chatbot application can be further modified by adding user profile where they can get connected with other user. 1.4.2 Limitation Along with scopes and benefits this project also have some shortcomings and limitations which are highlighted in following points:  This program is applicable only for certain diseases.  It will only predict the possible disease but will not prescribe any drugs or medicines.  Based on the symptoms the chatbot will response to the queries but will not ask any query.  The chatbot will provide accurate disease only if multiple symptoms is provided. 1.5 Development Methodology Artificial intelligence is the driving force behind the development of breakthrough technologies such as self-driving cars and chatbots. Because of modern improvements in Natural Language Processing (NLP), chatbots, also known as virtual assistants, are now a viable alternative for improving the customer experience. In this project we have built a chatbot that will predict the possible disease based on the symptoms provided by user. The chatbot development methodology blends several modern frameworks and methodologies including design thinking, AI innovation sprints, agile and waterfall software development.
  • 9. 9 In this project we will be following Waterfall Software Development Methodology. Waterfall methodology is also referred to as a linear-sequential life cycle model. It is very simple to understand and use. In a waterfall model, each phase must be completed before the next phase can begin and there is no overlapping in the phases. The Waterfall model is the earliest SDLC approach that was used for software development. The waterfall Model illustrates the software development process in a linear sequential flow. This means that any phase in the development process begins only if the previous phase is complete. In this waterfall model, the phases do not overlap. The sequential phases in Waterfall model are − • Requirement Gathering and analysis − All possible requirements of the system to be developed are captured in this phase and documented in a requirement specification document. • System Design − the requirement specifications from first phase are studied in this phase and the system design is prepared. This system design helps in specifying hardware and system requirements and helps in defining the overall system architecture. • Implementation − with inputs from the system design, the system is first developed in small programs called units, which are integrated in the next phase. Each unit is developed and tested for its functionality, which is referred to as Unit Testing. • Integration and Testing − All the units developed in the implementation phase are integrated into a system after testing of each unit. Post integration the entire system is tested for any faults and failures. • Deployment of system − Once the functional and non-functional testing is done; the product is deployed in the customer environment or released into the market. • Maintenance − There are some issues which come up in the client environment. To fix those issues, patches are released. Also to enhance the product some better versions are released. Maintenance is done to deliver these changes in the customer environment.
  • 10. 10 The following illustration shows waterfall methodology: Fig 1.5 Waterfall Model 1.6 Report Organization Altogether the project is divided into four different chapters, each representing different development phase of project. The chapter can be discussed briefly as follows: Chapter 1: It deals with introductory part of the project and explains about what the project is, how it came in idea, the main objective of the project that are planned to be achieved after the completion, its scope and limitations. Chapter 2: This chapter is all about research process carried out to do the project. It consist the background idea for the project as well as the study process that are required for this application to be popular among users. Chapter 3: This chapter deals with the analysis phase. It consist of all the requirement and feasibility analysis needed for the system. Chapter 4: This chapter is all about the design phase. System design consist of database design, interface design and process design that are carried out to build this application.
  • 11. 11 Fig 1.6: Diagram representing report organization Chapter 1 Introduction Chapter 2 Background Study and research Chapter 3 System Analysis Chapter 4 System Design
  • 12. 12 Chapter 2: Background Study and Literature Review 2.1 Background Study There are two basic types of chatbot models based on how they are built; Retrieval based and Generative based models [12]. I. Retrieval Based: A retrieval-based chatbot uses predefined input patterns and responses. It then uses some type of heuristic approach to select the appropriate response. It is widely used in the industry to make goal-oriented chatbots where we can customize the tone and flow of the chatbot to drive our customers with the best experience. II. Generative Based: Generative models are not based on some predefined responses. They are based on sequence to sequence neural networks. It is the same idea as machine translation. In machine translation, we translate the source code from one language to another language but here, we are going to transform input into an output. It needs a large amount of data and it is based on Deep Neural networks. In this project we will be using retrieval based model to build chatbot. We are building chatbot using deep learning approach. The chatbot will be trained on the dataset which contains categories (intents), pattern and responses. We use a special recurrent neural network (LSTM) to classify which category the user’s message belongs to and then we will give a random response from the list of responses. Stemming and Lemmatization: Stemming and Lemmatization are Text Normalization (or sometimes called Word Normalization) techniques in the field of Natural Language Processing that are used to prepare text, words, and documents for further processing. 2.2 Literature Review There are many medical chatbot that has been designed in past few years which aims at providing medical guidance and recommends medicine based on the symptoms provided by the user.
  • 13. 13 A similar paper “Pharmabot: A Pediatric Generic Medicine Consultant Chatbot” proposed by Benilda Eleonor V. Comendador, Bien Michael B. Francisco, Jefferson S. Medenilla, Sharleen Mae T. Nacion, and Timothy Bryle E. Serac provides a design for a stand-alone medical Chatbot that is implemented using MS Access and Visual C# . For using the proposed design, the user has to navigate using the four options provided by the application. This design aims to work by converting the user input to SQL queries and execute it on MS Access to retrieve the solution to the illness [1]. Another paper “A Self-Diagnosis Medical Chatbot Using Artificial Intelligence” proposed by Divya S1 , Indumathi V , Ishwarya S , Priyasankari M , Kalpana Devi S provides a medical chatbot system built in python. This system has the user dialogue is a linear design that proceeds from symptom extraction, to symptom mapping, where it identifies the corresponding symptom, then diagnosis the patient whether it’s a major or minor disease and if it’s a major one an appropriate doctor will be referred to the patient, the doctor details will be extracted from the database, the user will be identified by the login details which is stored in the database [2]. Elomia is another AI powered chatbot which acts as a virtual therapist. This chatbot was trained to create by the observation of past therapies conducted by doctors. Elomia assist for the treatment related to mental health like anxiety, depression, loneliness, sleep issues etc. Youper’s AI monitors and improves the emotional health of the user through quick personalized conversation using psychological techniques. This chatbot app features personalized meditation and ability to track mood and monitor emotional health [8].
  • 14. 14 Chapter 3: System Analysis 3.1 System Analysis 3.1.1 Requirement Analysis 1. Functional Requirement The functional requirement of this system will include following module: 1.1 Registration Function In this project we have created registration function where user will have to register before entering chatbot. The user data is stored in database and through this database user is validated. 1.2 Login Function As mentioned above user must register for entering chatbot. Only the register user can have access to chatbot. User should enter contact number and password to log in. The password and contact number should matched with the data in database. 1.3 Admin Function Admin will be in charge of maintaining database of the chatbot. The response and possible queries will be updated and managed by the admin. 1.4 Chat Function In this medical chatbot user can have direct conversation with the bot via chat. Just like any other messaging application this application allows user to communicate via text. Use case diagram Use-case diagram is used to capture the dynamic aspects of a system. They can be used to gather requirements of a system including internal and external influences. The stick man represents an actor i.e. user or admin.
  • 15. 15 Fig 3.1 : Use case diagram for demonstrating admin and user role 2. Non-Functional Requirement a. User Friendly: The term user-friendly is self-explanatory. Users can easily use the web application. The application uses a simplified design and navigation, as well as simple language on the content to improve the user-friendliness. b. Easy Access: It can be accessed from anywhere with an Internet Connection at the time of election. c. Information Accuracy: The web application makes sure to avoid making mistakes during data and informational retrieval. Thus, the system provides the accuracy of information.
  • 16. 16 d. Speed of Application: The speed of application depends on basically two factors: System configuration and Internet Speed. System with good configuration will most definitely lag performance if the Internet bandwidth is below par and vice versa. 3.1.2 Feasibility study A feasibility study is an analysis that takes all of a project's relevant factors into account— including economic, technical, legal, and scheduling considerations—to ascertain the likelihood of completing the project successfully. Project managers use feasibility studies to discern the pros and cons of undertaking a project before they invest a lot of time and money into it [3]. The various feasibility studies are: i. Technical The application is technically feasible; compiles with current technology, including both the hardware and the software. The application is supported by almost all latest devices, and most of all, it can be run on modern-day systems. ii. Operation The application solves the problem faced by the target group that was underlined as the problem statement which makes it operationally feasible. iii. Economic The web application is available and accessible via the Internet which makes it economically feasible. User only requires internet connection to access the chatbot. Moreover, there are no charges of any sorts associated with contents in the web application. 3.1.3 Analysis The medical chatbot project is developed with different function and modules. Data Modelling with ER diagram An Entity Relationship Diagram (ERD) shows the relationships of entity sets stored in a database. An entity in this context is a component of data.
  • 17. 17  ER Diagram: In the ER diagram we present entities along with attributes. For this project we have three different entities: User, Chatbot and SQLite Database. Each of these entities have their respective attributes. Following are the attributes of the three entities of this chatbot. o User : Name, Contact, Password o Chatbot: Responses, tags o DBSQLite: user table The ER model for this project is shown below Fig 3.2 : ER Diagram For Medical Chatbot Process Modelling using DFD Process modeling involves graphically representing the processes, or actions, that capture, manipulate, store, and distribute data between a system and its environment and among components within a system. We have represented the entire process of system using Data Flow Diagram (DFD).
  • 18. 18 A Data Flow Diagram shows what kind of information will be input to and output from the system, where the data will come from and go to, and where the data will be stored. A data flow diagram takes business processes and activities and uses them to create a clear illustration of how data flows through a system. DFDs represent the flow of data from external entities into a single system by moving and storing data from one process to another. Through the use of data flow diagrams, a system can be decomposed into subsystems, and subsystems can be further decomposed into lower-level subsystems. I. Context level diagram User using this application must input the symptoms. Then the bot uses pattern matching to classify the text and provide possible response to user. Fig 3.3: Context level diagram for Medical Chatbot II. Level 1 DFD The detailed level 1 DFD can be further used to describe the process of application. Fig 3.4Level 1 DFD
  • 19. 19 Chapter 4: System Design 4.1 Design System design is the process of defining the architecture, modules, interface and data for a system to satisfy specified requirements. It is important phase of system development lifecycle. During this phase for interpretation of finding and analysis the following design and diagrams have been developed and thoroughly reviewed. Below is the system flow diagram of our proposed system. Fig 4.1 : System flow diagram of Medical Chatbot
  • 20. 20 4.2 Algorithm Details Natural Language Processing (NLP) The system follows the concept of NLP (Natural Language Processing. Basically, NLP is concerned with how technology can interpret and respond to the human language inputs. In case of chatbots, NLP allows the bots to understand the user message and respond it appropriately. Some of the Natural Language Processing steps are: Sentiment Analysis: Tries to learn if the user is having a good experience or if the after some point the chat should be forwarded to the human. Tokenization: The NLP divides a string of words into pieces or tokens that are linguistically symbolic or are differently useful for the application. Named Entity Recognition: The chatbot program model looks for categories of words, like the name of the product, the user’s name or address, whichever data is required [5]. Normalization: The Chatbot program model processes the text in an effort to find common spelling mistakes or typographical errors that might the user intent to convey. This gives more human like effect of the Chatbot to the users. In this project chatbot will be trained on the dataset which contains categories (intents), pattern and responses. We use a special recurrent neural network (LSTM) to classify which category the user’s message belongs to and then we will give a random response from the list of responses. RNN (Recurrent Neural Network) RNN is widely used neural network architecture for NLP. It has proven to be comparatively accurate and efficient for building language models and in tasks of speech recognition. RNNs are particularly useful if the prediction has to be at word-level, for instance, Named-entity recognition (NER) or Part of Speech (POS) tagging. As it stores the information for current feature as well neighboring features for prediction. It is the first algorithm that remembers its
  • 21. 21 input, due to an internal memory, which makes it perfectly suited for machine learning problems that involve sequential data. When the points in the dataset are dependent on the other points in the dataset, the data is termed sequential. Because of their internal memory, RNN’s can remember important things about the input they received, which allows them to be very precise in predicting what’s coming next. This is why they're the preferred algorithm for sequential data like time series, speech, text, financial data, audio, video, weather and much more. Recurrent neural networks can form a much deeper understanding of a sequence and its context compared to other algorithms. Fig 4.2 Recurrent Neural Network Model A Recurrent Neural Network is a deep learning model dedicated to the handling of sequences. Here an internal state is responsible for taking into consideration and properly handle the dependency that exists between successive inputs, Apart from the relative elegance of the model, it's impossible not to get captured and fascinated by it, simply from the many online demo and examples showcasing its generative capabilities. From handwriting to movie script generation [11].
  • 22. 22 In this project we have used a special recurrent neural network (LSTM) to classify which category the user’s message belongs to and then we will give a random response from the list of responses. Understanding LSTM LSTM stands for Long-Short Term Memory. It is an artificial recurrent neural network used in field of deep learning. LSTM has feedback connections. It can process not only single data points (such as images), but also entire sequences of data. LSTM networks are well-suited to classifying, processing and making predictions based on time series data, since there can be lags of unknown duration between important events in a time series. LSTM networks are a type of recurrent neural network capable of learning order dependence in sequence prediction problems. At a high-level LSTM works very much like an RNN cell. Here is the internal functioning of the LSTM network. The LSTM consists of three parts, as shown in the image below and each part performs an individual function [10]. Fig 4.2.1 LSTM Network The first part chooses whether the information coming from the previous timestamp is to be remembered or is irrelevant and can be forgotten. In the second part, the cell tries to learn
  • 23. 23 new information from the input to this cell. At last, in the third part, the cell passes the updated information from the current timestamp to the next timestamp. These three parts of an LSTM cell are known as gates. The first part is called Forget gate, the second part is known as the Input gate and the last one is the Output gate [10]. Fig 4.2.2 LSTM Gates
  • 24. 24 Chapter 5: Implementation and Testing 5.1Implementation 5.1.1 Tools used The Medical Chatbot is a simple python application where all the user interfaces was designed using Visual Studio Code with Python extension. Some of the major application tools used to develop the application are mentioned below. Front End Tools  Draw.io Draw.io is a website that provides online diagramming tool. We used this tool to create various diagram such as use case diagram, DFD and context diagram, system flow diagram which helps in understanding overall flow of application.  Python Python is interpreted high-level, general purpose programming language. Python has a design philosophy that emphasizes code readability, notably using significant whitespace. It provided construct that enable clear programming on both small and large scale. It was used to develop the machine leaning model in this project.  Tkinter Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit. For this application the user interface of chatbot was designed using tkinter.Creating a GUI application using Tkinter is an easy task. All you need to do is perform the following steps – o Import the Tkinter module. o Create the GUI application main window. o Add one or more of the above-mentioned widgets to the GUI application. o Enter the main event loop to take action against each event triggered by the user.
  • 25. 25 Back End Tools  NLTK : NLTK is leading platform for building Python programs to work with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical resources along with WordNet, along with a suite of text processing libraries for classification, prediction, tokenization, stemming, tagging, parsing and semantic reasoning.  Numpy NumPy is a library for the Python programming language, adding support for large, multi- dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. In Python we have lists that serve the purpose of arrays, but they are slow to process. NumPy aims to provide an array object that is up to 50x faster than traditional Python lists.The array object in NumPy is called ndarray, it provides a lot of supporting functions that make working with ndarray very easy. Arrays are very frequently used in data science, where speed and resources are very important.[10]  Keras Keras runs on top of open source machine libraries like TensorFlow, Theano or Cognitive Toolkit (CNTK). By the help of keras neural networks are written in Python which makes things simpler.  Tensorflow TensorFlow is the most famous symbolic math library used for creating neural networks and deep learning models. TensorFlow is very flexible and the primary benefit is distributed computing. TensorFlow is designed in Python programming language, hence it is considered an easy to understand framework. SQLite Database For this project we have used DB browser for SQLite to save our database. SQLite is a database engine, written in the C language. It is not a standalone app; rather, it is a library that software developers embed in their apps. As such, it belongs to the family of embedded databases. SQLite is a C-language library that implements a small, fast, self-contained, high-
  • 26. 26 reliability, full-featured, SQL database engine. SQLite is the most used database engine in the world. SQLite is built into all mobile phones and most computers and comes bundled inside countless other applications. 5.1.2 Implementation Details Various development technologies and tools have been used for the application development.Initially, we imported all the required libraries. Then we initialized the arrays and data file for the chatbot training. Then we performed preprocessing of data where we did tokenizing and lemmatizing of the data file. Tokenizing is the process of breaking the whole text into small parts like words. Lemmatizing is the process of converting a word into its lemma form and then creating a pickle file to store the Python objects which we will use while predicting. By this process we created two pickle files which included the words and files used for training. #tokenize each word w = nltk.word_tokenize(pattern) words.extend(w) documents.append((w, intent['tag']) if intent['tag'] not in classes: classes.append(intent['tag']) # lemmaztize and lower each word and remove duplicates words = [lemmatizer.lemmatize(w.lower()) for w in words if w not in ignore_words] words = sorted(list(set(words))) classes = sorted(list(set(classes))) print (len(documents), "documents") print (len(classes), "classes", classes) print (len(words), "unique lemmatized words", words) pickle.dump(words,open('words.pkl','wb')) pickle.dump(classes,open('classes.pkl','wb'))
  • 27. 27 After data preprocessing we created training data that will provide input and output. Our input will be the pattern and output will be the class our input pattern belongs to. But the computer doesn’t understand text so we will convert text into numbers. # create our training data training = [] # create an empty array for our output output_empty = [0] * len(classes) # training set, bag of words for each sentence for doc in documents: # initialize our bag of words bag = [] # list of tokenized words for the pattern pattern_words = doc[0] # lemmatize each word - create base word, in attempt to represent related words pattern_words = [lemmatizer.lemmatize(word.lower()) for word in pattern_words] # create our bag of words array with 1, if word match found in current pattern for w in words: bag.append(1) if w in pattern_words else bag.append(0) # output is a '0' for each tag and '1' for current tag (for each pattern) output_row = list(output_empty) output_row[classes.index(doc[1])] = 1 print(output_row)
  • 28. 28 training.append([bag, output_row]) # shuffle our features and turn into np.array random.shuffle(training) training = np.array(training) # create train and test lists. X - patterns, Y - intents train_x = list(training[:,0]) train_y = list(training[:,1]) print("Training data created") After created training data we built deep neural network that has 3 layers. We used the Keras sequential API for this. After training the model for 200 epochs, we achieved 100% accuracy on our model. # Create model - 3 layers. First layer 128 neurons, second layer 64 neurons and 3rd output layer contains number of neurons # equal to number of intents to predict output intent with softmax model = Sequential() model.add(Dense(128, input_shape=(len(train_x[0]),), activation='relu')) model.add(Dropout(0.5)) model.add(Dense(64, activation='relu')) model.add(Dropout(0.5)) model.add(Dense(len(train_y[0]), activation='softmax')) # Compile model. Stochastic gradient descent with Nesterov accelerated gradient gives good results for this model
  • 29. 29 sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy']) #fitting and saving the model hist = model.fit(np.array(train_x), np.array(train_y), epochs=200, batch_size=5, verbose=1) model.save('chatbot_model.h5', hist) print("model created") 5.2Testing Testing is the final process in system development life cycle. Here the developed system is tested to find out error and fix them. It is one of the most important procedure of system development life cycle. In order to verify and validate the system we performed few tests. 5.2.1 Test Cases for Unit Testing Unit testing is a software development process in which the smallest testable parts of an application, called units, are individually and independently scrutinized for proper operation. This testing methodology is done during the development process by the software developers and sometimes QA staff. The main objective of unit testing is to isolate written code to test and determine if it works as intended. We performed following test cases for unit testing. Table 5.2.1: Test case for disease prediction Test case Steps Input Expected output Actual output Status 1. Enter contact and password in login panel User enters contact=1234 Password=aaa Log in successful pop- up window and open chatbot Log in successful pop- up window and open chatbot Pass 2. Enter contact and password in login panel User enters Contact = 1234 Password = Password can’t be empty Password can’t be empty Pass 2. User enters greetings Basic greeting terms hi,hello etc. Chatbot replies with similar greetings Chatbot replies with similar greetings Pass
  • 30. 30 3. User enters multiple symptoms Enters headache and cough you might be suffering from headache problems, chickenpox you might be suffering from headache problems, chickenpox Pass 4. User enters random words Enters some random text Bot replies I don’t understand you. Bot replies I don’t understand you. Pass 5. User enters single symptoms Enters fever Bot replies I don’t understand you Tell me more symptoms OR You might be suffering from influenza Fail Result Analysis The result of different inputs were done in the unit testing. The major analysis of the testing was the prediction of disease that is done by chatbot. We tested the bot in the devices of our project team members. We tested few data from the dataset and obtained expected result. Few testing cases resulted failure but that can be recovered in future. On this project we tested the chatbot with only few symptoms from the dataset.
  • 31. 31 Chapter 6: Conclusion and Recommendation 6.1 Conclusion We developed this system of Medical Chatbot to demonstrate significance of AI in health sector. By using the concept of recurrent neural network we formed a prediction system where chatbot will match the pattern given by user text with dataset. Even for simple health related problem people searches for that in Google. SoE, to reduce the hustle of searching we developed this chatbot that will give immediate reply about the query. Moreover, the chatbot was developed to be user-friendly with minimal UI and simple user procedure. 6.2 Future Recommendation We plan to develop more function in future. We hope to create a chatbot that will work in larger dataset. Furthermore, we wish to enhance the chatbot with voice recognition and image reader which will make the user easier. Moreover, we are aiming this chatbot to be developed as an android application which will be bilingual so that user interaction will be made more easy and wide range of audience can experience the chatbot.
  • 32. 32 References 1. “Pharmabot: A Pediatric Generic Medicine Consultant Chatbot” proposed by Benilda Eleonor V. Comendador, Bien Michael B. Francisco, Jefferson S. Medenilla, Sharleen Mae T. Nacion, and Timothy Bryle E. Serac 2. “A Self-Diagnosis Medical Chatbot Using Artificial Intelligence” proposed by Divya S1 , Indumathi V , Ishwarya S , Priyasankari M , Kalpana Devi S 3. Will Kenton, Feasibility Study, Investopedia (2020) 4. Building Chatbot on FPT.AI platform · Documentation 5. https://chatbotsmagazine.com/what-is-the-working-of-a-chatbot-e99e6996f51c 6. Algorithm Inspection for Chatbot Performance Evaluation by Vijayaraghavan V., Jack Brian Cooper, Rian Leevinson J. 7. Chatbots in Healthcare: How They're Changing an Industry — Etactics 8. https://elomia.com/ 9. https://medicalfuturist.com/top-12-health-chatbots/ 10. https://www.analyticsvidhya.com/blog/2021/03/introduction-to-long-short-term- memory-lstm/ 11. https://builtin.com/data-science/recurrent-neural-networks-and-lstm 12. https://data-flair.training/blogs/python-chatbot-project/
  • 33. 33 Appendix Figure: User Login and Register Interface Figure: Chatbot chat GUI