0% found this document useful (0 votes)
400 views136 pages

Fetal Health Classification PDF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
400 views136 pages

Fetal Health Classification PDF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 136

FETAL HEALTH ANALYSIS SYSTEM

USING ML
A PROJECT REPORT

Submitted by

SYED SOHAIL AHMED B [REGISTER NO:211419104287]

THARUN E [REGISTER NO:211419104292]

SHAM MELBIN S [REGISTER NO:211419104245]

in partial fulfillment for the award of the

degree of

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE AND ENGINEERING

PANIMALAR ENGINEERING COLLEGE


(An Autonomous Institution, Affiliated to Anna University, Chennai)

APRIL 2023

1
PANIMALAR ENGINEERING COLLEGE
(An Autonmous Institution, Affiliated to Anna University, Chennai)

BONAFIDE CERTIFICATE

Certified that this project report “FETAL HEALTH ANALYSIS SYSTEM


USING ML” is the bonafide work of “THARUN E (211419104292)
, SYED SOHAIL AHMED B (211419104287 ) AND SHAM
MELBIN S (211419104245 )”

who carried out the project work under my supervision.

SIGNATURE SIGNATURE

Dr. L. JABASHEELA, M.E., Ph.D., Dr. BALAJI, B.Tech, M.E, PhD,

HEAD OF THE DEPARTMENT ASSOCIATE PROFESSOR

DEPARTMENT OF CSE DEPARTMENT OF CSE,


PANIMALAR ENGINEERING COLLEGE, PANIMALAR ENGINEERING COLLEGE,
NASARATHPETTAI, NASARATHPETTAI,
POONAMALLEE, POONAMALLEE,
CHENNAI-600 123. CHENNAI-600 123.

Certified that the above candidate(s) was/ were examined in the End Semester
Project Viva-Voce Examination held on 10-04-2023

INTERNAL EXAMINER EXTERNAL EXAMINER

2
DECLARATION BY THE STUDENT

We, SYED SOHAIL AHMED B (211419104287 ) , THARUN E

(211419104292 ) AND SHAM MELBIN S (211419104245) hereby declare

that this project report titled “FETAL HEALTH ANALYSIS SYSTEM USING

ML”, under the guidance of Dr.BALAJI is the original work done by us and we have

not plagiarized or submitted to any other degree in any university by us.

SYED SOHAIL AHMED B

THARUN E

SHAM MELBIN S

3
ACKNOWLEDGEMENT

We would like to express our deep gratitude to our respected Secretary and
Correspondent Dr.P.CHINNADURAI, M.A., Ph.D. for his kind words and enthusiastic
motivation, which inspired us a lot in completing this project.

We express our sincere thanks to our beloved Directors Tmt.C.VIJAYARAJESWARI,


Dr.C.SAKTHI KUMAR,M.E.,Ph.D and Dr.SARANYASREE SAKTHI KUMAR
B.E.,M.B.A.,Ph.D., for providing us with the necessary facilities to undertake this project.

We also express our gratitude to our Principal Dr.K.Mani, M.E., Ph.D. who facilitated
us in completing the project.

We thank the Head of the CSE Department, Dr.L.JABASHEELA, M.E.,Ph.D., for the
support extended throughout the project.

We would like to thank our Project Guide Dr. S. Balaji B. Tech, M. E, PhD, Associate
professor and all the faculty members of the Department of CSE for their advice and
encouragement for the successful completion of the project.

THARUN E

SYED SOHAIL AHMED B

SHAM MELBIN S

4
ABSTRACT:

Health complications during the gestation period have evolved as a global issue.
These complications sometimes result in the mortality of the fetus, which is more
prevalent in developing and underdeveloped countries. The genesis of machine learning
(ML) algorithms in the healthcare domain have brought remarkable progress in disease
diagnosis, treatment, and prognosis. Around 800 women die every day due to pregnancy
and childbirth-related issues. Maternal health and fetal health are closely associated with
each other because every year approximately 3 million newborn babies die. So there is a
need for proper care including the prediction of risk levels before, during and after the
delivery for the safety of both mother and child. Data mining is a commonly used
technique for processing enormous data. Researchers apply several data mining and
machine learning techniques to analyse huge complex data, helping health care
professionals to predict fetal health. Different algorithms are compared and the best
model is used for predicting the fetal health.

5
TABLE OF CONTENTS

SL.NO TITLE PAGE.NO

TITLE PAGE i

BONAFIDE CERTIFICATE ii

DECLARATION BY THE STUDENT iii

ACKNOWLEDGEMENTS iv

ABSTRACT v

1 EXISTING SYSTEM 10

1.1 DRAWBACKS 11

PROPOSED SYSTEM 12

2 2.1 ADVANTAGES 13

3 INTRODUCTION 14

3.1 DATA SCIENCE 15

3.2 ARTIFICIAL INTELLIGENCE 16

4 MACHINE LEARNING 20

5 PREPARING DATASET 24

6 LITERATURE SURVEY 25

6
7 SYSTEM STUDY 30

8.1 OBJECTIVES 31

8.2 PROJECT GOAL 31

8.3 SCOPE OF THE PROJECT 32

8 FEASIBILITY STUDY 33

9 LIST OF MODULES 36

10 PROJECT REQUIREMENTS 38

10.1 FUNCTIONAL REQUIREMENTS 39

10.2NON-FUNCTIONAL 39

REQUIREMENTS

11 ENVIRONMENT REQUIREMENT 41

12 SOFTWARE DESCRIPTION 42

12.1 ANACONDA NAVIGATOR 43

12.2 JUPYTER NOTEBOOK 46

13 PYTHON 52

14 SYSTEM ARCHITECTURE 64

15 WORKFLOW DIAGRAM 66

16 USECASE DIAGRAM 68

17 CLASS DIAGRAM 70

18 ACTIVITY DIAGRAM 72

7
19 SEQUENCE DIAGRAM 74

20 ER – DIAGRAM 76

21 MODULE DESCRIPTION 78

22.1 MODULE DIAGRAM 83

22.2 MODULE GIVEN INPUT EXPECTED 89

OUTPUT

22 DEPLOYMENT 93

23 HTML 101

24 CSS 106

26 CONCLUSION 116

27 FUTURE WORK 117

8
LIST OF FIGURES

SL.NO TITLE PAGE.NO

01 SYSTEM ARCHITECTURE 64

02 WORKFLOW DIAGRAM 66

03 USECASE DIAGRAM 68

04 CLASS DIAGRAM 70

05 ACTIVITY DIAGRAM 72

06 SEQUENCE DIAGRAM 74

07 ER – DIAGRAM 76

08 MODULE DIAGRAM 78

9
CHAPTER 1

EXISTING SYSTEM

10
1. Existing System:
Fetal development relies on a complex circulatory network. Accurate
assessment of flow distribution is important for understanding pathologies and potential
therapies. In this paper, we demonstrate a method for volumetric imaging of fetal flow
with magnetic resonance imaging (MRI). Fetal MRI faces challenges: small vascular
structures, unpredictable motion, and inadequate traditional cardiac gating methods.
Here, orthogonal multislice stacks are acquired with accelerated multidimensional radial
phase contrast (PC) MRI. we have developed an approach for dynamic volumetric fetal
flow imaging using highly accelerated multidimensional radial PCMRI. The method
makes use of real-time reconstructions for intra-slice motion correction and derivation of
fetal heart rate to provide flow sensitive CINEs. They are then combined with inter-slice
spatiotemporal registration and volumetric update to create 4D flow reconstructions in
human fetuses.

Disadvantages:
 Machine learning is not implemented.
 Fetal flow image is developed.
 Fetal condition is not predicted.

11
CHAPTER - 2

Proposed System

12
2. Proposed System:
The aim of the proposed method is to predict whether the gestation fetal is normal or not.
This can be predicted by a machine learning method. The process starts from collecting
the data’s. After collecting the dataset, it is pre-processed for removing the unwanted
data’s from the dataset. Machine learning method is now used and mostly used in all the
departments where it reduces the mistake. Many algorithms are used and the best one is
used for predicting the fetal health.

Patient Dataset

Test dataset
Data Processing

Classification ML Algorithm
Training dataset Model

Architecture of Proposed model


2.1 Advantages:
 Fetal health condition will be predicted.
 Machine learning is implemented.

 More algorithms are compared.

13
CHAPTER - 3

INTRODUCTION

14
3. INTRODUCTION
3.1 Data Science
Data science is an interdisciplinary field that uses scientific methods, processes,
algorithms and systems to extract knowledge and insights from structured and
unstructured data, and apply knowledge and actionable insights from data across a broad
range of application domains.
The term "data science" has been traced back to 1974, when Peter Naur proposed it
as an alternative name for computer science. In 1996, the International Federation of
Classification Societies became the first conference to specifically feature data science as
a topic. However, the definition was still in flux.
The term “data science” was first coined in 2008 by D.J. Patil, and Jeff
Hammerbacher, the pioneer leads of data and analytics efforts at LinkedIn and Facebook.
In less than a decade, it has become one of the hottest and most trending professions in
the market.
Data science is the field of study that combines domain expertise, programming
skills, and knowledge of mathematics and statistics to extract meaningful insights from
data.
Data science can be defined as a blend of mathematics, business acumen, tools,
algorithms and machine learning techniques, all of which help us in finding out the
hidden insights or patterns from raw data which can be of major use in the formation of
big business decisions.

Data Scientist:
Data scientists examine which questions need answering and where to find the
related data. They have business acumen and analytical skills as well as the ability to
mine, clean, and present data. Businesses use data scientists to source, manage, and
analyze large amounts of unstructured data.

Required Skills for a Data Scientist:


1
1. Programming: Python, SQL, Scala, Java, R, MATLAB.
2. Machine Learning: Natural Language Processing, Classification, Clustering.
3. Data Visualization: Tableau, SAS, D3.js, Python, Java, R libraries.
4. Big data platforms: MongoDB, Oracle, Microsoft Azure, Cloudera.

3.2 ARTIFICIAL INTELLIGENCE


Artificial intelligence (AI) refers to the simulation of human intelligence in
machines that are programmed to think like humans and mimic their actions. The term
may also be applied to any machine that exhibits traits associated with a human mind
such as learning and problem-solving.
Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to
the natural intelligence displayed by humans or animals. Leading AI textbooks define the
field as the study of "intelligent agents" any system that perceives its environment and
takes actions that maximize its chance of achieving its goals. Some popular accounts use
the term "artificial intelligence" to describe machines that mimic "cognitive" functions
that humans associate with the human mind, such as "learning" and "problem solving",
however this definition is rejected by major AI researchers.
Artificial intelligence is the simulation of human intelligence processes by
machines, especially computer systems. Specific applications of AI include expert
systems, natural language processing, and speech recognition and machine vision.

AI applications include advanced web search engines, recommendation systems


(used by Youtube, Amazon and Netflix), Understanding human speech (such
as Siri or Alexa), self-driving cars (e.g. Tesla), and competing at the highest level
in strategic game systems (such as chess and Go), As machines become increasingly
capable, tasks considered to require "intelligence" are often removed from the definition
of AI, a phenomenon known as the AI effect. For instance, optical character recognition
is frequently excluded from things considered to be AI, having become a routine
technology.
1
Artificial intelligence was founded as an academic discipline in 1956, and in the
years since has experienced several waves of optimism, followed by disappointment and
the loss of funding (known as an "AI winter"), followed by new approaches, success and
renewed funding. AI research has tried and discarded many different approaches during
its lifetime, including simulating the brain, modeling human problem solving, formal
logic, large databases of knowledge and imitating animal behavior. In the first decades of
the 21st century, highly mathematical statistical machine learning has dominated the
field, and this technique has proved highly successful, helping to solve many challenging
problems throughout industry and academia.

The various sub-fields of AI research are centered on particular goals and the use
of particular tools. The traditional goals of AI research include reasoning, knowledge
representation, planning, learning, natural language processing, perception and the ability
to move and manipulate objects. General intelligence (the ability to solve an arbitrary
problem) is among the field's long-term goals. To solve these problems, AI researchers
use versions of search and mathematical optimization, formal logic, artificial neural
networks, and methods based on statistics, probability and economics. AI also draws
upon computer science, psychology, linguistics, philosophy, and many other fields.

The field was founded on the assumption that human intelligence "can be so
precisely described that a machine can be made to simulate it". This raises philosophical
arguments about the mind and the ethics of creating artificial beings endowed with
human- like intelligence. These issues have been
explored by myth, fiction and philosophy since antiquity. Science fiction and
futurology have also suggested that, with its enormous potential and power, AI may
become an existential risk to humanity.

As the hype around AI has accelerated, vendors have been scrambling to promote
how their products and services use AI. Often what they refer to as AI is simply one

1
component of AI, such as machine learning. AI requires a foundation of specialized
hardware and software for writing and training machine learning algorithms. No one
programming language is synonymous with AI, but a few, including Python, R and Java,
are popular.

In general, AI systems work by ingesting large amounts of labeled training data,


analyzing the data for correlations and patterns, and using these patterns to make
predictions about future states. In this way, a chatbot that is fed examples of text chats
can learn to produce life like exchanges with people, or an image recognition tool can
learn to identify and describe objects in images by reviewing millions of examples.

AI programming focuses on three cognitive skills: learning, reasoning and self-


correction.

Learning processes. This aspect of AI programming focuses on acquiring data


and creating rules for how to turn the data into actionable information. The rules, which
are called algorithms, provide computing devices with step-by-step instructions for how
to complete a specific task.

Reasoning processes. This aspect of AI programming focuses on choosing the


right algorithm to reach a desired outcome.

Self-correction processes. This aspect of AI programming is designed to


continually fine-tune algorithms and ensure they provide the most accurate results
possible.

AI is important because it can give enterprises insights into their operations that
they may not have been aware of previously and because, in some cases, AI can perform
tasks better than humans. Particularly when it comes to repetitive, detail-oriented tasks
like analyzing large numbers of legal documents to ensure relevant fields are filled in
properly, AI tools often complete jobs quickly and with relatively few errors.
Artificial neural networks and deep learning artificial intelligence technologies are
quickly evolving, primarily because AI processes large amounts of data much faster and
makes predictions more accurately than humanly possible.

Natural Language Processing (NLP):

Natural language processing (NLP) allows machines to read and understand human
language. A sufficiently powerful natural language processing system would
enable natural-language user interfaces and the acquisition of knowledge directly from
human-written sources, such as newswire texts. Some straightforward applications of
natural language processing include information retrieval, text mining, question
answering and machine translation. Many current approaches use word co-occurrence
frequencies to construct syntactic representations of text. "Keyword spotting" strategies
for search are popular and scalable but dumb; a search query for "dog" might only match
documents with the literal word "dog" and miss a document with the word "poodle".
"Lexical affinity" strategies use the occurrence of words such as "accident" to assess the
sentiment of a document. Modern statistical NLP approaches can combine all these
strategies as well as others, and often achieve acceptable accuracy at the page or
paragraph level. Beyond semantic NLP, the ultimate goal of "narrative" NLP is to
embody a full understanding of common sense reasoning. By 2019, transformer-based
deep learning architectures could generate coherent text.

1
Chapter - 4

MACHINE LEARNING

2
4. MACHINE LEARNING

Machine learning is to predict the future from past data. Machine learning (ML) is
a type of artificial intelligence (AI) that provides computers with the ability to learn
without being explicitly programmed. Machine learning focuses on the development of
Computer Programs that can change when exposed to new data and the basics of
Machine Learning, implementation of a simple machine learning algorithm using python.
Process of training and prediction involves use of specialized algorithms. It feed the
training data to an algorithm, and the algorithm uses this training data to give predictions
on a new test data. Machine learning can be roughly separated in to three categories.
There are supervised learning, unsupervised learning and reinforcement learning.
Supervised learning program is both given the input data and the corresponding labelling
to learn data has to be labelled by a human being beforehand. Unsupervised learning is
no labels. It provided to the learning algorithm. This algorithm has to figure out the
clustering of the input data. Finally, Reinforcement learning dynamically interacts with
its environment and it receives positive or negative feedback to improve its performance.
Data scientists use many different kinds of machine learning algorithms to
discover patterns in python that lead to actionable insights. At a high level, these
different algorithms can be classified into two groups based on the way they “learn”
about data to make predictions: supervised and unsupervised learning. Classification is
the process of predicting the class of given data points. Classes are sometimes called as
targets/ labels or categories. Classification predictive modeling is the task of
approximating a mapping function from input variables(X) to discrete output
variables(y). In machine learning and statistics, classification is a supervised learning
approach in which the computer program learns from the data input given to it and then
uses this learning to classify new observation. This data set may simply be bi-class (like
identifying whether the person is male or female or that the mail is spam or non-spam) or
it may be multi-class too. Some examples of classification problems are: speech
recognition, handwriting recognition, bio metric identification, document classification
etc.
21
Supervised Machine Learning is the majority of practical machine learning uses
supervised learning. Supervised learning is where have input variables (X) and an output
variable (y) and use an algorithm to learn the mapping function from the input to the
output is y = f(X). The goal is to approximate the mapping function so well that when
you have new input data (X) that you can predict the output variables (y) for that data.
Techniques of Supervised Machine Learning algorithms include logistic
regression, multi-class classification, Decision Trees and support vector machines
etc. Supervised learning requires that the data used to train the algorithm is already
labelled with correct answers. Supervised learning problems can be further
grouped into Classification problems. This problem has as goal the construction of a
succinct model that can predict the value of the dependent attribute from the attribute
variables. The difference between the two tasks is the fact that the dependent attribute is
numerical for categorical for classification. A classification model attempts to draw some
conclusion from observed values. Given one or more inputs a classification model will
try to predict the value of one or more outcomes. A classification problem is when the
output variable is a category, such as “red” or “blue”.

2
Chapter 5
Preparing the Dataset

2
5. Preparing the Dataset:

This dataset contains 2000 records of features extracted, which were then used to
find the fetal health condition.

2
Chapter – 6
Literature survey:

2
6. Literature survey:
General
A literature review is a body of text that aims to review the critical points of
current knowledge on and/or methodological approaches to a particular topic. It is
secondary sources and discuss published information in a particular subject area and
sometimes information in a particular subject area within a certain time period. Its
ultimate goal is to bring the reader up to date with current literature on a topic and forms
the basis for another goal, such as future research that may be needed in the area and
precedes a research proposal and may be just a simple summary of sources. Usually, it
has an organizational pattern and combines both summary and synthesis.
A summary is a recap of important information about the source, but a synthesis is
a re-organization, reshuffling of information. It might give a new interpretation of old
material or combine new with old interpretations or it might trace the intellectual
progression of the field, including major debates. Depending on the situation, the
literature review may evaluate the sources and advise the reader on the most pertinent or
relevant of them

Review of Literature Survey


Title : Comparison of machine learning algorithms to classify fetal health using
cardiotocogram data
Author: Nabillah Rahmayanti, Humaira Pradani
Year : 2021
Cardiotocogram (CTG) is one of the monitoring tools to estimate the fetus health in
womb. CTG mainly yields two results fetal health rate (FHR) and uterine contractions
(UC). In total, there are 21 attributes in the measurement of FHR and UC on CTG. These
2
attributes can help obstreticians to clasify whether the fetus health is normal, suspected,
or pathological. This paper compares 7 algorithms to predict the fetus health: Artificial
Neural Network (ANN), Long-short Term Memory (LSTM), XG Boost (XGB), Support
Vector Machine (SVM), K-Nearest Neighbour (KNN), Light GBM (LGBM), and
Random Forest (RF). By employing three scenarios, this paper reports the performance
measurements among those algorithms. The results show that 5 out of 7 algorithms
perform very well (89-99% accurate). Those five algorithms are XGB, SVM, KNN,
LGBM, RF. Furthermore, only one from five algorithm that always performs well
through three scenarios: LGBM.

Title : Cardiotocographic Diagnosis of Fetal Health based on Multiclass Morphologic


Pattern Predictions using Deep Learning Classification
Author: Julia H. Miao1 , Kathleen H. Miao1, 2
Year : 2018
Medical complications of pregnancy and pregnancy-related deaths continue to
remain a major global challenge today. Internationally, about 830 maternal deaths occur
every day due to pregnancy-related or childbirth-related complications. In fact, almost
99% of all maternal deaths occur in developing countries. In this research, an alternative
and enhanced artificial intelligence approach is proposed for cardiotocographic diagnosis
of fetal assessment based on multiclass morphologic pattern predictions, including 10
target classes with imbalanced samples, using deep learning classification models. The
developed model is used to distinguish and classify the presence or absence of multiclass
morphologic patterns for outcome predictions of complications during pregnancy. The
testing results showed that the developed deep neural network model achieved an
accuracy of 88.02%, a recall of 84.30%, a precision of 85.01%, and an F-score of 0.8508
in average. Thus, the developed model can provide highly accurate and consistent
diagnoses for fetal assessment regarding complications during pregnancy, thereby
preventing and/or reducing fetal mortality rate as well as maternal mortality rate
during and following pregnancy and
2
childbirth, especially in lowresource settings and developing countries.

2
Title : HUMAN FETUS HEALTH PREDICTION USING DECISION TREE
Author: Rajasekhar Nannapaneni
Human unborn baby health is monitored by electronic fetal monitor equipment
which generates cardiotocographic data. This cardiotocographic data consists of fetal
heart rate (FHR), uterus contractions rate, etc. The inference achieved from analyzing the
cardiotocographic data lets us know whether the fetus is normal, suspect with action
needed or pathologic with immediate action needed. It is very important and critical to
making this inference quickly as any delay could be a risk to both fetal and mother. This
article details the development of machine learning-based decision tree algorithm that
will classify any given fetus health into normal, suspect and pathologic based on the
given cardiotocographic data. In this article, a dataset consisting of 2126 observations
with 22 attributes or readings is considered and 90% of this data is used for training the
decision tree model and the rest 10% is used to test the accuracy of the developed model.

Title : Fetal Health Prediction using Classification Techniques


Author: Naveen Reddy Navuluri
Year: 2021
A fetal is basically an unborn offspring which is in the embryo stage until it comes
to the world. During the pregnancy process, each three month period is known by a name
called trimester. During this process the fetus grows and develops and along with it the
regular checkups are very important. As we all know that a pregnancy lasts for 9 months
and in this long period there may be various reasons which may cause disability or
mortality in the newborn which is a very severe case and this needs to be avoided. One of
the main tool to analyse the health of the fetal in the womb is by doing a
CTG(Cardiotacagraphy) which generally is used to evaluate the heart beat and the uterine
contractions hence the data generated is used by the doctor to analyse the health and give
2
his wording. But there is a room for error hence the doctors are not reliable to analyse the
data hence different machine and deep learning algorithms have been there which can
analyse the data and predict the fetals health based on it. The main motive of the paper is
to prove the prediction accuracy using the different classification models and compare
which model performs better.

Title : Prediction of Fetal Health State during Pregnancy: A Survey


Author: Tadele Debisa Deressa [1] , Kalyani Kadam [2]
Year : 2018
Fetal Health is the indicator of fetal wellbeing and regular contact in the uterus of
pregnant women during pregnancy. Most pregnancy period complication leads fetus to a
severe problem which restricts proper growth that causes impairment or death. Safe
pregnancy period by predicting risk levels before the occasion of complications
encourage proper fetal growth. Prediction of fetal health state from a set of pre-classified
patterns knowledge is a common important in developing a predictive classifier model
using data mining algorithms. In this paper the University of California Irvine (UCI)
Cardiotocogram (CTG) dataset is the source of information required for building a model
which predicts whether the fetal is healthy or unhealthy. It consists of 2126 instances
with 22 attributes obtained from FHR and UC which are multivariate datatypes. The
major goal of this study is to choose efficient data mining algorithm which develops the
accurate predictive model to manage knowledge of fetal health during pregnancy.

3
Chapter - 7

SYSTEM STUDY

3
7. SYSTEM STUDY
Aim:
Fetal health is one of the major factors in our health care. There are lot of pregnant
women who are living in the world. It is difficult to find the fetal health. So this project
can easily find out the Fetal health.

7.1 Objectives
The goal is to develop a machine learning model for fetal health Prediction, to
potentially replace the updatable supervised machine learning classification models by
predicting results in the form of best accuracy by comparing supervised algorithm.

7.2 Project Goals

 Exploration data analysis of variable identification


1. Loading the given dataset
2. Import required libraries packages
3. Analyze the general properties
4. Find duplicate and missing values
5. Checking unique and count values

 Uni-variate data analysis


 Rename, add data and drop the data
 To specify data type

3
 Exploration data analysis of bi-variate and multi-variate
 Plot diagram of pairplot, heatmap, bar chart and Histogram

 Method of Outlier detection with feature engineering


 Pre-processing the given dataset
 Splitting the test and training dataset
 Comparing the Decision tree and Logistic regression model and random forest
etc.

 Comparing algorithm to predict the result


 Based on the best accuracy

7.3 Scope of the Project


Here the scope of the project is that integration of fetal health with computer-based
prediction could reduce errors and improve prediction outcome. This suggestion is
promising as data modeling and analysis tools, e.g., data mining, have the potential to
generate a knowledge-rich environment which can help to significantly improve the
quality of fetal health prediction.

3
Chapter - 8
Feasibility study

3
8. Feasibility study:
Data Wrangling
In this section of the report will load in the data, check for
cleanliness, and then trim and clean given dataset for analysis. Make sure
that the document steps carefully and justify for cleaning decisions.

Data collection
The data set collected for predicting given data is split into Training set and Test
set. Generally, 7:3 ratios are applied to split the Training set and Test set. The Data
Model which was created using Random Forest, logistic, Decision tree algorithms and
Support vector classifier (SVC) are applied on the Training set and based on the test
result accuracy, Test set prediction is done.

Preprocessing
The data which was collected might contain missing values that may lead to
inconsistency. To gain better results data need to be preprocessed so as to improve the
efficiency of the algorithm. The outliers have to be removed and also variable conversion
need to be done.

Building the classification model


The prediction of Heart attack, a high accuracy prediction model is effective
because of the following reasons: It provides better results in classification problem.

3
 It is strong in preprocessing outliers, irrelevant variables, and a mix of continuous,
categorical and discrete variables.
 It produces out of bag estimate error which has proven to be unbiased in many
tests and it is relatively easy to tune with.

Construction of a Predictive Model


Machine learning needs data gathering have lot of past data’s. Data
gathering have sufficient historical data and raw data. Before data pre-
processing, raw data can’t be used directly. It’s used to pre-process then,
what kind of algorithm with model. Training and testing this model
working and predicting correctly with minimum errors. Tuned model
involved by tuned time to time with improving the accuracy.

Data Gathering

Data Pre-Processing

Choose model

Train model

Test model

Tune model

Prediction
Process of dataflow diagram

3
Chapter - 9

List of Modules

3
9. List of Modules:

 Data Pre-processing
 Data Analysis of Visualization
 Implementing Algorithm 1
 Implementing Algorithm 2
 Implementing Algorithm 3
 Implementing Algorithm 4
 Deployment

3
Chapter - 10

Project Requirements

3
10. Project Requirements

General:
Requirements are the basic constrains that are required to develop a system.
Requirements are collected while designing the system. The following are the
requirements that are to be discussed.
1. Functional requirements
2. Non-Functional requirements
3. Environment requirements
A. Hardware requirements
B. software requirements

10.1 Functional requirements:


The software requirements specification is a technical specification of requirements
for the software product. It is the first step in the requirements analysis process. It lists
requirements of a particular software system. The following details to follow the special
libraries like sk-learn, pandas, numpy, matplotlib and seaborn.

10.2 Non-Functional Requirements:


Process of functional steps,
1. Problem define
2. Preparing data
3. Evaluating algorithms
4. Improving results
5. Prediction the result

4
Chapter - 11
Environmental Requirements

4
11. Environmental Requirements:
1. Software Requirements:
Operating System : Windows 10 or later
Tool : Anaconda with Jupyter Notebook
2. Hardware requirements:
Processor : Pentium IV/III
Hard disk : minimum 80 GB
RAM : minimum 2 GB

4
Chapter - 12
SOFTWARE DESCRIPTION

4
12. SOFTWARE DESCRIPTION
Anaconda is a free and open-source distribution of the Python and R programming
languages for scientific computing (data science, machine learning applications, large-
scale data processing, predictive analytics, etc.), that aims to simplify package
management and deployment. Package versions are managed by the package
management system “Conda”. The Anaconda distribution is used by over 12 million
users and includes more than 1400 popular data-science packages suitable for Windows,
Linux, and MacOS. So, Anaconda distribution comes with more than 1,400
packages as well as the Conda package and virtual environment manager called
Anaconda Navigator and it eliminates the need to learn to install each library
independently. The open source packages can be individually installed from the
Anaconda repository with the conda install command or using the pip install command
that is installed with Anaconda. Pip packages provide many of the features of conda
packages and in most cases they can work together. Custom
packages can be made using the conda command, and can be shared with others

by uploading them to Anaconda Cloud, PyPI or other repositories. The default


installation of Anaconda2 includes Python 2.7 and Anaconda3 includes Python 3.7.
However, you can create new environments that include any version of Python packaged
with conda.

12.1 ANACONDA NAVIGATOR


Anaconda Navigator is a desktop graphical user interface (GUI) included in
Anaconda® distribution that allows you to launch applications and easily manage conda
packages, environments, and channels without using command-line commands.
Navigator can search for packages on Anaconda.org or in a local Anaconda Repository.
Anaconda. Now, if you are primarily doing data science work, Anaconda is also a
great option. Anaconda is created by Continuum Analytics, and it is a Python
distribution that comes preinstalled with lots of useful python libraries for data science.
4
Anaconda is a distribution of the Python and R programming languages for
scientific

4
computing (data science, machine learning applications, large-scale data processing,
predictive analytics, etc.), that aims to simplify package management and deployment.
In order to run, many scientific packages depend on specific versions of other
packages. Data scientists often use multiple versions of many packages and use multiple
environments to separate these different versions.

The command-line program conda is both a package manager and an environment


manager. This helps data scientists ensure that each version of each package has all the
dependencies it requires and works correctly.

Navigator is an easy, point-and-click way to work with packages and environments


without needing to type conda commands in a terminal window. You can use it to find
the packages you want, install them in an environment, run the packages, and update
them – all inside Navigator.

The following applications are available by default in Navigator:

 JupyterLab
 Jupyter Notebook
 Spyder
 PyCharm
 VSCode
 Glueviz
 Orange 3 App
 RStudio
 Anaconda Prompt (Windows only)
 Anaconda PowerShell (Windows only)

4
Anaconda Navigator is a desktop graphical user interface (GUI) included in
Anaconda distribution.

4
Navigator allows you to launch common Python programs and easily manage
conda packages, environments, and channels without using command-line commands.
Navigator can search for packages on Anaconda Cloud or in a local Anaconda
Repository.

Anaconda comes with many built-in packages that you can easily find with conda list on
your anaconda prompt. As it has lots of packages (many of which are rarely used), it
requires lots of space and time as well. If you have enough space, time and do not want to
burden yourself to install small utilities like JSON, YAML, you better go for Anaconda.

Conda :
Conda is an open source, cross-platform, language-agnostic package manager and
environment management system that installs, runs, and updates packages and their
dependencies. It was created for Python programs, but it can package and distribute
software for any language (e.g., R), including multi-language projects. The conda
package and environment manager is included in all versions of Anaconda, Miniconda,
and Anaconda Repository.
Anaconda is freely available, open source distribution of python and R programming
languages which is used for scientific computations. If you are doing any machine
learning or deep learning project then this is the best place for you. It consists of many
softwares which will help you to build your machine learning project and deep learning
project. These softwares have great graphical user interface and these will make your
work easy to do. You can also use it to run your python script. These are the software
carried by anaconda navigator.

4
12.2 JUPYTER NOTEBOOK

4
This website acts as “meta” documentation for the Jupyter ecosystem. It has a
collection of resources to navigate the tools and communities in this ecosystem, and to
help you get started.
Project Jupyter is a project and community whose goal is to "develop open-source
software, open-standards, and services for interactive computing across dozens of
programming languages". It was spun off from IPython in 2014 by Fernando Perez.
Notebook documents are documents produced by the Jupyter Notebook App,
which contain both computer code (e.g. python) and rich text elements (paragraph,
equations, figures, links, etc…). Notebook documents are both human-readable
documents containing the analysis description and the results (figures, tables, etc.) as
well as executable documents which can be run to perform data analysis.

Installation: The easiest way to install the Jupyter Notebook App is


Running
installingthe Jupyter Notebook
a scientific python distribution which also includes scientific
pythonThis
Launching will The
launch
Jupyter
packages. mostacommon
Notebook new
App:browser window
The Jupyter
distribution (orAnaconda
is Notebook
called aApp
newcantab)
be
When
showing
launched the started,
Notebook
by clicking onthetheJupyter
JupyterNotebook
Dashboard, a sort of App
Notebook can panel
control
icon access
installed onlyallows
bythat
Anacondafiles
within
in the its
(among start-up
other
start folder
things)
menu (including
to select
(Windows) which any typing
sub-folder).
or notebook
by to in a No
open. configuration
terminal (cmd on is
necessary
Windows):if“jupyter
you place your notebooks in your home folder or subfolders.
notebook”

4
you need to choose a Jupyter Notebook App start-up folder which will
contain all the notebooks.

Save notebooks: Modifications to the notebooks are automatically saved


every few minutes. To avoid modifying the original notebook, make a copy
of the notebook document (menu file -> make a copy…) and save the
modifications on the copy.

Executing a notebook: Download the notebook you want to execute and


put it in your notebook folder (or a sub-folder of it).
 Launch the jupyter notebook app
 In the Notebook Dashboard navigate to find the notebook: clicking on its name
will open it in a new browser tab.
 Click on the menu Help -> User Interface Tour for an overview of the Jupyter
Notebook App user interface.
 You can run the notebook document step-by-step (one cell a time) by pressing shift
+ enter.
 You can run the whole notebook in a single step by clicking on the menu Cell ->
Run All.
 To restart the kernel (i.e. the computational engine), click on the menu Kernel ->
Restart. This can be useful to start over a computation from scratch (e.g. variables
are deleted, open files are closed, etc…).

Purpose: To support interactive data science and scientific computing across all
programming languages.

File Extension: An IPYNB file is a notebook document created by Jupyter Notebook, an

48
interactive computational environment that helps scientists manipulate and analyze data
using Python.

JUPYTER Notebook App:

The Jupyter Notebook App is a server-client application that allows editing and
Notebook Dashboard: The Notebook Dashboard is the component which
running notebook documents via a web browser.
is shown first when you launch Jupyter
49
The Jupyter Notebook App can be executed on a local desktop requiring no
internet access (as described in this document) or can be installed on a remote server
and accessed through the internet.

In addition to displaying/editing/running notebook documents, the Jupyter


Notebook App has a “Dashboard” (Notebook Dashboard), a “control panel” showing
local files and allowing to open notebook documents or shutting down their kernels.

Kernel: A notebook kernel is a “computational engine” that executes the


code contained in a Notebook document. The ipython kernel, referenced
in this guide, executes python code. Kernels for many other languages
exist (official kernels).
When you open a Notebook document, the associated kernel is automatically
launched. When the notebook is executed (either cell-by-cell or with menu Cell -> Run
All), the kernel performs the computation and produces the results.

Depending on the type of computations, the kernel may consume significant CPU
and RAM. Note that the RAM is not released until the kernel is shut-down
Dashboard is mainly used to open notebook documents, and to manage
the running kernels (visualize and shutdown).

The Notebook Dashboard has other features similar to a file manager, namely
 Download and install anaconda and get the most useful package for machine
navigating folders and renaming/deleting files
learning in Python.
 Load a dataset and understand its structure using statistical summaries and data
visualization.
Working Process:
 Machine learning models, pick the best and build confidence that the accuracy is
reliable.
Python is a popular and powerful interpreted language. Unlike R, Python is a
complete language and platform that you can use for both research and development and
developing production systems. There are also a lot of modules and libraries to choose
from, providing multiple ways to do each task. It can feel overwhelming.

The best way to get started using Python for machine learning is to complete a project.

 It will force you to install and start the Python interpreter (at the very least).
 It will give you a bird’s eye view of how to step through a small project.
 It will give you confidence, maybe to go on to your own small projects.

When you are applying machine learning to your own datasets, you are working on a

5
project. A machine learning project may not be linear, but it has a number of well-known
steps:

 Define Problem.
 Prepare Data.
 Evaluate Algorithms.
 Improve Results.
 Present Results.

The best way to really come to terms with a new platform or tool is to work
through a machine learning project end-to-end and cover the key steps. Namely, from
loading data, summarizing data, evaluating algorithms and making some predictions.

Here is an overview of what we are going to cover:

1. Installing the Python anaconda platform.


2. Loading the dataset.
3. Summarizing the dataset.
4. Visualizing the dataset.
5. Evaluating some algorithms.
6. Making some predictions.

5
Chapter – 13
PYTHON

5
13. PYTHON

Introduction:

Python is an interpreted high-level general-purpose programming language. Its


design philosophy emphasizes code readability with its use of significant indentation.
Its language constructs as well as its object-oriented approach aim to
help programmers write clear, logical code for small and large-scale projects.

Python is dynamically-typed and garbage-collected. It supports multiple programming


paradigms, including structured (particularly, procedural), object-oriented and functional
programming. It is often described as a "batteries included" language due to its
comprehensive standard library.

Guido van Rossum began working on Python in the late 1980s, as a successor to
the ABC programming language, and first released it in 1991 as Python 0.9.0. Python 2.0
was released in 2000 and introduced new features, such as list comprehensions and a
garbage collection system using reference counting. Python 3.0 was released in 2008 and
was a major revision of the language that is not completely backward-compatible. Python
2 was discontinued with version 2.7.18 in 2020.

Python consistently ranks as one of the most popular programming languages

History:

Python was conceived in the late 1980s by Guido van Rossum at Centrum
Wiskunde & Informatica (CWI) in the Netherlands as a successor to ABC programming
language, which was inspired by SETL, capable of exception handling and interfacing
with the Amoeba operating system. Its implementation began in December 1989. Van
Rossum shouldered sole responsibility for the project, as the lead developer, until 12 July
2018, when he announced his "permanent vacation" from his responsibilities as
Python's Benevolent Dictator for Life, a title the Python community bestowed upon him
to reflect his long-term commitment as the project's chief decision-maker. In January
2019,
53
active Python core developers elected a 5-member "Steering Council" to lead the
project. As of 2021, the current members of this council are Barry Warsaw, Brett
Cannon, Carol Willing, Thomas Wouters, and Pablo Galindo Salgado.

Python 2.0 was released on 16 October 2000, with many major new features,
including a cycle-detecting garbage collector and support for Unicode.

Python 3.0 was released on 3 December 2008. It was a major revision of the
language that is not completely backward-compatible. Many of its major features
were backported to Python 2.6.x and 2.7.x version series. Releases of Python 3 include
the 2 to 3 utility, which automates (at least partially) the translation of Python 2 code to
Python 3.

Python 2.7's end-of-life date was initially set at 2015 then postponed to 2020 out of
concern that a large body of existing code could not easily be forward-ported to Python 3.
No more security patches or other improvements will be released for it. With
Python 2's end-of-life, only Python 3.6.x and later are supported.

Python 3.9.2 and 3.8.8 were expedited as all versions of Python (including 2.7) had
security issues, leading to possible remote code execution and web cache poisoning.

Design Philosophy & Feature

Python is a multi-paradigm programming language. Object-oriented


programming and structured programming are fully supported, and many of its features
support functional programming and aspect-oriented programming (including by meta-
programming and meta-objects (magic methods)). Many other paradigms are supported
via extensions, including design by contract and logic programming.

Python uses dynamic typing and a combination of reference counting and a cycle-
detecting garbage collector for memory management. It also features dynamic name
resolution (late binding), which binds method and variable names during program
execution.
5
Python's design offers some support for functional programming in
the Lisp tradition. It has filter, map and reduce functions; list comprehensions,
dictionaries, sets, and generator expressions. The standard library has two modules
(itertools and functools) that implement functional tools borrowed from Haskell and
Standard ML.

The language's core philosophy is summarized in the document The Zen of


Python (PEP 20), which includes aphorisms such as:

 Beautiful is better than ugly.


 Explicit is better than implicit.
 Simple is better than complex.
 Complex is better than complicated.
 Readability counts.

Rather than having all of its functionality built into its core, Python was designed
to be highly extensible (with modules). This compact modularity has made it particularly
popular as a means of adding programmable interfaces to existing applications. Van
Rossum's vision of a small core language with a large standard library and easily
extensible interpreter stemmed from his frustrations with ABC, which espoused the
opposite approach.

Python strives for a simpler, less-cluttered syntax and grammar while giving
developers a choice in their coding methodology. In contrast to Perl's "there is more than
one way to do it" motto, Python embraces a "there should be one— and preferably only
one —obvious way to do it" design philosophy. Alex Martelli, a Fellow at the Python
Software Foundation and Python book author, writes that "To describe something as
'clever' is not considered a compliment in the Python culture."

Python's developers strive to avoid premature optimization, and reject patches to


55
non-critical parts of the C-Python reference implementation that would offer marginal
increases in speed at the cost of clarity. When speed is important, a Python programmer
can move time-critical functions to extension modules written in languages such as C, or
use PyPy, a just-in-time compiler. Cython is also available, which translates a Python
script into C and makes direct C-level API calls into the Python interpreter.

Python's developers aim to keep the language fun to use. This is reflected in its
name a tribute to the British comedy group Monty Python and in occasionally playful
approaches to tutorials and reference materials, such as examples that refer to spam and
eggs (a reference to a Monty Python sketch) instead of the standard foo and bar.

A common neologism in the Python community is pythonic, which can have a


wide range of meanings related to program style. To say that code is pythonic is to say
that it uses Python idioms well, that it is natural or shows fluency in the language, and
that it conforms to Python's minimalist philosophy and emphasis on readability. In
contrast, code that is difficult to understand or reads like a rough transcription from
another programming language is called unpythonic.

Users and admirers of Python, especially those considered knowledgeable or


experienced, are often referred to as Pythonistas

Syntax and Semantics :

Python is meant to be an easily readable language. Its formatting is visually


uncluttered, and it often uses English keywords where other languages use punctuation.
Unlike many other languages, it does not use curly brackets to delimit blocks, and
semicolons after statements are allowed but are rarely, if ever, used. It has fewer
syntactic exceptions and special cases than C or Pascal.

Indentation :
56
Main article: Python syntax and semantics & Indentation

Python uses whitespace indentation, rather than curly brackets or keywords, to


delimit blocks. An increase in indentation comes after certain statements; a decrease in
indentation signifies the end of the current block. Thus, the program's visual structure
accurately represents the program's semantic structure. This feature is sometimes termed
the off-side rule, which some other languages share, but in most languages indentation
does not have any semantic meaning. The recommended indent size is four spaces.

Statements and control flow:

Python's statements include:

 The assignment statement, using a single equals sign =.


 The if statement, which conditionally executes a block of code, along with else and
elif (a contraction of else-if).
 The for statement, which iterates over an iterable object, capturing each element to a
local variable for use by the attached block.
 The while statement, which executes a block of code as long as its condition is true.
 The Try statement, which allows exceptions raised in its attached code block to be
caught and handled by except clauses; it also ensures that clean-up code in a finally
block will always be run regardless of how the block exits.
 The raise statement, used to raise a specified exception or re-raise a caught exception.
 The class statement, which executes a block of code and attaches its local namespace
to a class, for use in object-oriented programming.
 The def statement, which defines a function or method.
 The with statement, which encloses a code block within a context manager (for
example, acquiring a lock before the block of code is run and releasing the lock

5
afterwards, or opening a file and then closing it), allowing resource-acquisition-is-
initialization (RAII) - like behavior and replaces a common try/finally idiom.
 The break statement, exits from a loop.
 The continue statement, skips this iteration and continues with the next item.
 The del statement, removes a variable, which means the reference from the name to
the value is deleted and trying to use that variable will cause an error. A deleted
variable can be reassigned.
 The pass statement, which serves as a NOP. It is syntactically needed to create an
empty code block.
 The assert statement, used during debugging to check for conditions that should apply.
 The yield statement, which returns a value from a generator function and yield is also
an operator. This form is used to implement co-routines.
 The return statement, used to return a value from a function.
 The import statement, which is used to import modules whose functions or variables
can be used in the current program.

The assignment statement (=) operates by binding a name as a reference to a


separate, dynamically-allocated object. Variables may be subsequently rebound at any
time to any object. In Python, a variable name is a generic reference holder and does not
have a fixed data type associated with it. However, at a given time, a variable will refer
to some object, which will have a type. This is referred to as dynamic typing and is
contrasted with statically-typed programming languages, where each variable may only
contain values of a certain type.

Python does not support tail call optimization or first-class continuations, and,
according to Guido van Rossum, it never will.[80][81] However, better support for co-

5
routine-like functionality is provided, by extending Python's generators. Before 2.5,
generators were lazy iterators; information was passed uni-directionally out of the
generator. From Python 2.5, it is possible to pass information back into a generator
function, and from Python 3.3, the information can be passed through multiple stack
levels.

Expressions :

Some Python expressions are similar to those found in languages such as C


and Java, while some are not:

 Addition, subtraction, and multiplication are the same, but the behaviour of division
differs. There are two types of divisions in Python. They are floor division (or integer
division) // and floating-point/ division. Python also uses the ** operator for
exponentiation.
 From Python 3.5, the new @ infix operator was introduced. It is intended to be used
by libraries such as NumPy for matrix multiplication.
 From Python 3.8, the syntax: =, called the 'walrus operator' was introduced. It assigns
values to variables as part of a larger expression.
 In Python, == compares by value, versus Java, which compares numerics by value
and objects by reference. (Value comparisons in Java on objects can be performed
with the equals () method.) Python's is operator may be used to compare object
identities (comparison by reference). In Python, comparisons may be chained, for
example A<=B<=C.
 Python uses the words and, or, not for or its boolean operators rather than the
symbolic &&, ||,! Used in Java and C.
 Python has a type of expression termed a list comprehension as well as a more
general expression termed a generator expression.
 Anonymous functions are implemented using lambda expressions; however, these are
5
limited in that the body can only be one expression.

6
 Conditional expressions in Python are written as x if c else y (different in order of
operands from the c ? x : y operator common to many other languages).
 Python makes a distinction between lists and tuples. Lists are written as [1, 2, 3], are
mutable, and cannot be used as the keys of dictionaries (dictionary keys must
be immutable in Python). Tuples are written as (1, 2, 3), are immutable and thus can
be used as the keys of dictionaries, provided all elements of the tuple are immutable.
The
+ operator can be used to concatenate two tuples, which does not directly modify their
contents, but rather produces a new tuple containing the elements of both provided
tuples. Thus, given the variable t initially equal to (1, 2, 3), executing t = t + (4, 5)
first evaluates t + (4, 5), which yields (1, 2, 3, 4, 5), which is then assigned back to t,
thereby effectively "modifying the contents" of t, while conforming to the immutable
nature of tuple objects. Parentheses are optional for tuples in unambiguous contexts.
 Python features sequence unpacking wherein multiple expressions, each evaluating to
anything that can be assigned to (a variable, a writable property, etc.), are associated
in an identical manner to that forming tuple literals and, as a whole, are put on the
left- hand side of the equal sign in an assignment statement. The statement
expects an iterable object on the right-hand side of the equal sign that produces the
same number of values as the provided writable expressions when iterated through
and will iterate through it, assigning each of the produced values to the corresponding
expression on the left.
 Python has a "string format" operator %. This functions analogously ton printf format
strings in C, e.g. “spam=%s eggs=%d” % (“blah”,2) evaluates to “spam=blah
eggs=2”. In Python 3 and 2.6+, this was supplemented by the format() method of the
str class,
e.g. “spam={0} eggs={1}”.format(“blah”,2). Python 3.6 added "f-strings": blah =
“blah”; eggs = 2; f‘spam={blah} eggs={eggs}’
 Strings in Python can be concatenated, by "adding" them (same operator as for adding

6
integers and floats). E.g. “spam” + “eggs” returns “spameggs”. Even if your strings
contain numbers, they are still added as strings rather than integers. E.g. “2” + “2”

6
returns “2”.
 Python has various kinds of string literals:
o Strings delimited by single or double quote marks. Unlike in Unix shells, Perl and
Perl-influenced languages, single quote marks and double quote marks function
identically. Both kinds of string use the backslash (\) as an escape character. String
interpolation became available in Python 3.6 as "formatted string literals".
o Triple-quoted strings, which begin and end with a series of three single or double
quote marks. They may span multiple lines and function like here documents in
shells, Perl and Ruby.
o Raw string varieties, denoted by prefixing the string literal with an r . Escape
sequences are not interpreted; hence raw strings are useful where literal
backslashes are common, such as regular expressions and Windows-style paths.
Compare "@- quoting" in C#.
 Python has array index and array slicing expressions on lists, denoted as
a[Key], a[start:stop] or a[start:stop:step]. Indexes are zero-based, and negative
indexes are relative to the end. Slices take elements from the start index up to, but not
including, the stop index. The third slice parameter, called step or stride, allows
elements to be skipped and reversed. Slice indexes may be omitted, for example a[:]
returns a copy of the entire list. Each element of a slice is a shallow copy.

In Python, a distinction between expressions and statements is rigidly enforced, in


contrast to languages such as Common Lisp, Scheme, or Ruby. This leads to duplicating
some functionality. For example:

 List comprehensions vs. for-loops


 Conditional expressions vs. if blocks
 The eval() vs. exec() built-in functions (in Python 2, exec is a statement); the former is
6
for expressions, the latter is for statements.

Statements cannot be a part of an expression, so list and other comprehensions


or lambda expressions, all being expressions, cannot contain statements. A particular case
of this is that an assignment statement such as a=1 cannot form part of the conditional
expression of a conditional statement. This has the advantage of avoiding a classic C
error of mistaking an assignment operator = for an equality operator == in
conditions: if (c==1) {…} is syntactically valid (but probably unintended) C code but if
c=1: … causes a syntax error in Python.

Methods :

Methods on objects are functions attached to the object's class; the syntax
instance.method(argument) is, for normal methods and functions, syntactic sugar for
Class.method(instance, argument). Python methods have an explicit self parameter
access instance data, in contrast to the implicit self (or this) in some other object-oriented
programming languages (e.g., C++, Java, Objective-C, or Ruby). Apart from this Python
also provides methods, sometimes called d-under methods due to their names beginning
and ending with double-underscores, to extend the functionality of custom class to
support native functions such as print, length, comparison, support for arithmetic
operations, type conversion, and many more.

Typing :

Python uses duck typing and has typed objects but untyped variable names. Type
constraints are not checked at compile time; rather, operations on an object may fail,
signifying that the given object is not of a suitable type. Despite being dynamically-
typed,
6
Python is strongly-typed, forbidding operations that are not well-defined (for example,

6
adding a number to a string) rather than silently attempting to make sense of them.

Python allows programmers to define their own types using classes, which are
most often used for object-oriented programming. New instances of classes are
constructed by calling the class (for example, SpamClass() or EggsClass()), and the
classes are instances of the metaclass type (itself an instance of itself), allowing
meta-programming and reflection.

Before version 3.0, Python had two kinds of classes: old-style and new-style. The
syntax of both styles is the same, the difference being whether the class object is
inherited from, directly or indirectly (all new-style classes inherit from object and are
instances of type). In versions of Python 2 from Python 2.2 onwards, both kinds of
classes can be used. Old-style classes were eliminated in Python 3.0.

The long-term plan is to support gradual typing and from Python 3.5, the syntax of the
language allows specifying static types but they are not checked in the default
implementation, CPython. An experimental optional static type checker
named mypy supports compile-time type checking.

66
Chapter - 14

System Architecture

67
14. System Architecture

68
Chapter - 15

Work flow diagram

69
15. Work flow diagram

Source Data

Data Processing and Cleaning

Training Testing
Dataset Dataset

Classification ML Algorithms Best Model by Accuracy

Fetal health prediction

Workflow Diagram

70
Chapter - 16

Use Case Diagram

71
16. Use Case Diagram

Use case diagrams are considered for high level requirement analysis of a system.
So when the requirements of a system are analyzed the functionalities are captured in use
cases. So, it can say that uses cases are nothing but the system functionalities written in
an organized manner.

72
Chapter - 17
Class Diagram

73
17. Class Diagram:

Class diagram is basically a graphical representation of the static view of the


system and represents different aspects of the application. So a collection of class
diagrams represent the whole system. The name of the class diagram should be
meaningful to describe the aspect of the system. Each element and their relationships
should be identified in advance Responsibility (attributes and methods) of each class
should be clearly identified for each class minimum number of properties should be
specified and because, unnecessary properties will make the diagram complicated. Use
notes whenever required to describe some aspect of the diagram and at the end of the
drawing it should be understandable to the developer/coder. Finally, before making the
final version, the diagram should be drawn on plain paper and rework as many times as

74
possible to make it

75
correct.

Chapter – 18
Activity Diagram

76
18. Activity Diagram:

Activity is a particular operation of the system. Activity diagrams are not only
used for visualizing dynamic nature of a system but they are also used to construct the
executable system by using forward and reverse engineering techniques. The only
missing thing in activity diagram is the message part. It does not show any message flow
from one activity to another. Activity diagram is some time considered as the flow chart.
Although the diagrams looks like a flow chart but it is not. It shows different flow like
parallel, branched, concurrent and single.

77
Chapter – 19

Sequence Diagram

78
19. Sequence Diagram:

Sequence diagrams model the flow of logic within your system in a visual manner,
enabling you both to document and validate your logic, and are commonly used for both
analysis and design purposes. Sequence diagrams are the most popular UML artifact for
dynamic modelling, which focuses on identifying the behaviour within your system.
Other dynamic modelling techniques include activity diagramming, communication
diagramming, timing diagramming, and interaction overview diagramming.
Sequencediagrams, along with class diagrams and physical data models are in my
opinion the most important design-level models for modern business application
development.

79
Chapter – 20
Entity Relationship Diagram

80
20. Entity Relationship Diagram (ERD)

An entity relationship diagram (ERD), also known as an entity relationship model,


is a graphical representation of an information system that depicts the relationships
among people, objects, places, concepts or events within that system. An ERD is a data
modeling technique that can help define business processes and be used as the
foundation for a relational database. Entity relationship diagrams provide a visual
starting point for database design that can also be used to help determine information
system requirements throughout an organization. After a relational database is rolled out,
an ERD can still serve as a referral point, should any debugging or business process re-
engineering be needed later.

81
Chapter – 21
Module description

82
21. Module description:
Data Pre-processing
Validation techniques in machine learning are used to get the error rate of the
Machine Learning (ML) model, which can be considered as close to the true error rate of
the dataset. If the data volume is large enough to be representative of the population, you
may not need the validation techniques. However, in real-world scenarios, to work with
samples of data that may not be a true representative of the population of given dataset.
To finding the missing value, duplicate value and description of data type whether it is
float variable or integer. The sample of data used to provide an unbiased evaluation of a
model fit on the training dataset while tuning model hyper parameters.
The evaluation becomes more biased as skill on the validation dataset is
incorporated into the model configuration. The validation set is used to evaluate a given
model, but this is for frequent evaluation. It as machine learning engineers use this data
to fine-tune the model hyper parameters. Data collection, data analysis, and the process
of addressing data content, quality, and structure can add up to a time-consuming to-do
list. During the process of data identification, it helps to understand your data and its
properties; this knowledge will help you choose which algorithm to use to build your
model.

A number of different data cleaning tasks using Python’s Pandas library and
specifically, it focus on probably the biggest data cleaning task, missing values and it
able to more quickly clean data. It wants to spend less time cleaning data, and more time
exploring and modeling.

Some of these sources are just simple random mistakes. Other times, there can be a
deeper reason why data is missing. It’s important to understand these different types of
missing data from a statistics point of view. The type of missing data will influence how
to deal with filling in the missing values and to detect missing values, and do some basic

83
imputation and detailed statistical approach for dealing with missing data. Before, joint
into

84
code, it’s important to understand the sources of missing data. Here are some typical
reasons why data is missing:

 User forgot to fill in a field.

 Data was lost while transferring manually from a legacy database.

 There was a programming error.

 Users chose not to fill out a field tied to their beliefs about how the results would be
used or interpreted.

Variable identification with Uni-variate, Bi-variate and Multi-variate analysis:


 import libraries for access and functional purpose and read the given dataset
 General Properties of Analyzing the given dataset
 Display the given dataset in the form of data frame
 show columns
 shape of the data frame
 To describe the data frame
 Checking data type and information about dataset
 Checking for duplicate data
 Checking Missing values of data frame
 Checking unique values of data frame
 Checking count values of data frame
 Rename and drop the given data frame
 To specify the type of values
 To create extra columns

Data Validation/ Cleaning/Preparing Process


85
Importing the library packages with loading given dataset. To analyzing the
variable identification by data shape, data type and evaluating the missing values,
duplicate values. A validation dataset is a sample of data held back from training your
model that is used to give an estimate of model skill while tuning models and procedures
that you can use to make the best use of validation and test datasets when evaluating your
models. Data cleaning / preparing by rename the given dataset and drop the column etc.
to analyze the uni-variate, bi-variate and multi-variate process. The steps and techniques
for data cleaning will vary from dataset to dataset. The primary goal of data cleaning is to
detect and remove errors and anomalies to increase the value of data in analytics and
decision making.

MODULE DIAGRAM

GIVEN INPUT EXPECTED OUTPUT


input : data
output : removing noisy data

86
Exploration data analysis of visualization
Data visualization is an important skill in applied statistics and machine learning.
Statistics does indeed focus on quantitative descriptions and estimations of data. Data
visualization provides an important suite of tools for gaining a qualitative understanding.
This can be helpful when exploring and getting to know a dataset and can help with
identifying patterns, corrupt data, outliers, and much more. With a little domain
knowledge, data visualizations can be used to express and demonstrate key relationships
in plots and charts that are more visceral and stakeholders than measures of association or
significance. Data visualization and exploratory data analysis are whole fields themselves
and it will recommend a deeper dive into some the books mentioned at the end.

Sometimes data does not make sense until it can look at in a visual form, such as with
charts and plots. Being able to quickly visualize of data samples and others is an
important skill both in applied statistics and in applied machine learning. It will discover
the many types of plots that you will need to know when visualizing data in Python and
how to use them to better understand your own data.

 How to chart time series data with line plots and categorical quantities with bar
charts.
 How to summarize data distributions with histograms and box plots.

Pre-processing refers to the transformations applied to our data before feeding it to the
algorithm. Data Preprocessing is a technique that is used to convert the raw data into a
clean data set. In other words, whenever the data is gathered from different sources it is
collected in raw format which is not feasible for the analysis. To achieving better results
from the applied model in Machine Learning method of the data has to be in a proper
manner. Some specified Machine Learning model needs information in a specified
format, for example, Random Forest algorithm does not support null values. Therefore, to
execute random forest algorithm null values have to be managed from the original raw

87
data set.

88
And another aspect is that data set should be formatted in such a way that more than one
Machine Learning and Deep Learning algorithms are executed in given dataset.

MODULE DIAGRAM

GIVEN INPUT EXPECTED OUTPUT


input : data
output : visualized data

Comparing Algorithm with prediction in the form of best accuracy result


It is important to compare the performance of multiple different machine learning
algorithms consistently and it will discover to create a test harness to compare multiple
different machine learning algorithms in Python with scikit-learn. It can use this test
harness as a template on your own machine learning problems and add more and
different algorithms to compare. Each model will have different performance
characteristics. Using resampling methods like cross validation, you can get an estimate
for how accurate each model may be on unseen data. It needs to be able to use these
estimates to choose one or two best models from the suite of models that you have
created. When have a new dataset, it is a good idea to visualize the data using different
techniques in order to look at the data from different perspectives. The same idea applies
to model selection. You should use a number of different ways of looking at the
estimated accuracy of your machine learning algorithms in order to choose the one or two

89
to finalize. A way to do this is to use different

90
visualization methods to show the average accuracy, variance and other properties of the
distribution of model accuracies.

In the next section you will discover exactly how you can do that in Python with
scikit-learn. The key to a fair comparison of machine learning algorithms is ensuring that
each algorithm is evaluated in the same way on the same data and it can achieve this by
forcing each algorithm to be evaluated on a consistent test harness.

In the example below 4 different algorithms are compared:

 Logistic Regression
 XGBoost Classifier
 Support Vector classifier
 Adaboost

The K-fold cross validation procedure is used to evaluate each algorithm,


importantly configured with the same random seed to ensure that the same splits to the
training data are performed and that each algorithm is evaluated in precisely the same
way. Before that comparing algorithm, Building a Machine Learning Model using install
Scikit- Learn libraries. In this library package have to done preprocessing, linear model
with logistic regression method, cross validating by KFold method, ensemble with
random forest method and tree with decision tree classifier. Additionally, splitting the
train set and test set. To predicting the result by comparing accuracy.

Prediction result by accuracy:


Logistic regression algorithm also uses a linear equation with independent
predictors to predict a value. The predicted value can be anywhere between negative
infinity to
91
positive infinity. It need the output of the algorithm to be classified variable data. Higher
accuracy predicting result is logistic regression model by comparing the best accuracy.

False Positives (FP): A person who will pay predicted as defaulter. When actual class is
no and predicted class is yes. E.g. if actual class says this passenger did not survive but
predicted class tells you that this passenger will survive.
False Negatives (FN): A person who default predicted as payer. When actual class is yes
but predicted class in no. E.g. if actual class value indicates that this passenger survived
and predicted class tells you that passenger will die.
True Positives (TP): A person who will not pay predicted as defaulter. These are the
correctly predicted positive values which means that the value of actual class is yes and
the value of predicted class is also yes. E.g. if actual class value indicates that this
passenger survived and predicted class tells you the same thing.
True Negatives (TN): A person who default predicted as payer. These are the correctly
predicted negative values which means that the value of actual class is no and value of
predicted class is also no. E.g. if actual class says this passenger did not survive and
predicted class tells you the same thing.

True Positive Rate(TPR) = TP / (TP + FN)


False Positive rate(FPR) = FP / (FP + TN)

Accuracy: The Proportion of the total number of predictions that is correct otherwise
overall how often the model predicts correctly defaulters and non-defaulters.

Accuracy calculation:
Accuracy = (TP + TN) / (TP + TN + FP + FN)
Accuracy is the most intuitive performance measure and it is simply a ratio of correctly
predicted observation to the total observations. One may think that, if we have high
92
accuracy then our model is best. Yes, accuracy is a great measure but only when you have
symmetric datasets where values of false positive and false negatives are almost same.

Precision: The proportion of positive predictions that are actually correct.


Precision = TP / (TP + FP)
Precision is the ratio of correctly predicted positive observations to the total predicted
positive observations. The question that this metric answer is of all passengers that
labelled as survived, how many actually survived? High precision relates to the low false
positive rate. We have got 0.788 precision which is pretty good.

Recall: The proportion of positive observed values correctly predicted. (The proportion
of actual defaulters that the model will correctly predict)
Recall = TP / (TP + FN)
Recall(Sensitivity) - Recall is the ratio of correctly predicted positive observations to the
all observations in actual class - yes.

F1 Score is the weighted average of Precision and Recall. Therefore, this score takes
both false positives and false negatives into account. Intuitively it is not as easy to
understand as accuracy, but F1 is usually more useful than accuracy, especially if you
have an uneven class distribution. Accuracy works best if false positives and false
negatives have similar cost. If the cost of false positives and false negatives are very
different, it’s better to look at both Precision and Recall.

General Formula:
F- Measure = 2TP / (2TP + FP + FN)
F1-Score Formula:
F1 Score = 2*(Recall * Precision) / (Recall + Precision)

93
ALGORITHM AND TECHNIQUES
Algorithm Explanation
In machine learning and statistics, classification is a supervised learning approach
in which the computer program learns from the data input given to it and then uses this
learning to classify new observation. This data set may simply be bi-class (like
identifying whether the person is male or female or that the mail is spam or non-spam) or
it may be multi-class too. Some examples of classification problems are: speech
recognition, handwriting recognition, bio metric identification, document classification
etc. In Supervised Learning, algorithms learn from labelled data. After understanding the
data, the algorithm determines which label should be given to new data based on pattern
and associating the patterns to the unlabelled new data.

Used Python Packages:


sklearn:
 In python, sklearn is a machine learning package which include a lot of ML
algorithms.
 Here, we are using some of its modules like train_test_split,
DecisionTreeClassifier or Logistic Regression and accuracy_score.
NumPy:
 It is a numeric python module which provides fast maths functions for
calculations.
 It is used to read data in numpy arrays and for manipulation purpose.
Pandas:
 Used to read and write different files.
 Data manipulation can be done easily with data frames.

94
Matplotlib:
 Data visualization is a useful way to help with identify the patterns from given
dataset.
 Data manipulation can be done easily with data frames.

Logistic Regression

It is a statistical method for analysing a data set in which there are one or more
independent variables that determine an outcome. The outcome is measured with a
dichotomous variable (in which there are only two possible outcomes). The goal of
logistic regression is to find the best fitting model to describe the relationship between
the dichotomous characteristic of interest (dependent variable = response or outcome
variable) and a set of independent (predictor or explanatory) variables. Logistic
regression is a Machine Learning classification algorithm that is used to predict the
probability of a categorical dependent variable. In logistic regression, the dependent
variable is a binary variable that contains data coded as 1 (yes, success, etc.) or 0 (no,
failure, etc.).

In other words, the logistic regression model predicts P(Y=1) as a function of X.


Logistic regression Assumptions:

 Binary logistic regression requires the dependent variable to be binary.

 For a binary regression, the factor level 1 of the dependent variable should
represent the desired outcome.

 Only the meaningful variables should be included.

95
 The independent variables should be independent of each other. That is, the model

96
should have little.

 The independent variables are linearly related to the log odds.

 Logistic regression requires quite large sample sizes.

MODULE DIAGRAM

GIVEN INPUT EXPECTED OUTPUT


input : data
output : getting accuracy

XGBoost Algorithm:
XGBoost is a popular and efficient open-source implementation of the gradient
boosted trees algorithm. Gradient boosting is a supervised learning algorithm, which
attempts to accurately predict a target variable by combining the estimates of a set of
simpler, weaker models.
When using gradient boosting for regression, the weak learners are regression
trees, and each regression tree maps an input data point to one of its leafs that contains a
continuous score. XGBoost minimizes a regularized (L1 and L2) objective function that
combines a convex loss function (based on the difference between the predicted and
target outputs) and a penalty term for model complexity (in other words, the regression
tree functions). The training proceeds iteratively, adding new trees that predict the
residuals or errors of prior trees that are then combined with previous trees to make the
final prediction. It's called gradient boosting because it uses a gradient descent algorithm

97
to minimize the

98
loss when adding new models.

MODULE DIAGRAM

GIVEN INPUT EXPECTED OUTPUT


input : data
output : getting accuracy

Support Vector classifier


A support vector machine (SVM) is machine learning algorithm that analyzes data
for classification and regression analysis. SVM is a supervised learning method that
looks at data and sorts it into one of two categories. An SVM outputs a map of the sorted
data with the margins between the two as far apart as possible. SVMs are used in text
categorization, image classification, handwriting recognition and in the sciences.
A support vector machine is a supervised learning algorithm that sorts data into two
categories. It is trained with a series of data already classified into two categories,
building the model as it is initially trained. The task of an SVM algorithm is to determine
which category a new data point belongs in. This makes SVM a kind of non-binary linear
classifier.
An SVM algorithm should not only place objects into categories, but have the margins
between them on a graph as wide as possible.
 Some applications of SVM include:
99
 Text and hypertext classification
 Image classification
 Recognizing handwritten characters
 Biological sciences, including protein

classification MODULE DIAGRAM

GIVEN INPUT EXPECTED OUTPUT


input : data
output : getting accuracy

AdaBoost
AdaBoost is a type of algorithm that uses an ensemble learning approach to weight
various inputs. It was designed by Yoav Freund and Robert Schapire in the early 21st
century. It has now become somewhat of a go-to method for different kinds of boosting
in machine learning paradigms.
AdaBoost also presents a particular philosophy in machine learning – as an
ensemble learning tool, it proceeds from the fundamental idea that many weak learners
can get better results than one stronger learning entity. With AdaBoost, machine learning
experts are often crafting systems that will take in a number of inputs and combine them
for an optimized result. Some take this idea to a further extent, talking about how
AdaBoost can command "armies of decision stumps" that are essentially less
sophisticated learners employed in large numbers to crunch data where this approach is
seen favorably over using a single classifier.

10
MODULE DIAGRAM

GIVEN INPUT EXPECTED OUTPUT


input : data
output : getting accuracy

10
Chapter – 22
Deployment

10
22. Deployment
Django:
Django is a micro web framework written in Python.
It is classified as a micro-framework because it does not require particular tools or
libraries.
It has no database abstraction layer, form validation, or any other components
where pre-existing third-party libraries provide common functions.
However, Django supports extensions that can add application features as if they
were implemented in Django itself.
Extensions exist for object-relational mappers, form validation, upload handling,
various open authentication technologies and several common framework related tools.

Django was created by Armin Ronacher of Pocoo, an international group of


Python enthusiasts formed in 2004. According to Ronacher, the idea was originally an
April Fool’s joke that was popular enough to make into a serious application. The name
is a play on the earlier Bottle framework.

When Ronacher and Georg Brand created a bulletin board system written in
Python, the Pocoo projects Werkzeug and Jinja were developed.

In April 2016, the Pocoo team was disbanded and development of Django and
related libraries passed to the newly formed Pallets project.

Django has become popular among Python enthusiasts. As of October 2020, it has
second most stars on GitHub among Python web-development frameworks, only slightly
behind Django, and was voted the most popular web framework in the Python
10
Developers

10
Survey 2018.

The micro-framework Django is part of the Pallets Projects, and based on several
others of them.

Django is based on Werkzeug, Jinja2 and inspired by Sinatra Ruby framework, available
under BSD licence. It was developed at pocoo by Armin Ronacher. Although Django is
rather young compared to most Python frameworks, it holds a great promise and has
already gained popularity among Python web developers. Let’s take a closer look into
Django, so-called “micro” framework for Python.

FEATURES:
Django was designed to be easy to use and extend. The idea behind Django is to
build a solid foundation for web applications of different complexity. From then on you
are free to plug in any extensions you think you need. Also you are free to build your
own modules. Django is great for all kinds of projects. It's especially good for
prototyping. Django depends on two external libraries: the Jinja2 template engine and the
Werkzeug WSGI toolkit.

Still the question remains why use Django as your web application framework if
we have immensely powerful Django, Pyramid, and don’t forget web mega-
framework Turbo-gears? Those are supreme Python web frameworks BUT out-of-the-
box Django is pretty impressive too with it’s:

 Built-In Development server and Fast debugger


 integrated support for unit testing

10
 RESTful request dispatching
 Uses Jinja2 Templating
 support for secure cookies
 Unicode based
 Extensive Documentation
 Google App Engine Compatibility
 Extensions available to enhance features desired

Plus Django gives you so much more CONTROL on the development stage
of your project. It follows the principles of minimalism and let you decide how you will
build your application.

 Django has a lightweight and modular design, so it easy to transform it to the web
framework you need with a few extensions without weighing it down
 ORM-agnostic: you can plug in your favourite ORM e.g. SQLAlchemy.
 Basic foundation API is nicely shaped and coherent.
 Django documentation is comprehensive, full of examples and well structured. You can
even try out some sample application to really get a feel of Django.
 It is super easy to deploy Django in production (Django is 100% WSGI 1.0 compliant”)
 HTTP request handling functionality
 High Flexibility

The configuration is even more flexible than that of Django, giving you plenty of solution
for every production need.

10
To sum up, Django is one of the most polished and feature-rich micro frameworks,
available. Still young, Django has a thriving community, first-class extensions, and
an elegant API. Django comes with all the benefits of fast templates, strong WSGI
features, thorough unit testability at the web application and library level, extensive
documentation. So next time you are starting a new project where you need some good
features and a vast number of extensions, definitely check out Django.

Django is an API of Python that allows us to build up web-applications. It was


developed by Armin Ronacher. Django's framework is more explicit than Django
framework and is also easier to learn because it has less base code to implement a simple
web-Application
Django is a micro web framework written in Python. It is classified as a micro-
framework because it does not require particular tools or libraries. It has no database
abstraction layer, form validation, or any other components where pre-existing third-
party libraries provide common functions.
Overview of Python Django Framework Web apps are developed to generate
content based on retrieved data that changes based on a user’s interaction with the site.
The server is responsible for querying, retrieving, and updating data. This makes web
applications to be slower and more complicated to deploy than static websites for simple
applications.
Django is an excellent web development framework for REST API creation. It is built on
top of Python which makes it powerful to use all the python features.
Django is used for the backend, but it makes use of a templating language called Jinja2
which is used to create HTML, XML or other markup formats that are returned to the
user via an HTTP request.
Django is considered to be more popular because it provides many out of box features
and reduces time to build complex applications. Django is a good start if you are getting
into web development. Django is a simple, un-opinionated framework; it doesn't decide

10
what

10
your application should look like developers do.
Django is a web framework. This means Django provides you with tools, libraries
and technologies that allow you to build a web application. This web application can be
some web pages, a blog, and a wiki or go as big as a web-based calendar application or a
commercial website.

Advantages of Django:
 Higher compatibility with latest technologies.
 Technical experimentation.
 Easier to use for simple cases.
 Codebase size is relatively smaller.
 High scalability for simple applications.
 Easy to build a quick prototype.
 Routing URL is easy.
 Easy to develop and maintain applications.

Framework Django is a web framework from Python language. Django provides a


library and a collection of codes that can be used to build websites, without the need to
do everything from scratch. But Framework Django still doesn't use the Model View
Controller (MVC) method.

Django-RESTful is an extension for Django that provides additional support for


building REST APIs. You will never be disappointed with the time it takes to develop an
API. Django-Restful is a lightweight abstraction that works with the existing
ORM/libraries. Django-RESTful encourages best practices with minimal setup.

Django Restful is an extension for Django that adds support for building REST APIs

10
in Python using Django as the back-end. It encourages best practices and is very easy to
set up. Django restful is very easy to pick up if you're already familiar with Django.
Django is a web framework for Python, meaning that it provides functionality for
building web applications, including managing HTTP requests and rendering templates
and also we can add to this application to create our API.

Start Using an API


1. Most APIs require an API key. ...
2. The easiest way to start using an API is by finding an HTTP client online, like REST-
Client, Postman, or Paw.
3. The next best way to pull data from an API is by building a URL from existing API
documentation.

The Django object implements a WSGI application and acts as the central object.
It is passed the name of the module or package of the application. Once it is created it
will act as a central registry for the view functions, the URL rules, template configuration
and much more.

The name of the package is used to resolve resources from inside the package or
the folder the module is contained in depending on if the package parameter resolves to
an actual python package (a folder with an init py file inside) or a standard module (just
a .py file).

For more information about resource loading, see open resource().

Usually you create a Django instance in your main module or in the init .py file
of your package.

11
Parameters
 rule (str) – The URL rule string.
 endpoint (Optional[str]) – The endpoint name to associate with the rule and view
function. Used when routing and building URLs. Defaults to view_func. name .
 view_func (Optional[Callable]) – The view function to associate with the
endpoint name.
 provide_automatic_options (Optional[bool]) – Add the OPTIONS method and
respond to OPTIONS requests automatically.
 options (Any) – Extra options passed to the Rule object.
Return type -- None

After_Request(f)
Register a function to run after each request to this object.

The function is called with the response object, and must return a response
object. This allows the functions to modify or replace the response before it is sent.

If a function raises an exception, any remaining after request functions will


not be called. Therefore, this should not be used for actions that must execute, such
as to close resources. Use teardown_request() for that.

11
Parameters:
f (Callable[[Response], Response])
Return type
Callable[[Response], Response]
after_request_funcs: t.Dict[AppOrBlueprintKey,
t.List[AfterRequestCallable]]
A data structure of functions to call at the end of each request, in the format
{scope: [functions]}. The scope key is the name of a blueprint the functions are
active for, or None for all requests.

To register a function, use the after_request() decorator.

This data structure is internal. It should not be modified directly and its format
may change at any time.
app_context()
Create an AppContext. Use as a with block to push the context, which will
make current_app point at this application.

An application context is automatically pushed by RequestContext.push() when


handling a request, and when running a CLI command. Use this to manually create
a context outside of these situations.

With app.app_context():

Init_db()

101
Chapter - 23
HTML
Introduction

1
23. HTML Introduction

HTML stands for Hyper Text Markup Language. It is used to design web pages
using a markup language. HTML is the combination of Hypertext and Markup language.
Hypertext defines the link between the web pages. A markup language is used to define
the text document within tag which defines the structure of web pages. This language is
used to annotate (make notes for the computer) text so that a machine can understand it
and manipulate text accordingly. Most markup languages (e.g. HTML) are human-
readable. The language uses tags to define what manipulation has to be done on the text.

Basic Construction of an HTML Page


These tags should be placed underneath each other at the top of every HTML page that
you create.

10
<!DOCTYPE html> — This tag specifies the language you will write on the page. In this
case, the language is HTML 5.

<html> — This tag signals that from here on we are going to write in HTML code.

<head> — This is where all the metadata for the page goes — stuff mostly meant for
search engines and other computer programs.

<body> — This is where the content of the page goes.

Further Tags
Inside the <head> tag, there is one tag that is always included: <title>, but there are others
that are just as important:

<title>
This is where we insert the page name as it will appear at the top of the browser
window or tab.

<meta>
This is where information about the document is stored: character encoding,
name (page context), description.

Head Tag
<head>
<title>My First Webpage</title>
<meta charset="UTF-8">
<meta name="description" content="This field contains information about your page. It is
usually around two sentences long.">.
10
<meta name="author" content="Conor Sheils">
</header>

Adding Content
Next, we will make<body> tag.

The HTML <body> is where we add the content which is designed for viewing by human
eyes.

This includes text, images, tables, forms and everything else that we see on the internet
each day.

Add HTML Headings To Web Page


In HTML, headings are written in the following elements:

 <h1>
 <h2>
 <h3>
 <h4>
 <h5>
 <h6>

As you might have guessed <h1> and <h2> should be used for the most important
titles, while the remaining tags should be used for sub-headings and less important text.

Search engine bots use this order when deciphering which information is most
important on a page.

Creating Your Heading


Let’s try it out. On a new line in the HTML editor, type:

10
<h1> Welcome To My Page </h1>

And hit save. We will save this file as “index.html” in a new folder called “my
webpage.”

Add Text In HTML

Adding text to our HTML page is simple using an element opened with the tag
<p> which creates a new paragraph. We place all of our regular text inside the element
<p>.

When we write text in HTML, we also have a number of other elements we can use
to control the text or make it appear in a certain way.

Add Links In HTML


As you may have noticed, the internet is made up of lots of links.

Almost everything you click on while surfing the web is a link takes you to another
page within the website you are visiting or to an external site.

Links are included in an attribute opened by the <a> tag. This element is the first that
we’ve met which uses an attribute and so it looks different to previously mentioned
tags.<a href=http://www.google.com>Google</a>

Image Tag
In today’s modern digital world, images are everything. The <img> tag has
everything you need to display images on your site. Much like the <a> anchor element,
<img> also contains an attribute.

The attribute features information for your computer regarding


the source, height, width and alt text of the image

<img src=”yourimage.jpg” alt=”Describe the image” height=“X” width=“X”>

10
Chapter 24
CSS

10
24. CSS
CSS stands for Cascading Style Sheets. It is the language for describing the
presentation of Web pages, including colours, layout, and fonts, thus making our web
pages presentable to the users.CSS is designed to make style sheets for the web. It is
independent of HTML and can be used with any XML-based markup language. Now
let’s try to break the acronym:

 Cascading: Falling of Styles


 Style: Adding designs/Styling our HTML tags
 Sheets: Writing our style in different documents

CSS Syntax

Selector {
Property 1 : value;
Property 2 : value;
Property 3 : value;
}
For example:
h1
{
Color: red;
Text-align: center;
}
#unique
{
color: green;

10
}

 Selector: selects the element you want to target


 Always remains the same whether we apply internal or external styling
 There are few basic selectors like tags, id’s, and classes
 All forms this key-value pair
 Keys: properties(attributes) like color, font-size, background, width, height,etc
 Value: values associated with these properties

CSS Comment

 Comments don’t render on the browser


 Helps to understand our code better and makes it readable.
 Helps to debug our code
 Two ways to comment:
o Single line

CSS How-To

 There are 3 ways to write CSS in our HTML file.


o Inline CSS
o Internal CSS
o External CSS

 Priority order
o Inline > Internal > External
10
Inline CSS

 Before CSS this was the only way to apply styles


 Not an efficient way to write as it has a lot of redundancy
 Self-contained
 Uniquely applied on each element
 The idea of separation of concerns was lost
 Example:

<h3 style = “color:red”> Have a great day </h3>

<p style = “color:green”> I did this, I did that </p>

Internal CSS

 With the help of style tag, we can apply styles within the HTML file
 Redundancy is removed
 But the idea of separation of concerns still lost
 Uniquely applied on a single document
 Example:

<style>

H1{

Color:red;

11
</style>

<h3> Have a great day </h3>

External CSS

 With the help of <link> tag in the head tag, we can apply styles
 Reference is added
 File saved with .css extension
 Redundancy is removed
 The idea of separation of concerns is maintained
 Uniquely applied to each document
 Example:

<head>

<link rel= “stylesheet” type= “text/css” href= “name of the CSS file”>

</head>

h1{

color:red; //.css file

CSS Selectors

11
 The selector is used to target elements and apply CSS
 Three simple selectors
o Element Selector
o Id Selector
o Class Selector

 Priority of Selectors

CSS Colors

 There are different colouring schemes in CSS


 RGB-This starts with RGB and takes 3 parameter
 HEX-Hex code starts with # and comprises of 6 numbers which are further
divided into 3 sets
 RGBA-This starts with RGB and takes 4 parameter

CSS Background

 There are different ways by which CSS can have an effect on HTML elements
 Few of them are as follows:
o Color – used to set the color of the background
o Repeat – used to determine if the image has to repeat or not and if it
is repeating then how it should do that
o Image – used to set an image as the background
o Position – used to determine the position of the image

11
o Attachment – It basically helps in controlling the mechanism of
scrolling.

CSS BoxModel

 Every element in CSS can be represented using the BOX model


 It allows us to add a border and define space between the content
 It helps the developer to develop and manipulate the elements
 It consists of 4 edges
o Content edge – It comprises of the actual content
o Padding edge – It lies in between content and border edge
o Border edge – Padding is followed by the border edge
o Margin edge – It is an outside border and controls the margin of the
element

MODULE DIAGRAM

GIVEN INPUT EXPECTED OUTPUT


input : data values
output : predicting output

11
Output Sample Screenshot:

11
Chapter – 25

Conclusion

11
25. Conclusion

The analytical process started from data cleaning and processing, missing value,
exploratory analysis and finally model building and evaluation. The best accuracy on
public test set of higher accuracy score algorithm will be find out. The founded one is
used in the application which can help to find the health of the fetal.

11
Chapter - 26

Future Work

11
26. Future Work

 Deploying the project in the cloud.

 To optimize the work to implement in the IOT system.

11

You might also like