Medical Care 1

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

APPLICATIONS OF MACHINE LEARNING IN THE

FIELD OF MEDICAL CARE

A mini project submitted to the JAWAHARLAL NEHRU


TECHNOLOGICAL UNIVERSITY in partial fulfillment of the
requirement for the award of the degree of

BACHELOR OF TECHNOLOGY
In
Computer Science & Engineering
Submitted by
PABBOJU NAVEEN KUMAR 19D31A0573
THARIGOPPULA MANASA 20D35A0519
JOGINI KAVERI 19D31A0544
Under the Guidance of

MR. CH. GOPI KRISHNA

Asst.Prof Dept of CSE

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

INDUR INSTITUTE OF ENGINEERING & TECHNOLOGY


(Affiliated to JNTUH)

PONNALA(V), SIDDIPET(D), TELANGANA STATE-502277

JANUARY 2023

i
INDUR INSTITUTE OF ENGINEERING & TECHNOLOGY
Ponnala (V), Siddipet (Mdl&Dist), Telangana State, PIN: 502277

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Date: / /2022

CERTIFICATE

This is to certify that the thesis “ APPLICATIONS OF MACHINE


LEARNING IN THE FIELD OF MEDICAL CARE” being submitted by

PABBOJU NAVEEN KUMAR 19D31A0573


THARIGOPPULA MANASA 20D35A0519
JOGINI KAVERI 19D31A0544

In partial fulfillment for the award of Bachelor of Technology in Computer


Science & Engineering (B.Tech) to the Jawaharlal Nehru Technological University is
a record of bonafide mini project work carried out by them under our guidance and
supervision .The results embodied in this thesis have not been submitted to any other
University or Institute for the award of any degree or diploma.

MR. CH.GOPI KRISHNA MR.RITESH THAKUR

Project Guide Prof & Head


Asst.Professor, Dept of CSE Dept of CSE
Indur Institute of Engineering & Indur Institute of Engineering &
Technology, Siddipet. Technology, Siddipet.

EXTERNAL EXAMINER

ii
ACKNOWLEGEMENT

We are thankful MR. CH.GOPI KRISHNA , Asst.Prof, Project


Guide,Dept. of CSE who guided me a lot by his favorable suggestions to complete
our project. He is the research oriented personality with higher end technical
exposure.

We are thankful to MR. RITESH THAKUR, Prof & Head, Dept. of CSE,
Indur Institute of Engineering & Technology, for extending his help in the
department academic activities in the course duration. He is the personality of
dynamic, enthusiastic in the academic activities.

We extend my thanks to DR.VP.RAJU, Principal , Indur Institute of


Engineering and Technology, Siddipet for extending his help throughtout the
duration of this project.

We sincerely acknowledge to all the lecturers of the Dept. of CSE for their motivation
during my B. Tech course.

We would like to say thanks to all of our friends for their timely help and
encouragement.

PABBOJU NAVEEN KUMAR 19D31A0573


THARIGOPPULA MANASA 20D35A0519
JOGINI KAVERI 19D31A0544

iii
DECLARATION

We hereby declare that the project work entitled “APPLICATIONS OF


MACHINE LEARNING IN THE FIELD OF MEDICAL CARE” submitted to
the university, is a record of an original work done by us under the guidance of MR.

CH.GOPI KRISHNA , Asst.Prof, Department Of Computer Science &


Engineering, INDUR INSTITUTE OF ENGINEERING & TECHNOLOGY and
this project work has not formed the basis for the award of any
degree\diploma\associateship\fellowship and any other similar titles if any.

PABBOJU NAVEEN KUMAR 19D31A0573


THARIGOPPULA MANASA 20D35A0519
JOGINI KAVERI 19D31A0544

iv
ABSTRACT

These years, with artificial intelligence and machine learning


becoming the hotspot of research, several applications have emerged in
each of these areas. It exists not only as a kind of academic frontier but
also something close to our life. In this trend, the combination of medical
care and machine learning becomes more and more tighter. The proposal
of its main idea also greatly alleviated the existing situation of
unbalanced medical distribution and resources strain. This paper
summarizes some application of machine learning and auxiliary tumor
treatment in the process of medical resource allocation, and puts forward
some new methods of application to realize it closer to human life in the
era of artificial intelligence and the explores a good situation of mutual
combination of medical industry and computer industry, which is benefit
both.

v
CONTENTS

1 INTRODUCTION 2

2 LITERATURE SURVEY 4-7

3 SYSTEM ANALYIS 9-36

3.1 Existing System

3.2 Proposed System

3.3 System Environment

3.3.1 Python

3.3.2 Django

3.4 System Study

3.4.1 Feasibility Study.

5 Requirement Analysis

3.5.1 Software Requirements

3.5.2 Hardware Requirements

4 SYSTEM DESIGN 38-44

4.1 System Architecture

4.2 Data Flow Diagram

4.3 UML Diagrams

4.3.1 Use Case Diagram

4.3.2 Class Diagram

4.3.3 Sequence Diagram

4.3.4 Activity Diagram

vi
5 IMPLEMENTATION 46-54

5.1 Modules

5.2 Modules Description

5.2.1 Doctor

5.2.2 Patient

5.2.3 Admin

5.2.4 Machine Learning

5.3 Sample Code

5.4 Input and Output Design

5.4.1 Input Design

5.4.2 Output Design

6 RESULTS 56-61

7 SYSTEM TESTING 63-67

7.1 Unit Testing

7.2 Integration Testing

7.3 Functional Testing

7.4 System Testing

7.5 White box Testing

7.6 Block box Testing

8 CONCLUSION 69

8.1 Conclusion

8.2 Future Enhancement

9 BIBLIOGRAPHY 71-72

vii
LIST OF FIGURES

1 Django architecture 24
2 Model view template 25
3 System Architecture 38
4 Data Flow Diagram 39
5 Use Case Diagram 41
6 Class Diagram 42
7 Sequence Diagram 43
8 Activity Diagram 44

Doctor
9 Registration Page 56
10 Doctor Page 56
11 View Patient Data 57
12 Add Treatment 57

Patient
13 Registration Page 58
14 Patient Page 58
15 Treatment 58

Hospital
16 HSP Page 59
17 Upload Patient Data 59
18 View Patient Data 59

Admin
19 Admin Page 60
20 Patient Details 60
21 Doctor Details 60
22 Store Data 61
23 SVM 61
24 Decision Tree 61

viii
CHAPTER – 1

1
INTRODUCTION

Machine learning (M’L) is a science which aims to make machine capable of


learning. Machine learning returned to the public’s vision after the famous
competition between Alpha Go of Google and the Go player Li Sedol, ending with the
score 4:1 in 2015. And this event made machine learning more well know among
people even among those who were not familiar to computer science and it has caused
intense debate in related field. Actually, although machine learning is a young branch
of AI, it is not a new subject. ML is broadly defined as the application of certain
computer algorithms to a set of data known to the event outcomes, and the ability to
learn to training data and predict new data based on learning outcomes. Its core is
induction and summary instead of deductive. Early in the medium of 1950s, Samuel, a
computer scientist of United States, designed a chess program that could learn by
itself through continuous play. This program shows people the ability of machine at
the first time, meanwhile, the unpredictable potential of machine to learn came into
people’s sight. However, as the research continued, machine learning entered a period
of cooling off. Until 1970s, it staged a comeback gradually. And during this period of
continuous research and development, until today, machine learning has become an
important subject including data mining, pattern recognition, natural language
processing and so on. It has also become a core of AI. In today’s society, medical care
problems have become a hot topic, and problems such as the unbalance and
insufficient allocation of medical resources has become increasingly apparent. In this
situation, the application of ML has become the unavoidable trend in the current
development of medical care. As early as 1972, the scientists in the University of
Leeds in the UK has been trying to use artificial intelligence (ANN) algorithms to
judge abdominal pain. Now, more and more researchers are committed to the
combination of ML and medical care. The methods of pathological diagnosis of
tumors, lung cancer, etc. by ML has gradually entered the field of vision. Some
companies, such as Alibaba, Amazon, and Baidu have established their own research
team working for it. This introduction of ML in medical care has greatly saved
medical resources and provided a new way for citizens to see a doctor and facilitate
people’s lives. At th.e same time, the demand of people also provides a new impetus
for the research and development of ML, with promoting its continuous improvement.

2
CHAPTER – 2

3
LITERATURE SURVEY

1)Journal of Medical Imaging and Health Informatics ISSN


AUTHORS: Dr. Eddie Yin-Kwee NG , Singapore.

Journal of Medical Imaging and Health Informatics (JMIHI) is a medium to


disseminate novel experimental and theoretical research results in the field of
biomedicine, biology, clinical, rehabilitation engineering, medical image processing,
bio-computing, D2H2, and other health related areas. As an example, the Distributed
Diagnosis and Home Healthcare (D2H2) aims to improve the quality of patient care
and patient wellness by transforming the delivery of healthcare from a central,
hospital-based system to one that is more distributed and home-based. Different
medical imaging modalities used for extraction of information from MRI, CT,
ultrasound, X-ray, thermal, molecular and fusion of its techniques is the focus of this
journal.

2)Computer-aided diagnosis of malignant or benign thyroid nodes based on


ultrasound images.
AUTHORS: Qin Yu, Tao Jiang, Aiyun Zhou, Lili Zhang, Cheng Zhang & Pan
Xu The objective of this study is to evaluate the diagnostic value of combination of
artificial neural networks (ANN) and support vector machine (SVM)-based CAD
systems in differentiating malignant from benign thyroid nodes with gray-scale
ultrasound images. Two morphological and 65 texture features extracted from regions
of interest in 610 2D-ultrasound thyroid node images from 543 patients (207
malignant, 403 benign) were used to develop the ANN and SVM models. Tenfold
cross validation evaluated their performance; the best models showed accuracy of
99% for ANN and 100% for SVM. From 50 thyroid node ultrasound images from 45
prospectively enrolled patients, the ANN model showed sensitivity, specificity,
positive and negative predictive values, Youden index, and accuracy of 88.24, 90.91,
83.33, 93.75, 79.14, and 90.00%, respectively, the SVM model 76.47, 90.91, 81.25,
88.24, 67.38, and 86.00%, respectively, and in combination 100.00, 87.88, 80.95,
100.00, 87.88, and 92.00%, respectively. Both ANN and SVM had high value in
classifying thyroid nodes. In combination, the sensitivity increased but specificity
decreased. This combination might provide a second opinion for radiologists dealing
with difficult to diagnose thyroid node ultrasound images.

4
3)Liver segmentation from CT images using a sparse priori statistical shape
model (SP-SSM)

AUTHORS: Xuehu Wang ,Yongchang Zheng ,Lan Gan,Xuan Wang,Xinting


Sang,Xiangfeng Kong,Jie Zhao

This study proposes a new liver segmentation method based on a sparse a


priori statistical shape model (SP-SSM). First, mark points are selected in the liver a
priori model and the original image. Then, the a priori shape and its mark points are
used to obtain a dictionary for the liver boundary information. Second, the sparse
coefficient is calculated based on the correspondence between mark points in the
original image and those in the a priori model, and then the sparse statistical model is
established by combining the sparse coefficients and the dictionary. Finally, the
intensity energy and boundary energy models are built based on the intensity
information and the specific boundary information of the original image. Then, the
sparse matching constraint model is established based on the sparse coding theory.
These models jointly drive the iterative deformation of the sparse statistical model to
approximate and accurately extract the liver boundaries. This method can solve the
problems of deformation model initialization and a priori method accuracy using the
sparse dictionary. The SP-SSM can achieve a mean overlap error of 4.8% and a mean
volume difference of 1.8%, whereas the average symmetric surface distance and the
root mean square symmetric surface distance can reach 0.8 mm and 1.4 mm,
respectively.

5
4)Automatic Detection of Cerebral Microbleeds From MR Images via 3D
Convolutional Neural Networks

AUTHORS:Qin Yu, Tao Jiang, Aiyun Zhou, Lili Zhang, Cheng Zhang & Pan
Xu

Cerebral microbleeds (CMBs) are small haemorrhages nearby blood vessels. They
have been recognized as important diagnostic biomarkers for many cerebrovascular
diseases and cognitive dysfunctions. In current clinical routine, CMBs are manually
labelled by radiologists but this procedure is laborious, time-consuming, and error
prone. In this paper, we propose a novel automatic method to detect CMBs from
magnetic resonance (MR) images by exploiting the 3D convolutional neural network
(CNN). Compared with previous methods that employed either low-level hand-crafted
descriptors or 2D CNNs, our method can take full advantage of spatial contextual
information in MR volumes to extract more representative high-level features for
CMBs, and hence achieve a much better detection accuracy. To further improve the
detection performance while reducing the computational cost, we propose a cascaded
framework under 3D CNNs for the task of CMB detection. We first exploit a 3D fully
convolutional network (FCN) strategy to retrieve the candidates with high
probabilities of being CMBs, and then apply a well-trained 3D CNN discrimination
model to distinguish CMBs from hard mimics. Compared with traditional sliding
window strategy, the proposed 3D FCN strategy can remove massive redundant
computations and dramatically speed up the detection process. We constructed a large
dataset with 320 volumetric MR scans and performed extensive experiments to
validate the proposed method, which achieved a high sensitivity of 93.16% with an
average number of 2.74 false positives per subject, outperforming previous methods
using low-level descriptors or 2D CNNs by a significant margin. The proposed
method, in principle, can be adapted to other biomarker detection tasks from
volumetric medical data.

6
5)Automatic Classification of Specific Melanocytic Lesions Using Artificial
Intelligence

AUTHORS:Joanna Jaworek-Korjakowska 1 and Paweł Kłeczek 1.

Background. Given its propensity to metastasize, and lack of effective therapies for
most patients with advanced disease, early detection of melanoma is a clinical
imperative. Different computer-aided diagnosis (CAD) systems have been proposed
to increase the specificity and sensitivity of melanoma detection. Although such
computer programs are developed for different diagnostic algorithms, to the best of
our knowledge, a system to classify different melanocytic lesions has not been
proposed yet. Method. In this research we present a new approach to the classification
of melanocytic lesions. This work is focused not only on categorization of skin lesions
as benign or malignant but also on specifying the exact type of a skin lesion including
melanoma, Clark nevus, Spitz/Reed nevus, and blue nevus. The proposed automatic
algorithm contains the following steps: image enhancement, lesion segmentation,
feature extraction, and selection as well as classification. Results. The algorithm has
been tested on 300 dermoscopic images and achieved accuracy of 92% indicating that
the proposed approach classified most of the melanocytic lesions correctly.
Conclusions. A proposed system can not only help to precisely diagnose the type of
the skin mole but also decrease the amount of biopsies and reduce the morbidity
related to skin lesion excision.

7
CHAPTER – 3

8
SYSTEM ANALYSIS

3.1 EXISTING SYSTEM:

Computer technology could be used to reduce the number of mortality and reduce the
waiting time to see the specialist. Computer programs or software developed by
emulating human intelligence could be used to assist the doctors in making decisions
without consulting the specialists directly. The software was not meant to replace the
specialist or doctor, yet it was developed to assist general practitioners and specialists
take immediate action to produce as many doctors as possible. However, while
waiting for students to become doctors and the doctors to become specialists, many
patients may already die. Current practice for medical treatment required patients to
consult specialists for further treatment. Artificial intelligence provides students with
more opportunities to participate in a digital and dynamic way.

DISADVANTAGES OF EXISTING SYSTEM:

We can’t Identify Diseases and Diagnosis, without artificial intelligence or machine


learning.

.we can’t predict any type of cancer like breast cancer or skin cancer etc..

Drug Discovery and Manufacturing.,Medical Imaging Diagnosis difficult to do

without machine learning.

9
3.2 PROPOSED SYSTEM:

In this paper, Focusing on research about ML in medical care currently, its focus is
basically on the judgement of the symptoms and the improvement of related medical
measures.

Certainly, relevant researchers are able to reduce the investment of medical resources
and avoid subjective error caused by human’s judgement themselves.

With the development of medical technology Machine learning has been studied for
the prediction of tumor, follow-up treatment and so on. At present, relevant study has
made a significance in breast cancer, lung cancer, skin cancer. Researchers are still
advancing research on other cancers.

ADVANTAGES OF PROPOSED SYSTEM:

By implementing machine learning we can predict breast cancer, lung cancer, skin
cancer..

We can Identify Diseases and Diagnosis,Drug Discovery and Manufacturing,Medical


Imaging Diagnosis,Personalized Medicine,Clinical Trial and Research,Crowdsourced
Data Collection etc..

Recommendations on health and treatments for diseases are personalized based on the
patient’s medical history, diet, stress levels, past conditions, etc.

Robots are being trained to perform complicated surgeries on humans and, that too,
as efficient as a human doctor. Imagine an era where a patient can scan an image of
his skin through his phone and know what kind of disease he is suffering with.

10
3.3 SYSTEM Environment

3.3.1 PYTHON

Python is a general-purpose interpreted, interactive, object-oriented, and high-level


programming language. An interpreted language, Python has a design philosophy that
emphasizes code readability (notablyusing whitespace indentation to delimit code
blocks rather than curly brackets or keywords), and a syntax that allows programmers
to express concepts in fewer lines of code than might be used in languages such
as C++or Java. It provides constructs that enable clear programming on both small
and large scales. Python interpreters are available for many operating
systems. Cpython, the reference implementation of Python, is open
source software and has a community-based development model, as do nearly all of
its variant implementations. Cpython is managed by the non-profit Python Software
Foundation. Python features a dynamic type system and automatic memory
management. It supports multiple programming paradigms, including object-
oriented, imperative, functional and procedural, and has a large and
comprehensive standard library.

Interactive Mode Programming

Invoking the interpreter without passing a script file as a parameter brings up the
following prompt –

$ python
Python 2.4.3 (#1, Nov 11 2010, 13:34:43)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.>>>
Type the following text at the Python prompt and press the Enter –
>>> print “Hello, Python!”
If you are running new version of Python, then you would need to use print statement
with parenthesis as in print (“Hello, Python!”);. However in Python version 2.4.3, this
produces the following result –

Hello, Python!

11
Script Mode Programming
Invoking the interpreter with a script parameter begins execution of the script and
continues until the script is finished. When the script is finished, the interpreter is no
longer active.
Let us write a simple Python program in a script. Python files have extension .py.
Type th following source code in a test.py file –
Live Demo
print “Hello, Python!”
We assume that you have Python interpreter set in PATH variable. Now, try to run
this program as follows –
$ python test.py
This produces the following result –

Hello, Python!
Let us try another way to execute a Python script. Here is the modified test.py file –
Live Demo
#!/usr/bin/python
print “Hello, Python!”
We assume that you have Python interpreter available in /usr/bin directory. Now, try
to run this program as follows –

$ chmod +x test.py # This is to make file executable


$./test.py
This produces the following result –

Hello, Python!

Python Identifiers
A Python identifier is a name used to identify a variable, function, class, module or
other object. An identifier starts with a letter A to Z or a to z or an underscore (_)
followed by zero or more letters, underscores and digits (0 to 9).
Python does not allow punctuation characters such as @, $, and % within identifiers.
Python is a case sensitive programming language. Thus, Manpower and manpower
are two different identifiers in Python.

12
Here are naming conventions for Python identifiers –
Class names start with an uppercase letter. All other identifiers start with a lowercase
letter.
Starting an identifier with a single leading underscore indicates that the identifier is
private.
Starting an identifier with two leading underscores indicates a strongly private
identifier.
If the identifier also ends with two trailing underscores, the identifier is a language-
defined special name.

Reserved Words
The following list shows the Python keywords. These are reserved words and you
cannot use them as constant or variable or any other identifier names. All the Python
keywords contain lowercase letters only.

And exec not


assert finally or
break for pass
class from print
continue global raise
def if return
del import try
elseif in while
else is with
except lambda yield

Lines and Indentation


Python provides no braces to indicate blocks of code for class and function definitions
or flow control. Blocks of code are denoted by line indentation, which is rigidly
enforced.
The number of spaces in the indentation is variable, but all statements within the
block must be indented the same amount. For example –

13
if True:
print “True”
else:
print “False”
However, the following block generates an error –
if True:
print “Answer”
print “True”
else:
print “Answer”
print “False”
Thus, in Python all the continuous lines indented with same number of spaces would
form a block. The following example has various statement blocks –
Note – Do not try to understand the logic at this point of time. Just make sure you
understood various blocks even if they are without braces.

#!/usr/bin/python
import sys
try:
# open file stream
file = open(file_name, “w”)
except IOError:
print “There was an error writing to”, file_name
sys.exit()
print “Enter ‘”, file_finish,
print “’ When finished”
while file_text != file_finish:
file_text = raw_input(“Enter text: “)
if file_text == file_finish:
# close the file
file.close
break
file.write(file_text)
file.write(“\n”)

14
file.close()
file_name = raw_input(“Enter filename: “)
if len(file_name) == 0:
print “Next time please enter something”
sys.exit()
try:
file = open(file_name, “r”)
except IOError:
print “There was an error reading file”
sys.exit()
file_text = file.read()
file.close()
print file_text
Multi-Line Statements
Statements in Python typically end with a new line. Python does, however, allow the
use of the line continuation character (\) to denote that the line should continue. For
example –
total = item_one + \
item_two + \
item_three
Statements contained within the [], {}, or () brackets do not need to use the line
continuation character. For example –

days = [‘Monday’, ‘Tuesday’, ‘Wednesday’,


‘Thursday’, ‘Friday’]
Quotation in Python
Python accepts single (‘), double (“) and triple (‘’’ or “””) quotes to denote string
literals, as long as the same type of quote starts and ends the string.
The triple quotes are used to span the string across multiple lines. For example, all the
following are legal –

word = ‘word’
sentence = “This is a sentence.”
Paragraph = “””This is a paragraph. It is

15
made up of multiple lines and sentences.”””
Comments in Python
A hash sign (#) that is not inside a string literal begins a comment. All characters after
the # and up to the end of the physical line are part of the comment and the Python
interpreter ignores them.

Live Demo
#!/usr/bin/python

# First comment
print “Hello, Python!” # second comment
This produces the following result –

Hello, Python!
You can type a comment on the same line after a statement or expression –

name = “Madisetti” # This is again comment


You can comment multiple lines as follows –

# This is a comment.
# This is a comment, too.
# This is a comment, too.
# I said that already.
Following triple-quoted string is also ignored by Python interpreter and can be used as
a multiline comments:
‘’’
This is a multiline
comment.
‘’’
Using Blank Lines
A line containing only whitespace, possibly with a comment, is known as a blank line
and Python totally ignores it.

16
In an interactive interpreter session, you must enter an empty physical line to
terminate a multiline statement.

Waiting for the User


The following line of the program displays the prompt, the statement saying “Press
the enter key to exit”, and waits for the user to take action –

#!/usr/bin/python
raw_input(“\n\nPress the enter key to exit.”)
Here, “\n\n” is used to create two new lines before displaying the actual line. Once the
user presses the key, the program ends. This is a nice trick to keep a console window
open until the user is done with an application.
Multiple Statements on a Single Line
The semicolon ( ; ) allows multiple statements on the single line given that neither
statement starts a new code block. Here is a sample snip using the semicolon.
Import sys; x = ‘foo’; sys.stdout.write(x + ‘\n’)
Multiple Statement Groups as Suites
A group of individual statements, which make a single code block are called suites in
Python. Compound or complex statements, such as if, while, def, and class require a
header line and a suite.
Header lines begin the statement (with the keyword) and terminate with a colon ( : )
and are followed by one or more lines which make up the suite. For example –

if expression :
suite
elif expression :
suite
else :
suite
Command Line Arguments
Many programs can be run to provide you with some basic information about how
they should be run. Python enables you to do this with -h –
$ python -h
usage: python [option] … [-c cmd | -m mod | file | -] [arg] …

17
Options and arguments (and corresponding environment variables):
-c cmd : program passed in as string (terminates option list)
-d : debug output from parser (also PYTHONDEBUG=x)
-E : ignore environment variables (such as PYTHONPATH)
-h : print this help message and exit
You can also program your script in such a way that it should accept various options.
Command Line Arguments is an advanced topic and should be studied a bit later once
you have gone through rest of the Python concepts.
Python Lists
The list is a most versatile datatype available in Python which can be written as a list
of comma-separated values (items) between square brackets. Important thing about a
list is that items in a list need not be of the same type.

Creating a list is as simple as putting different comma-separated values between


square brackets. For example –

list1 = [‘physics’, ‘chemistry’, 1997, 2000];


list2 = [1, 2, 3, 4, 5 ];
list3 = [“a”, “b”, “c”, “d”]
Similar to string indices, list indices start at 0, and lists can be sliced, concatenated
and so on.
A tuple is a sequence of immutable Python objects. Tuples are sequences, just like
lists. The differences between tuples and lists are, the tuples cannot be changed unlike
lists and tuples use parentheses, whereas lists use square brackets.

Creating a tuple is as simple as putting different comma-separated values. Optionally


you can put these comma-separated values between parentheses also. For example –

tup1 = (‘physics’, ‘chemistry’, 1997, 2000);


tup2 = (1, 2, 3, 4, 5 );
tup3 = “a”, “b”, “c”, “d”;
The empty tuple is written as two parentheses containing nothing –

tup1 = ();

18
To write a tuple containing a single value you have to include a comma, even though
there is only one value –

tup1 = (50,);
Like string indices, tuple indices start at 0, and they can be sliced, concatenated, and
so on.
Accessing Values in Tuples
To access values in tuple, use the square brackets for slicing along with the index or
indices to obtain value available at that index. For example –
Live Demo
#!/usr/bin/python

tup1 = (‘physics’, ‘chemistry’, 1997, 2000);


tup2 = (1, 2, 3, 4, 5, 6, 7 );
print “tup1[0]: “, tup1[0];
print “tup2[1:5]: “, tup2[1:5];
When the above code is executed, it produces the following result –

tup1[0]: physics
tup2[1:5]: [2, 3, 4, 5]
Updating Tuples

Accessing Values in Dictionary


To access dictionary elements, you can use the familiar square brackets along with the
key to obtain its value. Following is a simple example –

Live Demo
#!/usr/bin/python

dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}


print “dict[‘Name’]: “, dict[‘Name’]
print “dict[‘Age’]: “, dict[‘Age’]
When the above code is executed, it produces the following result –

19
dict[‘Name’]: Zara
dict[‘Age’]: 7
If we attempt to access a data item with a key, which is not part of the dictionary, we
get an error as follows –

Live Demo
#!/usr/bin/python

dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}


print “dict[‘Alice’]: “, dict[‘Alice’]
When the above code is executed, it produces the following result –

dict[‘Alice’]:
Traceback (most recent call last):
File “test.py”, line 4, in <module>
print “dict[‘Alice’]: “, dict[‘Alice’];
KeyError: ‘Alice’
Updating Dictionary
You can update a dictionary by adding a new entry or a key-value pair, modifying an
existing entry, or deleting an existing entry as shown below in the simple example –

Live Demo
#!/usr/bin/python

dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}


dict[‘Age’] = 8; # update existing entry
dict[‘School’] = “DPS School”; # Add new entry

print “dict[‘Age’]: “, dict[‘Age’]


print “dict[‘School’]: “, dict[‘School’]
When the above code is executed, it produces the following result –

dict[‘Age’]: 8
dict[‘School’]: DPS School

20
Delete Dictionary Elements
You can either remove individual dictionary elements or clear the entire contents of a
dictionary. You can also delete entire dictionary in a single operation.

To explicitly remove an entire dictionary, just use the del statement. Following is a
simple example –

Live Demo
#!/usr/bin/python

dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}


del dict[‘Name’]; # remove entry with key ‘Name’
dict.clear(); # remove all entries in dict
del dict ; # delete entire dictionary

print “dict[‘Age’]: “, dict[‘Age’]


print “dict[‘School’]: “, dict[‘School’]
This produces the following result. Note that an exception is raised because after del
dict dictionary does not exist any more –

dict[‘Age’]:
Traceback (most recent call last):
File “test.py”, line 8, in <module>
print “dict[‘Age’]: “, dict[‘Age’];
TypeError: ‘type’ object is unsubscriptable
Note – del() method is discussed in subsequent section.

Properties of Dictionary Keys


Dictionary values have no restrictions. They can be any arbitrary Python object, either
standard objects or user-defined objects. However, same is not true for the keys.

There are two important points to remember about dictionary keys –

21
More than one entry per key not allowed. Which means no duplicate key is
allowed. When duplicate keys encountered during assignment, the last assignment
wins. For example –

Live Demo
#!/usr/bin/python

dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Name’: ‘Manni’}


print “dict[‘Name’]: “, dict[‘Name’]
When the above code is executed, it produces the following result –

dict[‘Name’]: Manni
(b) Keys must be immutable. Which means you can use strings, numbers or tuples as
dictionary keys but something like [‘key’] is not allowed. Following is a simple
example –

Live Demo
#!/usr/bin/python

dict = {[‘Name’]: ‘Zara’, ‘Age’: 7}


print “dict[‘Name’]: “, dict[‘Name’]
When the above code is executed, it produces the following result –

Traceback (most recent call last):


File “test.py”, line 3, in <module>
dict = {[‘Name’]: ‘Zara’, ‘Age’: 7};
TypeError: unhashable type: ‘list’
Tuples are immutable which means you cannot update or change the values of tuple
elements. You are able to take portions of existing tuples to create new tuples as the
following example demonstrates –
Live Demo
#!/usr/bin/python

tup1 = (12, 34.56);

22
tup2 = (‘abc’, ‘xyz’);

# Following action is not valid for tuples


# tup1[0] = 100;

# So let’s create a new tuple as follows


tup3 = tup1 + tup2;
print tup3;
When the above code is executed, it produces the following result –

(12, 34.56, ‘abc’, ‘xyz’)


Delete Tuple Elements
Removing individual tuple elements is not possible. There is, of course, nothing
wrong with putting together another tuple with the undesired elements discarded.

To explicitly remove an entire tuple, just use the del statement. For example –

Live Demo
#!/usr/bin/python
tup = (‘physics’, ‘chemistry’, 1997, 2000);
print tup;
del tup;
print “After deleting tup : “;
print tup;
This produces the following result. Note an exception raised, this is because after del
tup tuple does not exist any more –
(‘physics’, ‘chemistry’, 1997, 2000)
After deleting tup :
Traceback (most recent call last):
File “test.py”, line 9, in <module>
print tup;
NameError: name ‘tup’ is not defined
3.3.2 DJANGO

23
Django is a high-level Python Web framework that encourages rapid development
and clean, pragmatic design. Built by experienced developers, it takes care of much of
the hassle of Web development, so you can focus on writing your app without
needing to reinvent the wheel. It’s free and open source.

Django’s primary goal is to ease the creation of complex, database-driven websites.


Django emphasizes reusabilityand “pluggability” of components, rapid development,
and the principle of don’t repeat yourself. Python is used throughout, even for settings
files and data models.

fig(1). Django Architecture

Django also provides an optional administrative create, read, update and


delete interface that is generated dynamically through introspection and configured
via admin models

24
fig(2). Model View Template

Create a Project

Whether you are on Windows or Linux, just get a terminal or a cmd prompt and
navigate to the place you want your project to be created, then use this code –

$ 25jango-admin startproject myproject

This will create a “myproject” folder with the following structure –

myproject/

manage.py

myproject/

__init__.py

settings.py

urls.py

wsgi.py

25
The Project Structure
The “myproject” folder is just your project container, it actually contains two
elements –
manage.py – This file is kind of your project local 26jango-admin for interacting with
your project via command line (start the development server, sync db…). To get a full
list of command accessible via manage.py you can use the code –
$ python manage.py help
The “myproject” subfolder – This folder is the actual python package of your project.
It contains four files –
__init__.py – Just for python, treat this folder as package.
Settings.py – As the name indicates, your project settings.
Urls.py – All links of your project and the function to call. A kind of ToC of your
project.
Wsgi.py – If you need to deploy your project over WSGI.
Setting Up Your Project
Your project is set up in the subfolder myproject/settings.py. Following are some
important options you might need to set –

DEBUG = True
This option lets you set if your project is in debug mode or not. Debug mode lets you
get more information about your project’s error. Never set it to ‘True’ for a live
project. However, this has to be set to ‘True’ if you want the Django light server to
serve static files. Do it only in the development mode.

DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.sqlite3’,
‘NAME’: ‘database.sql’,
‘USER’: ‘’,
‘PASSWORD’: ‘’,
‘HOST’: ‘’,
‘PORT’: ‘’,
}
}

26
Database is set in the ‘Database’ dictionary. The example above is for SQLite engine.
As stated earlier, Django also supports –

MySQL (27jango.db.backends.mysql)
PostGreSQL (27jango.db.backends.postgresql_psycopg2)
Oracle (27jango.db.backends.oracle) and NoSQL DB
MongoDB (27jango_mongodb_engine)
Before setting any new engine, make sure you have the correct db driver installed.

You can also set others options like: TIME_ZONE, LANGUAGE_CODE,


TEMPLATE…

Now that your project is created and configured make sure it’s working –

$ python manage.py run server


You will get something like the following on running the above code –

Validating models…

0 errors found
September 03, 2015 – 11:41:50
Django version 1.6.11, using settings ‘myproject settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

A project is a sum of many applications. Every application has an objective and can
be reused into another project, like the contact form on a website can be an
application, and can be reused for others. See it as a module of your project.

Create an Application
We assume you are in your project folder. In our main “myproject” folder, the same
folder then manage.py –

$ python manage.py startapp myapp

27
You just created myapp application and like project, Django create a “myapp” folder
with the application structure –

myapp/
__init__.py
admin.py
models.py
tests.py
views.py
__init__.py – Just to make sure python handles this folder as a package.

Admin.py – This file helps you make the app modifiable in the admin interface.

Models.py – This is where all the application models are stored.

Tests.py – This is where your unit tests are.

Views.py – This is where your application views are.

Get the Project to Know About Your Application


At this stage we have our “myapp” application, now we need to register it with our
Django project “myproject”. To do so, update INSTALLED_APPS tuple in the
settings.py file of your project (add your app name) –

INSTALLED_APPS = (
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘myapp’,
)

28
Creating forms in Django, is really similar to creating a model. Here again, we just
need to inherit from Django class and the class attributes will be the form fields. Let’s
add a forms.py file in myapp folder to contain our app forms. We will create a login
form.

Myapp/forms.py

#-*- coding: utf-8 -*-


from 29jango import forms

class LoginForm(forms.Form):
user = forms.CharField(max_length = 100)
password = forms.CharField(widget = forms.PasswordInput())
As seen above, the field type can take “widget” argument for html rendering; in our
case, we want the password to be hidden, not displayed. Many others widget are
present in Django: DateInput for dates, CheckboxInput for checkboxes, etc.

Using Form in a View


There are two kinds of HTTP requests, GET and POST. In Django, the request object
passed as parameter to your view has an attribute called “method” where the type of
the request is set, and all data passed via POST can be accessed via the request.POST
dictionary.

Let’s create a login view in our myapp/views.py –

#-*- coding: utf-8 -*-


from myapp.forms import LoginForm

def login(request):
username = “not logged in”

if request.method == “POST”:
#Get the posted form
MyLoginForm = LoginForm(request.POST)

29
if MyLoginForm.is_valid():
username = MyLoginForm.cleaned_data[‘username’]
else:
MyLoginForm = Loginform()

return render(request, ‘loggedin.html’, {“username” : username})


The view will display the result of the login form posted through the loggedin.html.
To test it, we will first need the login form template. Let’s call it login.html.

<html>
<body>

<form name = “form” action = “{% url “myapp.views.login” %}”


method = “POST” >{% csrf_token %}

<div style = “max-width:470px;”>


<center>
<input type = “text” style = “margin-left:20%;”
placeholder = “Identifiant” name = “username” />
</center>
</div>

<br>

<div style = “max-width:470px;”>


<center>
<input type = “password” style = “margin-left:20%;”
placeholder = “password” name = “password” />
</center>
</div>

<br>

30
<div style = “max-width:470px;”>
<center>

<button style = “border:0px; background-color:#4285F4; margin-top:8%;


height:35px; width:80%;margin-left:19%;” type = “submit”
value = “Login” >
<strong>Login</strong>
</button>

</center>
</div>

</form>

</body>
</html>
The template will display a login form and post the result to our login view above.
You have probably noticed the tag in the template, which is just to prevent Cross-site
Request Forgery (CSRF) attack on your site.

{% csrf_token %}
Once we have the login template, we need the loggedin.html template that will be
rendered after form treatment.

<html>

<body>
You are : <strong>{{username}}</strong>
</body>

</html>
Now, we just need our pair of URLs to get started: myapp/urls.py

from 31jango.conf.urls import patterns, url

31
from 32jango.views.generic import TemplateView

urlpatterns = patterns(‘myapp.views’,
url(r’^connection/’,TemplateView.as_view(template_name = ‘login.html’)),
url(r’^login/’, ‘login’, name = ‘login’))
When accessing “/myapp/connection”, we will get the following login.html template
rendered –
Setting Up Sessions
In Django, enabling session is done in your project settings.py, by adding some lines
to the MIDDLEWARE_CLASSES and the INSTALLED_APPS options. This should
be done while creating the project, but it’s always good to know, so
MIDDLEWARE_CLASSES should have –

‘django.contrib.sessions.middleware.SessionMiddleware’
And INSTALLED_APPS should have –

‘django.contrib.sessions’
By default, Django saves session information in database (32jango_session table or
collection), but you can configure the engine to store information using other ways
like: in file or in cache.

When session is enabled, every request (first argument of any view in Django) has a
session (dict) attribute.

Let’s create a simple sample to see how to create and save sessions. We have built a
simple login system before (see Django form processing chapter and Django Cookies
Handling chapter). Let us save the username in a cookie so, if not signed out, when
accessing our login page you won’t see the login form. Basically, let’s make our login
system we used in Django Cookies handling more secure, by saving cookies server
side.
For this, first lets change our login view to save our username cookie server side –

def login(request):
username = ‘not logged in’

32
if request.method == ‘POST’:
MyLoginForm = LoginForm(request.POST)
if MyLoginForm.is_valid():
username = MyLoginForm.cleaned_data[‘username’]
request.session[‘username’] = username
else:
MyLoginForm = LoginForm()
return render(request, ‘loggedin.html’, {“username” : username}
Then let us create formView view for the login form, where we won’t display the
form if cookie is set –

def formview(request):
if request.session.has_key(‘username’):
username = request.session[‘username’]
return render(request, ‘loggedin.html’, {“username” : username})
else:
return render(request, ‘login.html’, {})
Now let us change the url.py file to change the url so it pairs with our new view –

from 33jango.conf.urls import patterns, url


from 33jango.views.generic import TemplateView

urlpatterns = patterns(‘myapp.views’,
url(r’^connection/’,’formView’, name = ‘loginform’),
url(r’^login/’, ‘login’, name = ‘login’))
When accessing /myapp/connection, you will get to see the following page

33
3.4 SYSTEM STUDY
3.4.1 FEASIBILITY STUDY

The feasibility of the project is analyzed in this phase and business proposal is
put forth with a very general plan for the project and some cost estimates. During
system analysis the feasibility study of the proposed system is to be carried out. This
is to ensure that the proposed system is not a burden to the company. For feasibility
analysis, some understanding of the major requirements for the system is essential.

Three key considerations involved in the feasibility analysis are,

ECONOMICAL FEASIBILITY

TECHNICAL FEASIBILITY

SOCIAL FEASIBILITY

ECONOMICAL FEASIBILITY

This study is carried out to check the economic impact that the system will have on
the organization. The amount of fund that the company can pour into the research and
development of the system is limited. The expenditures must be justified. Thus the
developed system as well within the budget and this was achieved because most of the
technologies used are freely available. Only the customized products had to be
purchased.

TECHNICAL FEASIBILITY

This study is carried out to check the technical feasibility, that is, the technical
requirements of the system. Any system developed must not have a high demand on
the available technical resources. This will lead to high demands on the available
technical resources. This will lead to high demands being placed on the client. The
developed system must have a modest requirement, as only minimal or null changes
are required for implementing this system.

34
SOCIAL FEASIBILITY

The aspect of study is to check the level of acceptance of the system by the
user. This includes the process of training the user to use the system efficiently. The
user must not feel threatened by the system, instead must accept it as a necessity. The
level of acceptance by the users solely depends on the methods that are employed to
educate the user about the system and to make him familiar with it. His level of
confidence must be raised so that he is also able to make some constructive criticism,
which is welcomed, as he is the final user of the system.

3.5 REQUIREMENT ANALYSIS

The project involved analyzing the design of few applications so as


to make the application more users friendly. To do so, it was really
important to keep the navigations from one screen to the other well
ordered and at the same time reducing the amount of typing the user
needs to do. In order to make the application more accessible, the browser
version had to be chosen so that it is compatible with most of the
Browsers.

3.5.1 REQUIREMENT SPECIFICATION

Functional Requirements

 Graphical User interface with the User.


Software Requirements

For developing the application the following are the Software


Requirements:

1. Python
2. Django
3.
Operating Systems supported

35
1. Windows 7
2. Windows XP
3. Windows 8
Technologies and Languages used to Develop
1. Python
Debugger and Emulator
 Any Browser (Particularly Chrome)
Hardware Requirements

For developing the application the following are the Hardware


Requirements:

 Processor: Pentium IV or higher


 RAM: 256 MB
 Space on Hard Disk: minimum 512MB

3.5.2 SOFTWARE REQUIREMENTS:

Operating system : Windows 10 .


Coding Language : Python.
Front-End : Python.
Designing : Html , CSS , Java script.
Data Base : MySQL.

3.5.3 HARDWARE REQUIREMENTS:


System : Intel i5
Hard Disk : 40 GB.
Monitor : 14’ Colour Monitor.
Mouse : Optical Mouse.
Ram : 8GB

36
CHAPTER – 4

37
SYSTEM DESIGN

4.1 SYSTEM ARCHITECTURE:

Fig(3). System Architecture

4.2 DATA FLOW DIAGRAM:

1. The DFD is also called as bubble chart. It is a simple graphical formalism that
can be used to represent a system in terms of input data to the system, various
processing carried out on this data, and the output data is generated by this system.

2. The data flow diagram (DFD) is one of the most important modeling tools. It
is used to model the system components. These components are the system process,
the data used by the process, an external entity that interacts with the system and the
information flows in the system.

3. DFD shows how the information moves through the system and how it is
modified by a series of transformations. It is a graphical technique that depicts
information flow and the transformations that are applied as data moves from input to
output.

38
4. DFD is also known as bubble chart. A DFD may be used to represent a system
at any level of abstraction. DFD may be partitioned into levels that represent
increasing information flow and functional detail

fig(4). Data Flow Diagram

4.3 UML DIAGRAMS

UML stands for Unified Modeling Language. UML is a standardized general-purpose


modeling language in the field of object-oriented software engineering. The standard
is managed, and was created by, the Object Management Group.

39
The goal is for UML to become a common language for creating models of object
oriented computer software. In its current form UML is comprised of two major
components: a Meta-model and a notation. In the future, some form of method or
process may also be added to; or associated with, UML.

The Unified Modeling Language is a standard language for specifying,


Visualization, Constructing and documenting the artifacts of software system, as well
as for business modeling and other non-software systems.

The UML represents a collection of best engineering practices that have proven
successful in the modeling of large and complex systems.

The UML is a very important part of developing objects oriented software and the
software development process. The UML uses mostly graphical notations to express
the design of software projects.

GOALS: The Primary goals in the design of the UML are as follows:

1. Provide users a ready-to-use, expressive visual modeling Language so that


they can develop and exchange meaningful models.

2. Provide extendibility and specialization mechanisms to extend the core


concepts.

3. Be independent of particular programming languages and development


process.

4. Provide a formal basis for understanding the modeling language.

5. Encourage the growth of OO tools market.

6. Support higher level development concepts such as collaborations,


frameworks, patterns and components.

7. Integrate best practices.

40
4.3.1 USE CASE DIAGRAM:

A use case diagram in the Unified Modeling Language (UML) is a type of behavioral
diagram defined by and created from a Use-case analysis. Its purpose is to present a
graphical overview of the functionality provided by a system in terms of actors, their
goals (represented as use cases), and any dependencies between those use cases. The
main purpose of a use case diagram is to show what system functions are performed
for which actor. Roles of the actors in the system can be depicted.

Fig(5). Use Case Diagram

41
4.3.2 CLASS DIAGRAM:

In software engineering, a class diagram in the Unified Modeling Language (UML) is


a type of static structure diagram that describes the structure of a system by showing
the system’s classes, their attributes, operations (or methods), and the relationships
among the classes. It explains which class contains information

Fig(6). Class Diagram

42
4.3.3 SEQUENCE DIAGRAM:

A sequence diagram in Unified Modeling Language (UML) is a kind of interaction


diagram that shows how processes operate with one another and in what order. It is a
construct of a Message Sequence Chart. Sequence diagrams are sometimes called
event diagrams, event scenarios, and timing diagrams.

Fig(7). Sequence Diagram

43
4.3.4 ACTIVITY DIAGRAM:

Activity diagrams are graphical representations of workflows of stepwise activities


and actions with support for choice, iteration and concurrency. In the Unified
Modeling Language, activity diagrams can be used to describe the business and
operational step-by-step workflows of components in a system. An activity diagram
shows the overall flow of control

Fig(8). Activity Diagram

44
CHAPTER – 5

45
IMPLEMENTATION

5.1 MODULES:

Doctor.

Patient.

Admin

Machine learning

5.2 MODULES DESCRIPTION:

5.2.1 Doctor:

The Doctor can register the first. While registering he required a valid doctor email
and mobile for further communications. Once the doctor registers, then the admin can
activate the customer. Once the admin activates the customer then the customer can
login into our system. After login he can see the view-patient data. based on patient
symptoms, the doctor will give the precautions and he will give the doctor treatment.

5.2.2 Patient:

The Doctor can register the first. While registering he required a valid patient email
and mobile for further communications. Once the patient registers, then the admin can
activate the patient. Once the admin activates the patient then the patient can login
into our system. After login he can provide symptoms. based on patient symptoms,
the doctor will give the precautions and he will give the doctor treatment.

5.2.3 Admin:

Admin can login with his credentials. Once he logs in he can activate the doctors. The
activated user only login in our applications. Once he logs in he can activate the
patients. . The admin can add new data to the dataset. So this data user can perform
the testing process.admin can get predictions svm algorithm and also get the
prediction from the decision tree.

46
5.2.4 Machine learning:

Machine learning refers to the computer’s acquisition of a kind of ability to make


predictive judgments and make the best decisions by analyzing and learning a large
number of existing data. The representation algorithms include deep learning,
artificial neural networks, decision trees, enhancement algorithms and so on. The key
way for computers to acquire artificial intelligence is machine learning. Nowadays,
machine learning plays an important role in various fields of artificial intelligence.
Whether in aspects of internet search, biometric identification, auto driving, Mars
robot, or in American presidential election, military decision assistants and so on,
basically, as long as there is a need for data analysis, machine learning can be used to
play a role.

5.3 Source Code

url.py:

from django.contrib import admin


from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from doctor import views as doctor
from patient import views as patient
from Medicalcare import views as medical
from hsp import views as hsp

urlpatterns = [
path('admin/', admin.site.urls),
path('index/', doctor.index, name='index'),
path('logout/',medical.logout,name='logout'),
path('admin1/', medical.adminlogin, name='admin1'),
path('adminloginentered/', medical.adminloginentered, name='adminloginentered'),
path('doctordetails/', medical.doctordetails, name='doctordetails'),
path('patientdetails/', medical.patientdetails, name='patientdetails'),

47
path('activatedoctor/',medical.activatedoctor,name='activatedoctor'),
path('activatepatient/',medical.activatepatient,name='activatepatient'),
path('storecsvdata/',medical.storecsvdata,name='storecsvdata'),
path('svm/',medical.svm,name='svm'),
path('decision/',medical.decision,name='decision'),
path('hsplogin/', hsp.hsplogin, name='hsplogin'),
path('hsploginentered/', hsp.hsploginentered, name='hsploginentered'),
path('uploadpatientdata/', hsp.uploadpatientdata,name='uploadpatientdata'),
path('viewpatientdata/', hsp.viewpatientdata,name='viewpatientdata'),

path('doctorlogin/',doctor.doctorlogin,name='doctorlogin'),
path('doctorregister/',doctor.doctorregister,name='doctorregister'),
path('doctorlogincheck/',doctor.doctorlogincheck,name='doctorlogincheck'),
path('doctorviewpatientdata/',doctor.doctorviewpatientdata,name='doctorviewpatientd
ata'),
path('addtreatment/',doctor.addtreatment,name='addtreatment'),
path('patientlogin/',patient.patientlogin,name='patientlogin'),
path('patientregister/',patient.patientregister,name='patientregister'),
path('patientlogincheck/',patient.patientlogincheck,name='patientlogincheck'),
path('treatment/',patient.treatment,name='treatment'),

path('patienttreatmentresult/',patient.patienttreatmentresult,name='patienttreatmentres
ult'),

]
if settings.DEBUG:
urlpatterns +=
static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)

48
views.py:
from collections import defaultdict
from io import TextIOWrapper
import csv
from django.shortcuts import render
from django.http import HttpResponse
from patient.models import patientModel
from patient.forms import patientForm
from doctor.models import doctorModel, storedatamodel
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import classification_report, confusion_matrix
import pandas as pd
from django_pandas.io import read_frame
from sklearn.naive_bayes import GaussianNB
from sklearn import metrics
from sklearn import datasets

def logout(request):
return render(request, "index.html")

def adminlogin(request):
return render(request, "admin/adminlogin.html")

def adminloginentered(request):
if request.method == 'POST':
uname=request.POST['uname']
passwd=request.POST['upasswd']
if uname =='admin' and passwd=='admin':
return render(request,"admin/adminloginentered.html")
else:
return HttpResponse("invalied credentials")
return render(request, "admin/adminloginentered.html")

49
def doctordetails(request):
qs=doctorModel.objects.all()
return render(request,'admin/doctordetails.html',{"object":qs})

def patientdetails(request):
qs=patientModel.objects.all()
return render(request,'admin/patientdetails.html',{"object":qs})

def activatedoctor(request):
if request.method == 'GET':
uname = request.GET.get('pid')
print(uname)
status = 'Activated'
print("pid=", uname, "status=", status)
doctorModel.objects.filter(id=uname).update(status=status)
qs = doctorModel.objects.all()
return render(request,"admin/doctordetails.html", {"object": qs})

def activatepatient(request):
if request.method == 'GET':
uname = request.GET.get('pid')
print(uname)
status = 'Activated'
print("pid=", uname, "status=", status)
patientModel.objects.filter(id=uname).update(status=status)
qs = patientModel.objects.all()
return render(request, 'admin/patientdetails.html', {"object": qs})
def storecsvdata(request):
if request.method == 'POST':
name = request.POST.get('name')
csvfile =TextIOWrapper( request.FILES['file'])
columns = defaultdict(list)

storecsvdata =csv.DictReader(csvfile)

50
for row1 in storecsvdata:
Pregnancies = row1["Pregnancies"]
Glucose = row1["Glucose"]
BloodPressure = row1["BloodPressure"]
SkinThickness = row1["SkinThickness"]
Insulin = row1["Insulin"]
DiabetesPedigreeFunction = row1["DiabetesPedigreeFunction"]
Age = row1["Age"]
BMI = row1["BMI"]
Outcome = row1["Outcome"]
storedatamodel.objects.create(Pregnancies=Pregnancies, Glucose=Glucose,
BloodPressure=BloodPressure,
SkinThickness=SkinThickness,
Insulin=Insulin,BMI=BMI,DiabetesPedigreeFunction=DiabetesPedigreeFunction,Age
=Age,Outcome=Outcome)
print("Name is ",csvfile)
return HttpResponse('CSV file successful uploaded')
else:
return render(request, 'admin/storecsvdata.html', {})

doctors.html:
{% extends 'base.html' %}
{% load static %}
{% block contents %}
<div class="main-banner header-text" id="top">
<div class="Modern-Slider">
<!-- Item -->
<div class="item">
<!--<div class="img-fill">-->
<img src="{% static 'images/home.jpg' %}" alt="">
<div class="text-content">
<h3 style="color:blue"><center>Doctor REGISTRATION</center></h3>
<center> <h4><form action="/doctorregister/" method="POST">

51
{% csrf_token %}
<table>
<tr><td style="color:blue">doctor
name</td><td>{{form.name}}</td></tr>
<tr><td
style="color:blue">Password</td><td>{{form.passwd}}</td></tr>
<tr><td
style="color:blue">confirmPassword</td><td>{{form.cwpasswd}}</td></tr>
<tr><td
style="color:blue">Email</td><td>{{form.email}}</td></tr>
<tr><td
style="color:blue">Mobile</td><td>{{form.mobileno}}</td></tr>
<tr><td
style="color:blue">specialization</td><td>{{form.specialization}}</td></tr>
<tr><td></td><td>{{form.status}}</td></tr>
</table>
<input type="submit" value="submit">
</form></h4></center>
{% if messages %}
{% for message in messages %}
<font color='darkred'> {{ message }}</font>
{% endfor %}
{% endif %}
</div>
</div>
</div>
{% endblock %}

52
5.4 INPUT AND OUTPUT DESIGN
5.4.1 INPUT DESIGN

The input design is the link between the information system and the user.
It comprises the developing specification and procedures for data preparation and
those steps are necessary to put transaction data in to a usable form for processing can
be achieved by inspecting the computer to read data from a written or printed
document or it can occur by having people keying the data directly into the system.
The design of input focuses on controlling the amount of input required, controlling
the errors, avoiding delay, avoiding extra steps and keeping the process simple. The
input is designed in such a way so that it provides security and ease of use with
retaining the privacy. Input Design considered the following things:

What data should be given as input?

How the data should be arranged or coded?

The dialog to guide the operating personnel in providing input.

Methods for preparing input validations and steps to follow when error occur.

OBJECTIVES

1.Input Design is the process of converting a user-oriented description of


the input into a computer-based system. This design is important to avoid errors in the
data input process and show the correct direction to the management for getting
correct information from the computerized system.

2. It is achieved by creating user-friendly screens for the data entry to


handle large volume of data. The goal of designing input is to make data entry easier
and to be free from errors. The data entry screen is designed in such a way that all the
data manipulates can be performed. It also provides record viewing facilities.

3.When the data is entered it will check for its validity. Data can be
entered with the help of screens. Appropriate messages are provided as when needed
so that the user will not be in maize of instant. Thus the objective of input design is to
create an input layout that is easy to follow

53
5.4.2 OUTPUT DESIGN

A quality output is one, which meets the requirements of the end user
and presents the information clearly. In any system results of processing are
communicated to the users and to other system through outputs. In output design it is
determined how the information is to be displaced for immediate need and also the
hard copy output. It is the most important and direct source information to the user.
Efficient and intelligent output design improves the system’s relationship to help user
decision-making.

1. Designing computer output should proceed in an organized, well thought out


manner; the right output must be developed while ensuring that each output element is
designed so that people will find the system can use easily and effectively. When
analysis design computer output, they should Identify the specific output that is
needed to meet the requirements.

2.Select methods for presenting information.

3.Create document, report, or other formats that contain information produced by the
system.

The output form of an information system should accomplish one or more of the
following objectives.

Convey information about past activities, current status or projections of the

Future.

Signal important events, opportunities, problems, or warnings.

Trigger an action.

Confirm an action.

54
CHAPTER – 6

55
Results :

Doctor

Fig(9). Registration Page

Fig(10). Doctor Page

56
Fig(11). View Patient Data

Fig(12). Add Treatment

57
Patient

Fig(13). Registration Page

Fig(14). Patient Page

Fig(15). Treatment

58
Hospital

Fig(16). Hospital Page

Fig(17). Upload Patient Data

Fig(18). View Patient Data

59
Admin

Fig(19). Admin Page

Fig(20). Patient Data

Fig(21). Doctor Data

60
Fig(22). Store Data

Fig(23). Support Vector Machine

Fig(24). Decision Tree

61
CHAPTER – 7

62
SYSTEM TESTING

The purpose of testing is to discover errors. Testing is the process of trying to


discover every conceivable fault or weakness in a work product. It provides a way to
check the functionality of components, sub assemblies, assemblies and/or a finished
product It is the process of exercising software with the intent of ensuring that the
Software system meets its requirements and user expectations and does not fail in an
unacceptable manner. There are various types of test. Each test type addresses a
specific testing requirement.

TYPES OF TESTS

7.1 Unit testing

Unit testing involves the design of test cases that validate that the
internal program logic is functioning properly, and that program inputs produce valid
outputs. All decision branches and internal code flow should be validated. It is the
testing of individual software units of the application .it is done after the completion
of an individual unit before integration. This is a structural testing, that relies on
knowledge of its construction and is invasive. Unit tests perform basic tests at
component level and test a specific business process, application, and/or system
configuration. Unit tests ensure that each unique path of a business process performs
accurately to the documented specifications and contains clearly defined inputs and
expected results.

7.2 Integration testing

Integration tests are designed to test integrated software


components to determine if they actually run as one program. Testing is event driven
and is more concerned with the basic outcome of screens or fields. Integration tests
demonstrate that although the components were individually satisfaction, as shown by
successfully unit testing, the combination of components is correct and consistent.
Integration testing is specifically aimed at exposing the problems that arise from the
combination of components.

63
7.3 Functional test

Functional tests provide systematic demonstrations that functions tested


are available as specified by the business and technical requirements, system
documentation, and user manuals.

Functional testing is centered on the following items:

Valid Input : identified classes of valid input must be accepted.

Invalid Input : identified classes of invalid input must be rejected.

Functions : identified functions must be exercised.

Output : identified classes of application outputs must beexercised.

Systems/Procedures : interfacing systems or procedures must be invoked.

Organization and preparation of functional tests is focused on


requirements, key functions, or special test cases. In addition, systematic coverage
pertaining to identify Business process flows; data fields, predefined processes, and
successive processes must be considered for testing. Before functional testing is
complete, additional tests are identified and the effective value of current tests is
determined.

7.4 System Test

System testing ensures that the entire integrated software system meets
requirements. It tests a configuration to ensure known and predictable results. An
example of system testing is the configuration oriented system integration test.
System testing is based on process descriptions and flows, emphasizing pre-driven
process links and integration points.

7.5 White Box Testing

White Box Testing is a testing in which in which the software tester


has knowledge of the inner workings, structure and language of the software, or at
least its purpose. It is purpose. It is used to test areas that cannot be reached from a
black box level

64
7.6 Black Box Testing

Black Box Testing is testing the software without any knowledge of


the inner workings, structure or language of the module being tested. Black box tests,
as most other kinds of tests, must be written from a definitive source document, such
as specification or requirements document, such as specification or requirements
document. It is a testing in which the software under test is treated, as a black box
.you cannot “see” into it. The test provides inputs and responds to outputs without
considering how the software works.

Unit Testing

Unit testing is usually conducted as part of a combined code and unit


test phase of the software lifecycle, although it is not uncommon for coding and unit
testing to be conducted as two distinct phases.

Test strategy and approach

Field testing will be performed manually and functional tests will be


written in detail.

Test objectives

All field entries must work properly.

Pages must be activated from the identified link.

The entry screen, messages and responses must not be delayed.

Features to be tested

Verify that the entries are of the correct format

No duplicate entries should be allowed

All links should take the user to the correct page.

65
Integration Testing

Software integration testing is the incremental integration testing of two


or more integrated software components on a single platform to produce failures
caused by interface defects.

The task of the integration test is to check that components or software applications,
e.g. components in a software system or – one step up – software applications at the
company level – interact without error.

Test Results: All the test cases mentioned above passed successfully. No defects
encountered.

Acceptance Testing

User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional
requirements.

Test Results: All the test cases mentioned above passed successfully. No defects
encountered.

66
Sample Test Cases

Remarks(IF
S.no Test Case Excepted Result Result
Fails)
If already Doctor
If Doctor registration
1. Doctor Register Pass mail exists then it
successfully.
fails.

If the Doctor name and Un-registered


+2. Doctor Login password is correct then it Pass doctors will not be
will be a valid page. logged in.

If already patient
If patient registration
3. Patient Register Pass mail exists then it
successfully.
fails.

If the patient name and Un-registered


4 patient login password is correct then it Pass patients will not be
will be a valid page logged in..

based on body id doctor can’t provide the


5. hsp login will give body report to Pass body report to
forensic forensic.

can’t get the patient


6. after doctor login display the patient data Pass
data.

doctor add the treatment won’t add


doctor add
7. based on the patient Pass treatment to
treatment
symptoms patinet..

Admin can login with his Invalid login details


8. Admin login login credential. If success pass will not allowed
he get his home page here

If the patient did


Admin can activate Admin can activate the
9. Pass not find it then it
the register patients register patient id
wouldn't login

If the doctor did not


Admin can activate Admin can activate the
Pass find it then it
10. the register doctors register user id
wouldn't login.

67
CHAPTER – 8

68
CONCLUSION

8.1 CONCLUSION

This article reviews the main methods of machine learning, and summarizes several
representative applications after understanding the history of machine learning in the
medical field and its current application. The typical ideas and algorithms are
summarized. At the same time, the improvement method based on machine learning
in the process of visiting is proposed. However, this does not mean that ML is perfect.
Whether in terms of technology, ethic or law, it has certain problems. The solution of
these problems requires technicians and legal personnel. Working together, and how
to strike a balance between manpower and machine is also a problem that everyone of
us must face.

8.2 FUTURE ENHANCEMENT


Humans are visual beings and play is one of the most important aspects
of our lives. As children the most important way for us to learn was to
play. Interaction with the surroundings allowed us to gain further
understanding of the world and provided us with the much-needed
experience. The current educational system is limited and for interactive
disciplines such as medicine this can be a hindrance. Medicine can be
visualized as an art form and future clinicians are the artist. These
individuals require certain skills to fulfill the need for an ever-evolving
profession. Early in medical school, various concepts are taught to
students without them ever experiencing these concepts in real life. So
game-like technologies such as VR and AR could enhance and enrich the
learning experience for future medical and health-related disciplines.
Medical students could be provided with and taught novel and
complicated surgical procedures, or learn about anatomy through AR
without ever needing to interact or involve real patients at an early stage
or without ever needing to perform an autopsy on a real corpse. These
students will of course be interacting with real patients in their future
careers, but the goal would be to initiate the training at an earlier stage
and lowering the cost of training at a later stage.

69
CHAPTER – 9

70
BIBILOGRAPHY

[1] G. Eason, B. Noble, and I.N. Sneddon, “On certain integrals of Lipschitz-Hankel
type involving products of Bessel functions,” Phil. Trans. Roy. Soc. London, vol.
A247, pp. 529-551, April 1955. (references)

[2] Jiang M, Zhang S, Huang J, et al. Scalable histopathological image analysis via
supervised hashing with multiple features[J]. Medical Image Analysis, 2016, 34:3-12.

[3] Joanna J K, Pawel K . Automatic Classification of Specific Melanocytic Lesions


Using Artificial Intelligence[J]. BioMed Research International, 2016, 2016:1-17.

[4] Lu-Cheng, Zhu,Yun-Liang, Ye,Wen-Hua, Luo,Meng, Su,Hang-Ping, Wei,Xue-


Bang, Zhang,Juan, Wei,Chang-Lin, Zou.A model to discriminate malignant from
benign thyroid nodules using artificial neural network.[J].PloS
one,2013,8(12):e82211.

[5] Huang W C , Chang C P . Automatic Nasal Tumor Detection by grey prediction


and Fuzzy C-Means clustering[C]// IEEE International Conference on Systems. IEEE,
2006.M. Young, The Technical Writer’s Handbook. Mill Valley, CA: University
Science, 1989.

[6] Sarraf S , Tofighi G . Classification of Alzheimer's Disease using fMRI Data and
Deep Learning Convolutional Neural Networks[J]. 2016.

[7] Dou Q , Chen H , Yu L , et al. Automatic Detection of Cerebral Microbleeds from


MR Images via 3D Convolutional Neural Networks[J]. IEEE Transactions on Medical
Imaging, 2016:1-1.

[8] Pang-ning Tan, Michael Steinbach, Vipin Kumar, Introduction to data mining,
Beijing: Posts & Telecom Press, 2011.

[9] Xue-Hu WANG, Study Liver Segmtation Method from CT Images based on
Deformation Optimization and Sparse Statistics[D]. Beijing Institute of Technology,
2015.

71
[10] Yu Q , Jiang T , Zhou A , et al. Computer-aided diagnosis of malignant or
benign thyroid nodes based on ultrasound images[J]. European Archives of Oto-
Rhino-Laryngology, 2017, 274(7):2891- 2897.

[11] Fei Liu, Jun-Ran Zhang, Hao Yang. Advances in medical images recoginition
based on deep learning[J]. Chinese Journal of Biomedical Engineering, 2018.

[12] Ke-Yang Zhao, Mu-Yue Yang, Jing-Yu Zhu, Ze-Qi Wang, Wei-Wei Shen.
Machine learning AIDS in tumor dignosis[J]. Tumor, 2018, 38(10): 987-991.

[13] Bin Huang, Feng Liao, Yu-Feng Ye. Advances in machine learning in image
analysis of nasopharyngeal carcinom[J]. International Journal of Medical Radiology,
2019(1).

[14] Li F , Tran L , Thung K H , et al. A Robust Deep Model for Improved


Classification of AD/MCI Patients[J]. IEEE Journal of Biomedical and Health
Informatics, 2015, 19(5):1-1.

72

You might also like