Up-2 Project Report
Up-2 Project Report
Up-2 Project Report
Submitted by
BACHELOR OF TECHNOLOGY
IN
At
JUNE 2022
DEPARTMENT OF COMPUTER SCIENCE AND
ENGINEERING
SCHOOL OF ENGINEERING
PRESIDENCY UNIVERSITY
CERTIFICATE
This is to certified that the Project report “Health-care Chatbot using Natural
PRESIDENCY UNIVERSITY
DECLARATION
I hereby declare that the work, which is being presented in the internship report
Bangalore.
We have not submitted the matter presented in this report anywhere for the
With increasing population of India, increasing birth rate and decreasing death
rate due to advancement in the medical field it’s found that numbers of doctors
are less to serve the need of the increasing population. This scenario can be better
understood while walking through the city’s government hospitals where the less
availability of the doctors is the major cause behind the improper treatment of
the patients and in certain scenario the resultant death. Sometime even doctors
can make mistake in providing the correct treatment result in death of patient.
To encounter such cases there is a need of the smart and Intelligent chatbot who
can provide advice to the doctors and sometime even patients about what to do
in such cases which ultimately results in the saving the life of hundreds of people
Virtual assistants can help patients and providers with a host of medical-related
tasks. Chatbots are computer programs designed to carry on a dialogue with
people, assisting them via text messages, applications, or instant messaging. The
Bot can recognize the symptoms and provide diagnosis based on that particular
symptom. It can also suggest the doctor based on the diagnosis leading for a
faster response. Chatbots are already widely used to support, expedite, and
improve processes in other industries, such as retail, and now we can use it in
health service care also.
Keywords: Intelligent chatbot, Virtual assistants, medical-related tasks,
Diagnosis, health service.
ACKNOWLEDGEMENT
We express our sincere thanks to our respected dean Dr. Abdul Sharief, Dean,
School of Engineering, Presidency University for getting us permission to
undergo the Internship.
We thank our friends for the strong support and inspiration they have provided
us in bringing out this Internship.
DECLARATION ii
ABSTRACT iii
ACKNOWLEDGMENT iv
1. INTRODUCTION 1
2. LITERATURE REVIEW 2
3. EXISTING SYSTEM 5
4. PROPOSED SYSTEM 5
5. BLOCK DIAGRAM 6
Advantages 6
Applications 6
6. ARCHITECTURE DIAGRAM 7
7. SYSTEM REQUIREMENTS 7
8. ALGORITHMS 8
9. IMPLEMENTATION AND
11
INSTALLATION
Pycharm installation 12
10. CODE 14
11. EXECUTION 32
12. PYTHON 40
13. CONCLUSION 56
14. REFERENCES 56
List of Figures
INTRODUCTION
Now a day’s chatbots can be seen in every industry to guide the user as per their
need. They are found in IRCTC with name of Disha chatbot, in banks and also
in different online travel companies like Make My Trip. As we are moving
toward the digitalization there demand in the market is keep on increasing day
by day all the time. The increasing population of the India and availability of the
less doctors to serve the need of the increasing population is the major cause
behind the need of the medical chatbot in the medical industry. Even sometime
doctors can make mistake while making decision regarding the cause of
symptoms in patient thus risking the life of patient. For example, during the
decade of 90’s Mohammed Benaziza who was also known by the name of the
‘Giant killer’ was one of the dominating bodybuilders in the bodybuilding
industry. He has died because of Hypokalemia (means high potassium level) in
his body. Because of this excess potassium level, he was getting the cramps on
the body. The doctors were unable to understand what exactly is happening and
they were came on conclusion that Mohammed is potassium deficient which
creating the cramps on the body. Thus, doctors have injected more potassium in
his body result in spreading of the cramp toward his heart and ultimate death.
There is even lot more cases where even doctors can have made mistake. Thus,
to avoid such scenario there is the need of medical chatbot who can guide the
doctors about what to do in such critical cases. Its application is not only limited
till the doctors but they can also be utilized by the normal human being as in the
case of emergency where it can guide the user about the primary treatments
which should be taken by the person under treatment. Along with that if person
is suffering with a certain disease, then by simply giving the answer of few of
the questions asked by chatbot, it can judge the kind of disease a person is
suffering with. After this if a person wants to know about the precautions and
the remedies that he/she should take then chatbot can also give the information
regarding it.
2
LITERATURE SURVEY
messages that include specific keywords, and even to utilize machine learning
to modify their responses to the scenario. On their websites, an increasing
number of hospitals, nursing homes, and even private centers use online
Chatbots for human services. These bots communicate with potential patients
who visit the site, assisting them in finding specialists, scheduling appointments,
and obtaining the appropriate treatment. In any event, the use of artificial
intelligence in a field where people's lives are potentially at risk raises concerns.
It raises the question of whether the above-mentioned task should be delegated
to humans.
EXISTING SYSTEM
In the existing system, if any patient wants any medicine, then they have to go
to the clinic and meet the doctor and make the prescription after that they have
to go to the medicine store for medicine. This is the time taking process also
performance decreases.
Drawbacks
• Complex user interface. Making user difficult to recognize the operations
• Late response to user due to highly dumped data set
• More processing time to process huge data
PROPOSED SYSTEM
In our proposed system the user can chat with the bot regarding the query
through voice or text. The system uses an expert system to answer the
queries. User can also view the available doctors for that particular disease.
This system can be used by the multiple users to get the counselling
sessions online. The data of the chatbot stored in the database in the form of
pattern-template. Bot will provide analgesics and food suggestions that
means which food you have to take based on the disease.
6
BLOCK DIAGRAM
Figure 1
Advantages
• More visually pleasing
• Less response time to user
• Simple data set
• Less processing time
APPLICATIONS:
• Used to provide psychology related advice to patients.
• Government agencies can use them in health care field especially for poor
people as it is easy to scale up and is inexpensive.
• Hospitals and Health care professionals can use them to save time and
money
7
ARCHITECTURE DIAGRAM
Figure 2
SYSTEM REQUIREMENTS
HARDWARE CONFIGURATION:
• Processor - I3 Intel Processor/R3 AMD
• RAM - 4GB (min)
• Hard Disk - 128 GB
SOFTWARE CONFIGURATION:
• Operating System : Windows 7+
• Server-side Script version : Python 3.6+
• IDE : PyCharm
• Libraries Used in python : Pandas, NumPy, Sklearn, Tkinter
8
ALGORITHMS:
Decision Tree is a supervised learning technique that may be used to solve both
classification and regression problems, however it is most commonly employed
to solve classification issues. Internal nodes represent dataset attributes,
9
branches represent decision rules, and each leaf node provides the conclusion in
this tree-structured classifier.
The Decision Node and the Leaf Node are the two nodes of a Decision tree. Leaf
nodes are the result of those decisions and do not include any more branches,
whereas Choice nodes are used to make any decision and have several branches.
The judgments or tests are made based on the characteristics of the provided
dataset.
It's termed a decision tree because, like a tree, it starts with the root node and
grows into a tree-like structure with additional branches.
We utilize the CART algorithm, which stands for Classification and Regression
Tree algorithm, to form a tree.
A decision tree simply asks a question and then divides the tree into subtrees
based on the answer (Yes/No).
The SVM algorithm's purpose is to find the optimum line or decision boundary
10
for categorizing n-dimensional space into classes so that additional data points
may be readily placed in the proper category in the future. A hyperplane is the
name for the optimal choice boundary.
The extreme points/vectors that assist create the hyperplane are chosen via SVM.
Support vectors are the extreme instances, and the method is called a Support
Vector Machine.
11
Installing Python:
2. After the download is finished, launch the exe file to install Python. Now
press the Install Now button.
4. When it's finished, a screen will appear stating that the Setup was successful.
Now press the "Close" button.
Figure 3
Installing PyCharm:
2. Run the exe to install PyCharm when the download is finished. The
procedure for setting up your computer should have begun by now. "Next"
should be clicked.
4. Click "Following" to go to the next screen, where you can create a desktop
shortcut if desired.
5. Select a folder for the start menu. Keep JetBrains selected and pick "Install"
from the drop-down menu.
7. When the installation is complete, you should get a notification stating that
PyCharm has been successfully installed. If you wish to run it right away,
select "Run PyCharm Community Edition" and then "Finish."
11. The prompt will appear with the selected directory; type "pip install
package name" to install the package you want (for example, numpy, pandas,
seaborn, scikit-learn, matplotlib.pyplot).
13
Figure 3.1
Figure 3.2
CODE:
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
EXECUTION:
1. At first, we must run the code in PyCharm by using the command in the
terminal:
python chat_bot.py
and then press the enter key
Figure 4
33
Figure 4.1
34
2. After this we can start the conversation with the chatbot and the bot will
ask us to enter our name
It then asks us for how many days we have been experiencing that symptom
36
4. After entering the number of days, it will continue to ask us about other
symptoms that we may experience
After checking with all the required symptoms, it will conclude what disease or
condition we might have and will then give a brief description and what
measures should be taken to treat ourselves
It will also tell us if we should consult a doctor and how sever our condition is
39
After all this we can close the chat bot window to end the chat log or we can
say yes in the text box if we want to continue the chat bot
40
INTRODUCTION TO PYTHON
Python
A script is essentially a text file that contains the statements that make up a
Python program. Once you've written the script, you can run it multiple times
without having to retype it each time.
Perhaps more importantly, you can create several versions of the script by using
a text editor to change the statements from one file to the next. Then you can run
each of the separate versions. In this way, it is easy to create different programs
with a minimum amount of typing.
Just about any text editor will suffice for creating Python script files.
You can use Microsoft Notepad, Microsoft WordPad, Microsoft Word, or just
about any word processor if you want to.
Script:
Scripts are separate from the application's core code, which is generally written
in a different language, and are frequently produced or updated by the end-user.
41
Scripts are frequently interpreted from source code or bytes, but the programs
they manage are typically built to native machine code.
Program:
The software comes in an executable format that the computer may utilize to run
the instructions immediately.
The same software in its human-readable source code version, which is used to
create executable programs (e.g., compiled)
Python
What exactly is Python? It's likely that you're asking yourself this question. You
may have come across this book because you wish to learn to program but are
unfamiliar with programming languages. Alternatively, you may be familiar
with programming languages such as C, C++, C#, or Java and wish to learn more
about Python and how it compares to these "big name" languages. Hopefully,
I'll be able to explain it to you.
Python concepts
You can skip to the next chapter if you're not interested in the hows and whys of
Python. In this chapter, I'll try to explain why I think Python is one of the greatest
programming languages accessible and why it's a wonderful place to start.
Python is protected by copyright. Python source code is now available under the
GNU General Public License, much like Perl (GPL).
Python Features
• Python code that is easy to understand is more clearly defined and evident to
the eyes.
• A large standard library the majority of Python's library is portable and cross-
platform compatible on UNIX, Windows, and Macintosh systems.
• Apart from the characteristics described above, Python offers a long range
of useful features, some of which are given below. −
• It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
Dynamic vs Static
In C, for example, if you wanted a variable to hold the price of anything, you'd
have to declare it as a "float" type variable.
This instructs the compiler that the only data that may be used for that variable
is a floating-point number, i.e., a decimal number.
When attempting to build the software, the compiler would throw an error if any
other data value was added to the variable.
Python, on the other hand, does not require this. You simply name your
variables and assign them values. The interpreter is in charge of keeping track
of the objects that your program employs. This also means that as you build the
software, you can adjust the size of the values. Let's pretend you require another
decimal number (also known as a floating-point number) in your software.
When you first initialize a variable in a static typed language, you must decide
45
how much memory it can hold. A double is a floating-point value that can hold
substantially more data than a regular float (the actual memory sizes depend on
the operating environment).
Your program will fail if you declare a variable to be a float but then give it a
value that is too large; you will need to modify that variable to a double.
It makes no difference with Python. Python will take care of modifying the
number as needed if you simply give it a number. It's even applicable to derived
values.
Consider the case of splitting two integers. One of the numbers is a floating-
point value, while the other is an integer. Python recognizes that keeping track
of decimals is more precise, so it calculates the result as a floating-point number
automatically.
Variables
Variables are just reserved memory places where values can be stored. This implies that
when you make a variable, you set aside some memory for it.
The interpreter allocates memory and chooses what can be placed in the reserved memory
based on the data type of a variable. As a result, you may store integers, decimals, or
characters in variables by assigning multiple data types to them.
There are many different forms of data that can be stored in memory. A person's
age, for example, is saved as a numeric value, whereas his or her address is saved
as alphanumeric characters. Python contains a number of standard data types
that describe the operations that may be performed on them as well as the storage
technique for each of them.
Numbers
• String
• List
• Tuple
• Dictionary
Python Numbers
Numeric values are saved in number data types. When you assign a value to a number
object, it is generated.
Python Strings
In Python, a string is defined as a set of characters that are separated by quote marks. Single
or double quotes can be used in Python. The slice operator ([] and [:]) can be used to extract
subsets of strings, with indices beginning at 0 at the beginning and ending at -1 at the
conclusion.
Python Lists
The most flexible of Python's compound data types are lists. Items are separated by
commas and contained in square brackets in a list ([]). Lists are comparable to arrays in C
in certain ways. One distinction is that all elements in a list might be of different data types.
The slice operator ([] and [:]) can be used to retrieve the values stored in a list, with indexes
starting at 0 at the beginning of the list and working their way to -1 at the conclusion. The
list concatenation operator is the plus (+) sign, while the repetition operator is the asterisk
(*).
Python Tuples
47
A tuple, like a list, is a sequence data type. A tuple is a collection of values divided by
commas. Tuples, on the other hand, are contained in parenthesis, unlike lists.
Lists are surrounded in brackets ([]), and their items and sizes can be altered, but tuples are
wrapped in parentheses (()) and cannot be edited. Read-only lists are what tuples are.
Python Dictionary
The dictionaries in Python are similar to hash tables. They're similar to Perl's
associative arrays or hashes, and they're made up of key-value pairs. A
dictionary key can be practically any Python type, but integers and strings are
the most common. Values, on the other hand, may be any Python object you
choose.
Curly braces () surround dictionaries, whereas square braces are used to assign
and access values ([]).
The scripted and completed.py files are run in the Python interpreter in the
regular manner.
Interactive mode is a command-line shell that provides instant response for each
statement while simultaneously running previously provided statements in
active memory. The feed programme is assessed in part and in complete as fresh
lines are fed into the interpreter.
1. Pandas
48
2. Numpy
3. Pymysql
4. Scikit-learn
Pandas:
• Pandas gives us a lot of Series and Data Frames. It makes it simple to organise,
examine, visualise, and manipulate data.
• Pandas' smart alignment and indexing let you organise and classify your data
perfectly.
• Pandas offers certain unique features that allow you to properly manage
missing data or values.
• The code in this package is so clean that even those with little or limited
programming experience can work with it.
• It comes with a set of built-in utilities that let you read and write data from a
variety of online services, data structures, and databases.
• Pandas can read and write JSON, Excel, CSV, HDF5, and a variety of other
file formats. In reality, Pandas allows you to integrate many databases at once.
NumPy:
Masked arrays, as well as ordinary array objects, are available in NumPy. It also
includes features like logical shape manipulation, discrete Fourier transform,
general linear algebra, and more.
• If the geometry of any N-dimensional array is changed, NumPy will build new
arrays and remove the old ones.
NumPy has features that are equivalent to those of MATLAB. They both help
users to complete tasks more quickly.
Pymysql:
• It's completely open source, hosted on GitHub, distributed through Pypi, and
actively maintained.
Scikit-Learn:
• The random module is a simple and effective tool for analysing predicted data.
50
The foundations of OOP are these. A new object is created by a class. This item
might be a model of an actual object, such as a chair, or an abstract data idea.
Variables and methods are specific to each class. In most programming
languages, classes are extremely strong and are now "the big thing." As a result,
later in the book, numerous chapters are devoted to OOP.
When I originally learned C and C++, I did exceptionally well; functions were
51
intuitive to me.
I recognized functions were basically like subroutines after messing around with
BASIC in the early 1990s, so there wasn't much new to learn.
Once you've mastered OOP, you'll see that it's a really useful tool. Furthermore,
because many Python libraries and APIs employ classes, you should be able to
grasp what the code is doing at the very least.
One thing to keep in mind regarding Python and OOP: it's not necessary to utilise
objects in your code in the most efficient way; for example, you may not need a
full-fledged class with initialization code and methods to just return a
computation. You can be as technical as you want with Python.
Python can handle functions quite well, as you've already shown. Unlike
languages like Java, you aren't restricted to a particular method of operation; you
may combine functions and classes as needed inside the same application. This
allows you to construct the code.
Objects are a single object that encapsulates variables and functions. Classes
provide variables and functions to objects. Classes serve as a starting point for
creating your items.
• The class statement is used to construct a class object and name it. A new
namespace is created as a result of this.
• Class attributes are used to export an object's state as well as its related
behavior. All instances of a class share these properties.
• Calling a class (much like calling a function) produces a new instance of it.
• Each instance receives its own namespace and inherits the default class
properties. This prevents instance objects from overlapping and causing the
program to become confused.
• Using the word self identifies a specific instance, allowing for properties
specific to that instance. This allows elements like variables to be linked to a
specific instance.
Inheritance
To begin with, classes enable you to make changes to a program without really
changing it.
To put it another way, subclassing a class allows you to modify the behavior of
a program without having to rewrite the current components.
Class traits can, however, be passed down from one class to the next. As a result,
a subclass inherits from a superclass, allowing you to create a general superclass
with subclasses for specialization.
Subclasses can override a superclass' logic, allowing you to modify the behavior
53
Operator Overloads
Operator overloading essentially implies that objects created from classes may
respond to Python-defined actions (operations) such as addition, slicing,
printing, and so on.
Using overloading ties the behavior closer to Python's object model and the
object interfaces are more consistent with Python's built-in objects, making
overloading easier to understand and use.
Exceptions
I've already discussed exceptions, but today I'll go through them in further detail.
Exceptions are events that change the flow of a program, either purposefully or
due to faults.
They're unique events that can happen when the program encounters a mistake,
like as trying to open a file that doesn't exist, or when it achieves a milestone,
such as the end of a loop.
They're used by almost every module in the standard Python library, and Python
will raise them in a variety of situations.
One use of exceptions is to catch a fault and allow the program to continue
working; we have seen this before when we talked about files.
This is the most common way to use exceptions. When programming with the
Python command line interpreter, you don’t need to worry about catching
exceptions.
Your program is usually short enough to not be hurt too much if an exception
occurs.
Plus, having the exception occur at the command line is a quick and easy way to
tell if your code logic has a problem.
However, if the same error occurred in your real program, it will fail and stop
working. Exceptions can be created manually in the code by raising an
exception.
Because exceptions aren’t supposed to happen very often, they aren’t processed
until they occur.
Exceptions can be thought of as a special form of the if/elif statements. You can
55
realistically do the same thing with if blocks as you can with exceptions.
56
CONCLUSION
Chat bots are a thing of the future that has yet to realize its full potential, but
with their growing popularity and craze among businesses, they are sure to be
around for a long time. With new types of chat bots being introduced all the
time, it's exciting to see a new domain in technology grow while surpassing the
previous barrier. Because of our country's growing population, we are building
a system. These systems exist in other countries, but not in ours. We all know
that there aren't enough doctors to meet every patient's needs. A walk through
the city's government hospitals will give you a clearer understanding of the
situation. Thus, when a doctor is unavailable, the medical chatbot will provide
medical support to patients, thereby improving the efficiency and performance
of the medical business by lowering the death rate.
REFERENCES
[4] Flora Amato, Stefano Marrone, “Chatbots meet eHealth: automat zing
healthcare”, proceeding of diet, May-2018.
[9] Boukricha, H., Wachsmuth, I.: Modeling Empathy for a Virtual Human:
How, When and to What Extent. The 10th International Conference on
Autonomous Agents and Multiagent Systems-Volume 3. International
Foundation for Autonomous Agents and Multiagent Systems, 2011., pp. 1135–
1136
[10] Agarwal, R., Gao, G., DesRoches, C., et al.: The Digital Transformation of
Healthcare: Current Status and the Road Ahead. Information Systems Research
21, 796-809 (2010).
[11] Aron, A., Aron, E.N., Smollan, D.: Inclusion of Other in the Self Scale and
the structure of interpersonal closeness. Journal of Personality and Social
Psychology 63, 596-612 (1992).
[12] Bickmore, T., Cassell, J.: Social Dialogue with Embodied Conversational
Agents. In: Kuppevelt, J.C.J., Bernsen, N.O., Dybkjær, L. (eds.) Advances in
Natural Multimodal Dialogue Systems, vol. 30, pp. 23–54. Springer, Dordrecht
(2005).
[13] Bickmore, T., Gruber, A., Picard, R.: Establishing the computer–patient
working alliance in automated health behavior change interventions. Patient
Education and Counseling 59, 21-30 (2005).