Up-2 Project Report

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

HEALTH-CARE CHATBOT USING

NATURAL LANGUAGE PROCESSING


A Project Report

Submitted by

MEHER TAJ - 20181CSE0415


BRIAN PAUL - 20181CSE0116
ASHRITHA M - 20181CSE0446
N ZEBA FATHIMA NIAZI- 20181CSE0460

Under the guidance of


Assistant Professor T RAMESH

in partial fulfillment for the award of the degree of

BACHELOR OF TECHNOLOGY
IN

COMPUTER SCIENCE AND ENGINEERING

At

Department of Computer Science and Engineering


School of Engineering
PRESIDENCY UNIVERSITY
BANGALORE

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

Language Processing” being submitted by “Meher Taj, Brian Paul, Ashritha

M, N Zeba Fathima Niazi” bearing roll number(s): 20181CSE0415,

20181CSE0116, 20181CSE0446, 20181CSE0460 in partial fulfillment of

requirement for the award of degree of Bachelor of Technology in Computer

Science and Engineering is a bonafide work carried out under my supervision.

Dr. C. KALAIARASAN Dr. S PRAVINTH RAJA Mr. T RAMESH


Associate Dean-CSE UP-II (Project Coordinator) UP-II (Project Supervisor)
Department of CSE Associate Professor-CSE Asst. Professor-CSE
Presidency University Presidency University Presidency University
DEPARTMENT OF COMPUTER SCIENCE AND
ENGINEERING
SCHOOL OF ENGINEERING

PRESIDENCY UNIVERSITY

DECLARATION

I hereby declare that the work, which is being presented in the internship report

entitled Health-Care Chatbot Using Natural Language Processing in partial

fulfilment for the award of Degree of Bachelor of Technology in Computer

Science and Engineering, is a record of our own investigations carried under

the guidance of Mr. T Ramesh, Asst. Professor, Department of Computer

Science and Engineering, School of Engineering, Presidency University,

Bangalore.

We have not submitted the matter presented in this report anywhere for the

award of any other Degree.

MEHER TAJ - 20181CSE0415


BRIAN PAUL - 20181CSE0116
ASHRITHA M - 20181CSE0446
N ZEBA FATHIMA NIAZI -
20181CSE0460
ABSTRACT

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

First of all, we indebted to the GOD ALMIGHTY for giving me an opportunity


to excel in our efforts to complete this project on time.

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 record our heartfelt gratitude to our beloved professor Dr. C. Kalaiarasan,


Professional Practice-II In charge, Associate Dean-Admin, Department of
Computer Science and Engineering, Presidency University for rendering timely
help for the successful completion of this project.

We are greatly indebted to our guide Mr. T Ramesh, Asst. Professor,


Department of Computer Science and Engineering, Presidency University for
his/her inspirational guidance, valuable suggestions and providing us a chance
to express our technical capabilities in every respect for the completion of the
project work.

We thank our friends for the strong support and inspiration they have provided
us in bringing out this Internship.

MEHER TAJ - 20181CSE0415


BRIAN PAUL - 20181CSE0116
ASHRITHA M - 20181CSE0446
N ZEBA FATHIMA NIAZI - 20181CSE0460
TABLE OF CONTENTS

CHAPTER NO. TITLE PAGE NO.


CERTIFICATE i

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

Sl. Figure Caption Page


No. Name No.
1 Figure 1 Block Diagram 6
2 Figure 2 Architecture Diagram 7
3 Figure 3 Python page 11
4 Figure 3.1 Pycharm page 13
5 Figure 3.2 Pycharm window 13
6 Figure 4 Pycharm terminal 32
7 Figure 4.1 Chat-bot window 33
1

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

[1] E-Health is defined in as the practice of health-care supported by


electronic processes and communications.
Everyone is talking about e-health these days, but few have provided a precise
definition of this relatively new phrase. This term, which was barely in use
before 1999, now appears to be a broad "buzzword," describing not only
"Internet medicine," but essentially everything linked to computers and
medicine. Industry leaders and marketing professionals, not academics, are said
to have coined the phrase. They coined the term, along with other "e-words" like
e-commerce, e-business, e-solutions, and so on, to convey the promises,
principles, and excitement (and hype) surrounding e-commerce (electronic
commerce) to the health arena, as well as to describe the new possibilities the
Internet is opening up in the field of health care. For example, Intel defined e-
health as "a coordinated effort by leaders in health care and high-tech companies
to fully exploit the benefits available via the convergence of the Internet and
health care." The development of a new phrase to handle these concerns felt
appropriate because the Internet brought new opportunities and difficulties for
the old health care information technology business. These "new" challenges for
the health care information technology industry included (1) the ability of
consumers to interact with their systems online (B2C = "business to consumer");
(2) improved data transmission capabilities between institutions (B2B =
"business to business"); and (3) new consumer-to-consumer communication
capabilities (C2C = "consumer to consumer").

[2] It shows that emerging technologies are revolutionizing the way of


thinking about healthcare.
Existing technologies in healthcare, now commonplace, were once novel ideas,
care models and devices, and new treatments. Today emerging technologies
(ETs) are developed and implemented in healthcare organizations at a rapid rate.
3

Nurses, nurse informaticists, and nurse educators should have a clear


comprehension of the role of emerging technology in healthcare to optimize
clinical practice. Innovation and innovators are essential to revolutionizing
antiquated healthcare business models to offer new products, services, and
models to modernize practice and serve the Quadruple Aim better. Divergent
collaborations and innovation centers in healthcare organizations provide nurses
the opportunity to be champions and early adopters and enforcers of ETs and
responsible innovation, thereby improving safety and quality outcomes and
promoting health equity. The knowledge of Nurses as innovators will further the
impending need of ETs to serve the Quadruple Aim.

[3] People are relying on health tracking gadgets, connected health


equipment, and tailored and proximity medicine at an increasing rate.
Through remote monitoring and virtual visits, IoT technology increases patient-
doctor communication; it aids hospitals in tracking personnel and patients; and
IoT healthcare devices help with chronic illness management. It eliminates
inefficiencies and errors; it optimizes the pharmaceutical production process,
potentially cutting medicine prices; it maintains quality control and handles
sensitive products while in transit; and it can even lower healthcare expenses by
streamlining the overall process.

[4] Chat bots can be taught to answer in a consistent manner, to respond


differently to messages containing specific keywords, and even to apply
machine learning to adjust their responses to match the circumstance.
Chatbots allow users to converse via a text or voice interface and receive
responses from artificial intelligence. In most cases, a chat bot will converse with
a real human. Bots are employed in a variety of applications, including
ecommerce customer service, call centers, and online gaming. Chatbots are
computer programs that respond to messages automatically. Chatbots can be
designed to answer in the same manner every time, to respond differently to
4

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.

[5] A developing number of hospitals, nursing homes, and even private


centers, presently utilize online Chat bots for human services on their sites.
Chatbots are computer programs that respond to messages automatically.
Chatbots can be programmed to answer in the same way every time, to respond
differently to messages that contain specific keywords, and even to utilize
machine learning to modify their responses to the scenario. On their websites, a
growing number of hospitals, nursing homes, and even private facilities 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. This healthcare chatbot system will assist hospitals in
providing online healthcare support 24 hours a day, seven days a week. It
answers both detailed and general questions. It also assists in the generation of
leads and the automatic delivery of lead information to sales. By asking the
questions in order, the patient is aided in determining what he or she is seeking
for.
5

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:

NATURAL LANGUAGE PROCESSING:


Natural language processing (NLP) is a branch of linguistics, computer science,
and artificial intelligence concerned with how computers interact with human
language, specifically how to design computers to process and analyses massive
volumes of natural language data. As a consequence, a computer may
"understand" the contents of documents, including the intricacies of language
within them. The system can then properly extract data and insights from the
papers, as well as categories and arrange them.

A chatbot is natural language processing software that can mimic a discussion


(or chat) with a user in natural language via messaging apps, websites, mobile
apps, or the phone.

What is the significance of chatbots? A chatbot is frequently regarded as one of


the most advanced and promising forms of human-machine interaction. From a
technology standpoint, however, a chatbot is just the next step in the evolution
of a Question Answering system that uses Natural Language Processing (NLP).
One of the most common examples of Natural Language Processing in usage in
many organizations’ end-use applications is formulating replies to inquiries in
natural language.

DECISION TREE CLASSIFIER:

Decision Tree is a Supervised Machine Learning Algorithm that uses a set of


rules to make decisions, similarly to how humans make decisions.

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 a graphical depiction for obtaining all feasible answers to a problem/decision


depending on certain parameters.

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).

SVC (Support Vector Classification):

Support Vector Machine (SVM) is a supervised machine learning algorithm


used for both classification and regression

The Support Vector Machine, or SVM, is a common Supervised Learning


technique that may be used to solve both classification and regression issues.
However, it is mostly utilized in Machine Learning for Classification
difficulties.

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

IMPLEMENTATION AND INSTALLATION

Installing Python:

1. Go to the official Python website, https://www.python.org/downloads/, to


download and install Python. Then select your preferred version.

2. After the download is finished, launch the exe file to install Python. Now
press the Install Now button.

3. At this point, Python should be installed.

4. When it's finished, a screen will appear stating that the Setup was successful.
Now press the "Close" button.

Figure 3

Installing PyCharm:

1.Go to https://www.jetbrains.com/pycharm/download/ and click the "Get" link


in the Community Section to download PyCharm.
12

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.

3. Adjust the installation path, if necessary, on the following screen. "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.

6. Hold your breath until the installation is completed.

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."

8. The following page will show once you click "Finish."

9. You'll need to install a few packages in order to complete your project


properly.

10. Log in as an administrator to the command prompt/anaconda


prompt/terminal.

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

After that the chat window appears

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 to enter what symptoms we are experiencing


35

3. After entering the symptom, we get this

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

This is answered in yes/no


37

5. After this it will check with other 5 to 7 symptoms to come to the


conclusion.

All this will be answered in yes/no format only


38

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

What Is a Script, exactly?

I've focused on Python's interactive programming capabilities up to this point.


This is a really useful feature that allows you to type in a program and have it
executed in interactive mode right away.

Scripts can be reused.

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.

Scripts can be changed.

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.

You will need a text editor

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.

Difference between a script and a program

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.

• Object-oriented, procedural, and functional language that is open-source.

• Simple to use with C/ObjC/Java/Fortran

• C++ interface is rather simple (via SWIG)

• Excellent opportunity for interaction

Python is a scripting language that is high-level, interpreted, interactive, and


object-oriented. Python is intended to be a very understandable language. It
42

typically employs English terms instead of punctuation, and it has fewer


syntactical structures than other languages.

Python is Interpreted − Python is processed at runtime by the interpreter. You


do not need to compile your program before executing it. This is similar to PERL
and PHP.

• Python is Object-Oriented Python supports the Object-Oriented programming


style or approach, which wraps code within objects.

• Python is a Beginner's Language Python is an excellent language for beginning


programmers, as it allows for the creation of a wide range of programs, ranging
from simple text processing to web browsers and games. History of Python

Guido van Rossum created Python in the Netherlands' National Research


Institute for Mathematics and Computer Science in the late 1980s and early
1990s.

Python is based on a variety of languages, including ABC, Modula-3, C, C++,


Algol-68, SmallTalk, Unix shell and other scripting languages.

Python is protected by copyright. Python source code is now available under the
GNU General Public License, much like Perl (GPL).

Python is presently maintained by the institute's core development team;


however, Guido van Rossum continues to play a key role in its direction.

Python Features

Python's features include −

• Python is simple to learn, with few terms, a straightforward structure, and a


well-defined grammar. This enables the pupil to swiftly learn the language.
43

• Python code that is easy to understand is more clearly defined and evident to
the eyes.

• Simple to maintain Python's source code is relatively simple to maintain.

• A large standard library the majority of Python's library is portable and cross-
platform compatible on UNIX, Windows, and Macintosh systems.

• Interactive Mode Python features an interactive mode that allows interactive


debugging and testing of code snippets.

• Python is portable, meaning it can operate on a broad range of hardware


systems and has the same user interface across all of them.

• Extendable: The Python interpreter may be extended using low-level modules.


These modules allow programmers to improve the efficiency of their tools by
adding to or customizing them.

• ## Databases Python has interfaces for all of the main commercial


databases.

• GUI Programming Python facilitates the creation and porting of graphical


user interfaces to a variety of system calls, libraries, and operating systems,
including Windows MFC, Macintosh, and Unix's X Window system.

• Scalable - Compared to shell programming, Python has a stronger


structure and support for huge projects.

• Apart from the characteristics described above, Python offers a long range
of useful features, some of which are given below. −

• It supports OOP as well as functional and structured programming


methodologies.
44

• It may be used as a scripting language or converted into byte-code for


large-scale application development. It provides very high-level dynamic
data types and supports dynamic type checking.

• IT supports automatic garbage collection.

• It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

Dynamic vs Static

Types Python is a dynamically typed programming language. Many other


languages, such as C/C++ and Java, are static typed. A programmer must
explicitly inform the machine what sort of "thing" each data value is in a static
typed language.

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.

Standard Data Types

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.

There are five standard data types in Python.


46

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 ([]).

Different modes in python

Normal and interactive are the two basic modes of Python.

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.

Some Python Libraries:

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:

• NumPy’s arrays provide current mathematical implementations on large


datasets. NumPy simplifies and streamlines the implementation of these tasks.
49

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.

This Python package contains important integration tools. NumPy is simple to


use with programming languages such as C, C++, and Fortran.

NumPy has features that are equivalent to those of MATLAB. They both help
users to complete tasks more quickly.

Pymysql:

• PyMySQL is a Python database connector that includes packages that allow


Python programmes to communicate with MySQL servers.

• Python properties provide access to port settings.

• PyMySQL is a MySQL driver built entirely in Python, based on the MySQL-


Python driver.

• PyMySQL satisfies all of the requirements for a driver.

• It's completely open source, hosted on GitHub, distributed through Pypi, and
actively maintained.

• It's written in pure Python, so it's compatible with eventlet-monkeypatch and


Python 3.

Scikit-Learn:

• The random module is a simple and effective tool for analysing predicted data.
50

• Everyone may use it, and it can be reused in a variety of situations

• The library focuses on data modelling. It isn't focused on data loading,


manipulation, or summarization. Refer to NumPy and Pandas for these
functionalities.

The following are some of the features provided by scikit-learn:

• Linear and Logistic Regression are two types of regression.

• Classification, which includes the K-Nearest Neighbors method.

• Clustering techniques such as K-Means and K-Means++

• Pre-processing, including Min-Max Normalization • Model selection

Python class and objects

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.

In object-oriented programming, the class is the most fundamental component.


You already learnt how to make your program do anything by using functions.

We'll now enter the great, terrifying world of Object-Oriented Programming


(OOP) (OOP). To be honest, getting a grasp on things took several months for
me.

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.

My grades deteriorated, however, when my C++ class began discussing objects,


classes, and all of the new aspects of OOP.

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.

Here’s a brief list of Python OOP ideas:

• The class statement is used to construct a class object and name it. A new
namespace is created as a result of this.

• Class characteristics are created by assignments inside the class. These


characteristics are accessible by using the dot syntax to qualify the name:
ClassName.Attribute.
52

• 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.

As we've seen, a class's characteristics are passed down to its instances.

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

of your classes without having to update the superclass.

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.

Nearly all of Python's built-in operation methods may be overridden by user-


created classes.

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.

Exceptions, by definition, don't happen very often; as a result, they're the


"exception to the rule," and they've been given their own class. Exceptions may
be found all across Python.

They're used by almost every module in the standard Python library, and Python
will raise them in a variety of situations.

Here are just a few examples:


54

• Accessing a non−existent dictionary key will raise a KeyError exception.

• Searching a list for a non−existent value will raise a ValueError exception

. • Calling a non−existent method will raise an AttributeError exception.

• Referencing a non−existent variable will raise a NameError exception.

• Mixing datatypes without coercion will raise a TypeError exception.

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.

It operates exactly as a system-caused exceptions, except that the programmer


is doing it on purpose. This can be for a number of reasons. One of the benefits
of using exceptions is that, by their nature, they don’t put any overhead on the
code processing.

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

[1]A. Allen, ‘‘Morphing telemedicine-telecare-telehealth-ehealth,’’ Telemed


Today, Special, no. 2000, 2000.

[2]S. L. Murphy, J. Xu, K. D. Kochanek, and E. Arias, ‘‘Mortality in the United


States, 2017,’’ NCHS Data Brief, no. 328, pp. 1–8, Nov. 2018.

[3]K. Myers, P. Berry, J. Blythe, K. Conley, M. Gervasio, D. L. McGuinness,


D. Morley, A. Pfeffer, M. Pollack, and M. Tambe, ‘‘An intelligent personal
assistant for task and time management,’’ AI Mag., vol. 28, no. 2, p. 47, 2007.

[4] Flora Amato, Stefano Marrone, “Chatbots meet eHealth: automat zing
healthcare”, proceeding of diet, May-2018.

[5] BenildaEleonor V. Comendador, “Pharmabot: A pediatric generic Medicine


consultant Chatbot”, proceeding of the JACE, April 2015.

[6] Divya, Indumathi, Ishwarya, Priyasankari, “A SelfDiagnosis Medical


57

Chatbot Using Artificial Intelligence”, proceeding MAT Journal, October-2017.

[7] Tobias Kowatsch,” Text-based Healthcare Chatbots Supporting Patient and


Health”, 01 October 2017.

[8] Chin-Yuan Huang, Ming-Chin Yang, Chin-Yu Huang, “A Chatbot-


supported Smart Wireless Interactive Healthcare System for Weight Control and
Health Promotion”, proceeding of the IEEE, April-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).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy