0% found this document useful (0 votes)
2 views

full

The document discusses malaria, its symptoms, risk factors, and diagnostic methods, emphasizing the need for effective detection and treatment. It proposes using deep learning techniques, specifically Convolutional Neural Networks (CNN), to enhance the diagnosis of malaria by analyzing cell images. The study aims to develop a model that can improve early diagnosis and reduce complications associated with late detection.

Uploaded by

davidadebesin9
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)
2 views

full

The document discusses malaria, its symptoms, risk factors, and diagnostic methods, emphasizing the need for effective detection and treatment. It proposes using deep learning techniques, specifically Convolutional Neural Networks (CNN), to enhance the diagnosis of malaria by analyzing cell images. The study aims to develop a model that can improve early diagnosis and reduce complications associated with late detection.

Uploaded by

davidadebesin9
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/ 60

CHAPTER ONE

INTRODUCTION

1.1 Background of the study

Malaria, a significant cause of global mortality and illness, is induced by protozoan parasites from

the genus Plasmodium. It spreads through the bite of infected female Anopheles mosquitoes.

Symptoms of malaria can emerge within 6-8 days after being bitten or may appear several months

after leaving a malaria-endemic region. (Tuteja, 2007)

Malaria presents with a range of symptoms, including fever, fatigue, vomiting, headaches,

jaundice, diarrhea, excessive sweating, muscle and joint pain, seizures, and can result in coma or

death if not promptly and properly treated. The primary method for identifying malaria parasites

in human red blood cells is through microscopic examination. However, the accuracy of this

method can vary depending on the skill level of the microscopist. (Bayingana. et al, 2019)

1.2 Problem Statement

Malaria remains a significant global health challenge, with over 3.2 billion people in 91 countries

still at risk of the disease. The most vulnerable groups of people are children who have not

developed immunity and pregnant women whose immunity has decreased.

1.3 Aims and Objectives

Using Deep learning to detect parasitic cells.

1
Objectives to achieve

1. To review existing literature on machine learning and deep learning techniques that aid in early diagnosis.

2. To collect and preprocess Gather relevant medical data.

3. To prepare the data and tools used to create model for diagnosis prediction.

4. To evaluate the performance of the proposed model using appropriate data.

1.4 Proposed Methodology

1. Data Collection and Preprocessing: Gather and prepare relevant medical data, laboratory test

results, and all necessary data.

2. Feature Selection and Engineering: Select appropriate features from the dataset or perform

feature engineering to extract relevant information that can aid in the detection process.

3. Model Selection: The CNN model performs well for malaria cell detection, achieving high

accuracy and effectively reducing loss over epochs.

1.5 Scope of the Study

This study will focus on utilizing machine language to create a model that can detect parasitic cells by

relying on cell images obtained from the microscope.

1.6 Significance of the study

The successful development of the model can provide valuable insights for doctors. It can reduce the

problems caused by late diagnoses and can also help the doctor.

2
CHAPTER TWO

REVIEW OF LITERATURE

2.0 Introduction

Malaria is a disease that is caused by protozoan parasites of the genus Plasmodium (Kohli, & Das,

2018). It is mostly transmitted through the bite of an infected female Anopheles mosquito. Malaria

parasites have an intricate life cycle that encompasses both mosquito vectors and vertebrate hosts,

such as humans (Kataria. et al, 2022). Malaria is a major global health concern, leading to

significant mortality and morbidity worldwide.

2.1 Risk factors

Several factors can magnify the risk of contracting malaria. Some of the key risk factors include:

1. Geographical Location: Malaria is mostly concentrated in tropical and subtropical areas,

especially in sub-Saharan Africa, which is the main location for most cases. Additional

impacted regions include some locations in India, Brazil, and Southeast Asia.

2. Socioeconomic Status: Individuals residing in low-income nations or areas with restricted

healthcare access have an elevated risk owing to insufficient preventative and treatment

alternatives.

3. Environmental Conditions: Anopheles mosquitoes, which transmit malaria, thrive in

stagnant water habitats such as marshes and swamps. Therefore, being in or in close

proximity to such surroundings heightens the likelihood of danger.

3
4. Travel History: Individuals who go to regions with a high prevalence of malaria, without

taking appropriate prophylactic or preventative measures, are more likely to get infected

with the disease.

5. Susceptibility: Individuals who have not previously been exposed to malaria, such as small

children or individuals without immunity, are more likely to have severe illness. Pregnant

women are more susceptible to harm because of changes in their immune system during

pregnancy (Tuteja, 2007).

6. Drug resistance: The appearance of drug-resistant strains of Plasmodium falciparum raises

the likelihood of severe malaria and makes treatment more difficult.

It is essential to take preventive measures, such as using insecticide-treated bed nets, taking

antimalarial medications as prescribed, and seeking prompt medical attention if malaria is

suspected, to reduce the risk of contracting and spreading the disease.

2.2 Symptoms of Malaria

The symptoms of malaria vary thereby depends on the type of parasite which causes the infection

and the individual's immune response. Common symptoms of malaria include:

1. Fever: A prevalent symptom that might occur intermittently or persistently.

2. Chills and shivering: Frequently accompanying the fever, these symptoms may be quite

intense.

3. Headache: A prevalent grievance among those who are infected.

4. Joint Pain: Numerous individuals have discomfort in their joints and muscles.

5. Cough: Respiratory symptoms may also manifest.

4
6. Nausea and Vomiting: Gastrointestinal symptoms such as nausea and vomiting are often

noted.

7. Diarrhea: In some instances, there may be a presence of watery diarrhea.

8. Convulsions: Primarily seen in severe instances, particularly among youngsters.

9. Anemia: Anemia is a condition characterized by the process of red blood cell destruction

resulting to the manifestation of various symptoms, weariness and weakness.

10. Jaundice is a condition where the skin and eyes become yellow as a result of liver

dysfunction. (Tuteja, 2007).

It is important to note that symptoms of malaria can develop within a span of 6-8 days after a

mosquito bite from an infected insect, even several months later. If you have reason to believe that

you may have contracted malaria or have just visited a region with a high incidence of malaria and

are experiencing these symptoms, it is crucial to swiftly seek medical help for diagnosis and

treatment.

In terms of treatments, malaria is a curable illness when managed well and early. Quinine, extracted

from the bark of the Andean Cinchona tree, was the first extensively used medication for treating

malaria. Nevertheless, the parasite has the ability to quickly acquire resistance to widely used

antimalarial medications. Plasmodium falciparum has developed resistance to widely used

medications such as Fansidar and chloroquine in several areas. In order to address this issue, a

treatment approach known as combination therapy is being used more often. This involves the use

of artemisinin, derived from the Artemisia annua plant, in conjunction with other medications like

Fansidar or mefloquine (Tuteja, 2007).

5
It is crucial to swiftly seek medical aid for more accurate diagnosis and appropriate treatment if

there is suspicion of malaria.

2.3 Diagnosis of malaria

The diagnosis of malaria typically involves an amalgamation of clinical observations, medical

history, and laboratory testing. Here are some common methods used for diagnosing malaria:

1. Microscopic examination is often regarded as the most reliable way for diagnosing malaria.

The process entails extracting a blood sample from the patient, which is then applied as a

thin layer onto a glass slide. The slide is treated with a dye, often Giemsa stain, which

enhances the visibility of the malaria parasites. An adept laboratory technician uses a

microscope to scrutinize the stained blood smear in order to detect the existence of malaria

parasites and ascertain their kind. This approach is very efficient but it requires workers

who have received extensive training and the availability of appropriate laboratory

facilities.

2. Rapid Diagnostic Tests (RDTs) are immunochromatographic assays specifically

developed to identify and detect distinct antigens generated by malaria parasites. These

tests are user-friendly and provide findings within a timeframe of 15-30 minutes. A

minute quantity of blood is applied onto a diagnostic strip, and in the presence of malaria

antigens, a discernible line becomes apparent on the strip. Rapid diagnostic tests (RDTs)

are especially valuable in areas that lack access to microscopy, such as distant or

resource-constrained situations. Nevertheless, the precision of these tests may fluctuate

based on the test's quality and the incidence of malaria in the region.

Polymerase Chain Reaction (PCR) is a molecular method used to amplify the genetic

6
material of malaria parasites. This allows for the detection of even very low quantities of

parasites in the blood. This approach has a high level of sensitivity and specificity,

making it beneficial for verifying instances that are difficult to diagnose using

microscopy or RDTs. PCR may further be used for species identification of malaria

parasites and the detection of mixed infections. Nevertheless, the use of this technology is

limited in some environments due to the need of specific equipment and skilled staff.

3. Serological assays identify the presence of antibodies against malaria parasites in the

patient's blood. Although serological tests may provide evidence of previous exposure to

malaria, they are not often used to diagnose current infections. This is due to the fact that

antibodies have the ability to persist in the circulation for extended periods of time, ranging

from months to even years, after the resolution of the illness. Hence, serological tests are

more valuable for conducting epidemiological research and determining the prevalence of

malaria in a community, rather than for clinical diagnosis.

4. Clinical Diagnosis: In areas where malaria is often found, healthcare professionals may

diagnose malaria by evaluating the patient's clinical symptoms and medical background.

Typical manifestations of malaria are fever, chills, perspiration, headache, myalgia, and

weariness. Occasionally, patients may also encounter symptoms such as nausea,

vomiting, and diarrhea. Clinical diagnosis is often used in situations when laboratory

testing are unavailable or when urgent treatment is required. Nevertheless, it is less

dependable than laboratory-based techniques, as the manifestations of malaria might

7
coincide with those of other ailments.

5. Blood cultures, however not often used for malaria diagnosis, may sometimes be applied

to identify the existence of malaria parasites in the circulation. This technique involves

placing a blood sample in a culture medium to facilitate the growth and proliferation of any

parasites that may be present. The cultivated specimen is then scrutinized under a

microscope to discern the presence of parasites. Blood cultures are mostly used for the

diagnosis of bacterial diseases. However, they may also be beneficial in certain instances

of malaria (Tangpukdee et al., 2009).

2.4 Convolutional Neural Networks

A Convolutional Neural Network (CNN), commonly referred to as ConvNet, is a kind of neural

network designed specifically for analyzing data with a grid-like structure, such as images. A

digital picture is a representation of visual data using just two possible values, often 0 and 1. It

consists of a grid-like arrangement of pixels, each with pixel values indicating their brightness and

color (Mishra, 2021).

The human brain rapidly and efficiently analyzes a vast quantity of information as soon as we see

a picture. Every individual neuron operates within its own receptive field and is interconnected

with other neurons in a manner that collectively covers the full visual field. Similar to how each

neuron in the biological vision system only reacts to stimuli within a certain area of the visual field

8
known as the receptive field, each neuron in a CNN also analyzes data exclusively within its own

receptive field. The layers are organized in a manner that enables them to first recognize simpler

patterns, like as lines and curves, and then progress to identifying more intricate patterns, such as

faces and objects. Utilizing a Convolutional Neural Network (CNN) allows for the provision of

visual perception to computer systems (Mishra, 2021).

2.4.1 Convolutional Neural Network Architecture

i.Convolutional layer

CNN operates by doing a meticulous comparison of photos fragment by fragment. Filters have a

limited spatial size in terms of width and height, but they cover the whole depth of the input

picture. The architecture of the system allows it to identify a certain characteristic in the input

picture.

During the convolution layer, the filter/kernel is systematically shifted to each conceivable point

on the input matrix. The input picture is multiplied element-wise with the filter-sized patch, and

the resulting values are then summed by translating the filter to every possible point of the input

matrix of the picture, one may determine if a certain feature is present somewhere in the image.

The matrix that is produced as a consequence is referred to as the feature map.

Convolutional neural networks have the ability to simultaneously learn from numerous features.

During the last phase, we arrange all the output feature maps along with their depth and generate

the result. Feature maps are an essential component of Convolutional Neural Networks (CNNs).

9
Some crucial words that may come across when studying Convolutional Neural Networks. Local

connection pertains to pictures that are represented as a matrix of pixel values. The dimension of

the picture expands according to its size. When all the neurons in a layer are linked to all the

neurons in the preceding layer, as in a completely connected layer, the number of parameters

grows significantly. (Baheti, 2024)

In order to address this issue, we establish a connection between each neuron and a specific

section of input data. The geographic extent, sometimes referred to as the receptive field of the

neuron, dictates the dimensions of the filter.

Here is the practical implementation of how it functions— Assume that our input picture has

dimensions of 128 pixels in width, 128 pixels in height, and 3 color channels. Given a filter size

of 5*5*3, each neuron in the convolution layer will possess a sum of 75 weights (along with an

additional bias parameter of +1). The size and placement of neurons in the output volume are

determined by spatial organization. There are three hyperparameters that determine the

dimensions of the output volume:

The depth of the output volume is determined by the number of filters used to detect various

characteristics in the picture. The output volume consists of stacked activation/feature maps,

each with a depth equal to the number of filters applied.

Stride is the term used to describe the distance, measured in pixels, that we move the filter while

comparing it to the input picture patch. When the stride is set to one, the filters are shifted by one

pixel at a time. Increasing the stride will result in lower spatial output volumes.

10
Zero-padding is a technique that enables us to manipulate the spatial dimensions of the output

volume by adding zeros along the edges of the input data.

Parameter Sharing refers to the use of a single weight matrix to operate on all neurons inside a

certain feature map. This implies that the same filter is applied to various sections of the picture.

Statistical features of natural pictures include translation invariance. (Baheti, 2024)

Rectified Linear Unit (ReLU) Layer

The ReLU activation function is used in this layer, where any negative value in the output

volume from the convolution layer is substituted with zero. This is done to avoid the

accumulation of values resulting in zero.

ii. Convolutional Neural Network (CNN) Layer

Pooling layers are inserted between two convolution layers with the primary objective of

diminishing the spatial dimensions of the picture representation.

The pooling layer is characterized by two hyperparameters; Window size refers to the size of the

sliding window used in a computational process. Stride, on the other hand, refers to the step size

between consecutive windows.

For each window, we choose either the highest value or the average of the values in the window,

depending on the kind of pooling being done.

The Pooling Layer performs spatial resizing on each depth slice of the input individually, and

then combines them.

Pooling layer Different types of Pooling

i. Max Pooling extracts the highest value from each window of the feature map. Therefore, after

11
the max-pooling layer, the resulting output would be a feature map that consists of the most

prominent features from the preceding feature map.

ii. Average Pooling calculates the mean value of the elements within the area of the feature map

that is covered by the filter. It computes the mean value of the features in the feature map.

Pooling may be categorized into many types.

It is important to note that Max Pooling outperforms Average Pooling. (Baheti, 2024)

iii. Normalization Layer

Normalization layers serve the purpose of standardizing or normalizing the output of the

preceding levels. The insertion of this component between the convolution and pooling layers

enhances the network's ability to learn independently at each layer and mitigates the risk of

overfitting the model. Nevertheless, sophisticated designs do not use normalization layers due to

their limited contribution to successful training. A fully-connected layer is a kind of layer in a

neural network where each neuron is connected to every neuron in the previous layer. (Baheti,

2024) The Convolutional Layer, in conjunction with the Pooling Layer, constitutes a module

inside the Convolutional Neural Network. The quantity of these layers may be augmented to

capture more intricate features, contingent upon the intricacy of the job, but at the expense of

more computer power. A fully connected layer in a convolutional neural network (CNN) is a

layer where each neuron is connected to every neuron in the previous layer. This layer is

responsible for learning complex patterns and relationships in the input data.

After successfully completing the key feature extraction process, we will flatten the final feature

representation and input it into a fully-connected neural network for the purpose of picture

classification. (Baheti, 2024)

12
2.5 Related works

(Kazeem & Adebanji, 2021) discusses a model developed by researchers at Osun State University

for predicting malaria outbreaks. The study focuses on the relationship between meteorological

data and malaria outbreaks, utilizing machine learning algorithms to make predictions based on

this data.

Key points from the document include:

1. Feature selection process using correlation matrix to identify relevant features for training

and testing the models.

2. Data partitioning into training and testing sets, with the application of classification

algorithms like KNN, Support Vector Machine, Logistic Regression, Linear Regression,

and Naive Bayes.

3. Results showing the training and testing accuracies of different algorithms, with Naive

Bayes performing well in predicting malaria outbreaks.

4. Emphasis on the importance of developing effective models to predict malaria outbreaks

to assist health workers, governments, and hospitals in implementing preventive measures.

Machine learning was utilized to develop a model for predicting malaria outbreaks. Here is how

machine learning was used in the study:

1. Data Acquisition: Meteorological data and malaria incidence data from Osun State,

Nigeria, were collected for the years 2010-2020. This data served as the basis for

training and testing the machine learning models.

13
2. Data Preprocessing: The collected data underwent preprocessing, which involved

cleaning, transformation, and feature selection to prepare it for analysis by machine

learning algorithms.

3. Model Training: The data was divided into a training set (70%) and a test set (30%).

Machine learning models, including Support Vector Machine (SVM), K-Nearest

Neighbor (K-NN), Logistic Regression (LoR), Linear Regression (LiR), and Naive

Bayes, were trained using the training data.

4. Model Evaluation: After training, the models were tested using the remaining 30% of

the preprocessed data. The performance of the models was evaluated using metrics such

as accuracy, with Naive Bayes showing the best accuracy for predicting malaria

outbreaks.

5. Algorithm Selection: Different supervised machine learning algorithms were employed

to analyze the data and predict malaria outbreaks based on meteorological and

incidence data.

6. Confusion Matrix: The performance of the prediction models was assessed using a

confusion matrix, which helps evaluate the accuracy of the models in predicting malaria

outbreaks.

By leveraging machine learning techniques and algorithms, the researchers were able to develop

a predictive model that could assist in forecasting malaria outbreaks based on the collected data.

14
Table 2.1: A Summary of Related Works

S/N AUTHOR TITLE METHOD RESULT LIMITATION

1. Kazeem & A model for Machine This Lack of

Adebanji predicting learning shows that exploration into

Malaria models, Naive deep learning


(2021)
outbreak using including Bayes methods

machine Support algorithm

language Vector can be

Machine used to

(SVM), K- develop a

Nearest model for

Neighbor (K- predicting

NN), Logistic malaria

Regression outbreak

(LoR), Linear

Regression

(LiR), and

Naive Bayes,

were trained

using the

training data.

15
2 Zhang et Convolutional Data The CNN The study faced

al. (2019) neural network augmentation model a challenge of

for and dropout achieved overfitting due

classification regularization an to the small size

of blood cells accuracy of the dataset.

into five of 96.5%

categories in

classifying

the cells

16
3 Hamisu Malaria Developing a The accuracy obtained in The research study is

Ismail prediction model based training Malaria dataset by limited to be used

Ahmad using Bayes on decision the 4 different classification only on malaria cases

and other support algorithms. It indicates that within health care


(2019)
machine system to Decision tree (J48) has the environment and is

learning predict the greater accuracy with 88.4% limited to only

techniques disease quite followed by Naïve Bayes Classification

accurately with 79.9%, then OneR and models that use a

avoiding ZeroR with the accuracy of frequency table, and

skewed 79.8% and 60.9% uses only one of the

distribution respectively method for

data Increasing

performance of

classification

algorithm which is

Boosting, the study

also highlighted the

significance and

power of Decision

tree (J48) over Naïve

Bayes, ZeroR and

17
OneR classifiers in

supervised learning.

18
4 Rajaraman Pre-trained Utilized pre- Performance: Achieved an The study's results

et al. convolutional trained accuracy of over 95% for were based on a

(2018) neural convolutional malaria parasite detection. relatively small

networks as neural dataset, which may

feature networks affect

extractors (CNNs) as generalizability

toward feature

improved extractors for

malaria malaria

parasite parasite

detection in detection in

thin blood thin blood

smear images smear

images.

19
5 Dong et al. Evaluations of Evaluated Reported accuracy rates The dataset was

(2017) deep deep ranging from 93% to 97%. relatively small,

convolutional convolutional potentially limiting

neural neural generalizability.

networks for networks for

automatic automatic

identification identification.

of malaria

infected cells.

6 Liang et al. CNN-based Implemented Limited by variability in

(2018) image analysis a CNN-based blood smear image quality

for malaria approach for and staining techniques

diagnosis malaria

diagnosis

20
7 Bajpai et Deep learning Developed Achieved accuracy levels of Models need more

al. (2020) models for and evaluated 94% to 97%. extensive testing

automated deep learning across diverse

diagnosis of models for datasets for

malaria automated robustness

disease using diagnosis.

microscopic

blood smear

images

21
CHAPTER THREE

METHODOLOGY

3.0 Introduction

The chapter covers the description and discussion of the various techniques that will be used in the

study to collect and analyze data along with different procedures and methods that will be

implemented for the development of parasitized cell detection using deep learning.

3.1 Method of Data collection

Kaggle was the secondary source from which the data for this project was sourced. On the website

Kaggle, users and data scientists may collaborate with one another to solve global data science

problems, publish their datasets, and create machine learning models in a web-based environment.

The source of the dataset is (https://www.kaggle.com/datasets/iarunava/cell-images-for-detecting-

malaria).

3.1.1 Data Description

The dataset "Cell Images for Detecting Malaria" on Kaggle contains images of blood cells infected

with malaria parasites, as well as healthy cells, for the purpose of training machine learning models

to detect malaria. The dataset consists of:

i. 27,558 images of parasitized cells

ii. 13,779 images of uninfected cells

iii. Images are in PNG format

iv. Images are labeled as "Parasitized" or "Uninfected"

22
Figure 3.1: Parasitized cell

Figure 3.2: Uninfected cell

3.2 ANALYSIS OF THE MODEL

The model is a CNN built using TensorFlow and Keras. The model is a Convolutional Neural

Network (CNN) designed for binary classification of images into parasitized or uninfected cells It

consists of:

1. four convolutional layers with ReLU activation and max pooling.

2. A flattening layer to convert the 2D matrix to a vector.

3. A dense layer with 512 neurons and ReLU activation.

4. An output layer with a single neuron and sigmoid activation for binary classification.

23
This architecture uses convolutional layers to extract features from the images, max-pooling layers

to reduce dimensionality, and fully connected dense layers to perform the final classification. The

model is designed to differentiate between parasitized and uninfected cells based on the learned

features from the input images.

3.3 DESIGN AND IMPLEMENTATION OF THE PREDICTIVE MODEL

The diagrams that will be used to design a model for malaria-infected cells are:

i. Architectural Diagram for the model

ii. Flow chart diagram for the model.

The model's implementation is explained in the architecture. 30% of the data was used for testing

the model and 70% of the data was obtained from Kaggle for the initial data set.

24
3.3.1 Architectural Diagram for the model

Figure 3.3: Architectural diagram of the Predictive Model

25
3.3.2 Flow chart diagram

Figure 3.4: Flow chart diagram

26
3.4 System Development Life Cycle

The software development lifecycle (SDLC) is the cost-effective and time-efficient process that

development teams use to design and build high-quality software. The goal of SDLC is to minimize

project risks through forward planning so that software meets customer expectations during

production and beyond. This methodology outlines a series of steps that divide the software

development process into tasks you can assign, complete, and measure. Software development can

be challenging to manage due to changing requirements, technology upgrades, and cross-

functional collaboration. The software development lifecycle (SDLC) methodology provides a

systematic management framework with specific deliverables at every stage of the software

development process. As a result, all stakeholders agree on software development goals and

requirements upfront and also have a plan to achieve those goals. A software development lifecycle

(SDLC) model conceptually presents SDLC in an organized fashion to help organizations

implement it. Different models arrange the SDLC phases in varying chronological order to

optimize the development cycle. In traditional software development, security testing was a

separate process from the software development lifecycle (SDLC). The security team discovered

security flaws only after they had built the software. This led to a high number of bugs that

remained hidden as well as increased security risks (“What Is SDLC? - Software Development

Lifecycle Explained - AWS,” n.d.). The SDLC diagram which shows the sequential steps to be

taken in this project are shown in figure 3.5.

27
Figure 3.5: SDLC diagram for the Models to be Built

1. Problem definition: The problem definition in this project is to detect parasitic and non

parasitic cells

28
2. Data selection: The dataset was gotten from Kaggle, which was described in Table 3.1

3. Exploratory Data Analysis: Tableau would be used to provide any insight and graphical

representation

4. Model selection: When evaluating which model performs best on the malaria cell image

dataset using a custom Convolutional Neural Network (CNN) was decided

5. Model training: The Model was trained

6. Testing: The Model was tested to check if it is functional before it is then evaluated

7. Model evaluation: Using the Confusion Matrix to evaluate

8. Review: In this last phase, all other phases were reviewed to know if the model provided a

solution to the earlier stated problem in chapter one.

29
CHAPTER FOUR

SYSTEM IMPLEMENTATION AND RESULTS DISCUSSION

4.0 INTRODUCTION

This chapter reported the implementation procedure for student’s academic performance using

python and visualization tools. It consists of 27,558 images of cell images, classified into

parasitized and uninfected categories and the data virtualization on the essential attributes,

performance evaluation of the algorithm chosen, code snippets, screenshots of the model, and the

tools used to achieve the obtained results.

4.1 Features Of Dataset Based On Data Attributes

The Kaggle dataset "Cell Images for Detecting Malaria" consists of 27,558 images of cell images,

classified into parasitized and uninfected categories. Each category contains thousands of images,

which can be used to train machine learning models for detecting malaria from blood smear

samples. The dataset is structured into two main folders: "Parasitized" and "Uninfected," each

containing images in PNG format. It was gotten through the link below;

https://www.kaggle.com/datasets/iarunava/cell-images-for-detecting-malaria

Before data exploration was carried out for the training of the model using the random forest

algorithm, the following libraries were imported in jupyter notebook.

1. Shutil

30
2. Numpy

3. Tensorflow

4. Panda

5. Shutil: This module offers a number of high-level operations on files and collections of

files. It’s especially useful for copying and removing files.

6. Numpy: A fundamental package for scientific computing with Python. It supports large,

multi-dimensional arrays and matrices, along with a collection of mathematical functions

to operate on these arrays.

7. TensorFlow: An open-source library developed by Google for machine learning and deep

learning. It’s widely used for building and training neural networks.

After the necessary libraries for virtualization and preprocessing had been imported as shown in

Figure4.1a, the next step was the reading of the data from the directory it’s located using pandas

library, the head and tail of the dataset was printed. Figure 4.1b also shows the head and tail of the

dataset being displayed.

31
Figure4.1a: Python libraries imported into the Jupyter Notebook

4.2 Data Visualization Based on Dataset Attributes

The dataset contains 27,558 images classified into "Parasitized" and "Uninfected" categories,

stored in two folders:

Parasitized: Images of red blood cells infected with malaria parasites.

Uninfected: Images of healthy red blood cells.

32
4.2.1 Library tools for Data Visualization

i. Anaconda environment

ii. Jupyter noteboo

4.2.2 Abstraction of Directories

The creation of directory paths and using functions to manage file operations without altering the

actual structure.

Figure 4.2a: Shows the creation of directory paths

33
4.3 Data Preprocessing

Data processing is the steps taken to prepare and manipulate the data for training a machine

learning model. This includes handling, transforming, and augmenting the data to ensure it is

suitable for input into the model. Here’s a breakdown of the data processing steps used in this

project:

4.3.1 File Organization

Splitting images into training and testing sets based on a specified ratio. The ratio used is 80 for

file training to 20 for testing

34
Figure 4.3a: Shows the splitting of images into training and testing sets

4.3.2 Image Scaling and Data Augmentation

Rescaling image pixel values and augmenting training data, which improves model generalization.

using ImageDataGenerator.

35
Figure 4.3b: Shows the rescaling and augmentation of image

4.4 Model Creation

The model is created using TensorFlow Keras for image classification. Here’s a concise

explanation of how the model is structured and created based on the code:

4.4.1 Sequential Model Initialization:

The Sequential() function initializes a linear stack of layers. This model allows you to add layers

sequentially from input to output.

36
4.4.2 Convolutional Layers:

Convolutional layers (Conv2D) are added to extract features from the input images. Each Conv2D

layer applies a set of filters to the input, with each filter learning different features.

After each Conv2D layer, a MaxPooling2D layer is added to downsample the feature maps,

reducing their spatial dimensions. This process helps in focusing on the most important features

and reducing computational complexity.

4.4.3 Flatten Layer:

The Flatten() layer converts the 2D feature map into a 1D vector. This flattened output is then fed

into the dense layers.

4.4.4 Dense Layers

Dense layers (Dense) are fully connected layers that perform the final classification based on the

features extracted by the convolutional layers.

The model architecture includes two dense layers: one with 512 units and ReLU activation for

learning complex representations, and the final layer with 1 unit and sigmoid activation for binary

classification (outputting probabilities).

4.4.5 Compilation

The compile() method configures the model for training. Here, the optimizer (RMSprop) adjusts

the model's weights during training to minimize the binary_crossentropy loss function. The metric

used to evaluate the model performance during training is accuracy (acc).

37
4.4.6 Model Summary

The summary() method prints a detailed summary of the model architecture, including the type

and number of parameters in each layer. This summary helps in understanding the model's structure

and the flow of data through it.

38
Figure 4.4a: Shows the creation of model

39
4.5 Evaluation Metrics

Based on the observed accuracy, loss metrics, and visualizations from the code snippet:

The CNN model performs moderately well for malaria detection, achieving an average accuracy

and reducing loss over 5 epochs.

The plotted graphs confirm the model's learning progress and stability, showcasing consistent

improvements in accuracy and reductions in loss.

This indicates that the model is well-suited for classifying parasitized and uninfected cell images,.

40
Figure 4.5a Shows the validation and conclusion reached

41
Confusion Matrix: The code first resets the validation data generator and uses the model to predict

the class labels for the validation set. These predictions are compared to the true class labels to

compute the confusion matrix, which is then printed. The confusion matrix shows the counts of

true positive, true negative, false positive, and false negative predictions, providing insight into

the model's accuracy for each class. The matrix is also visualized using a color-coded plot, with

normalized values and annotations for clarity.

Classification Report: Following the confusion matrix, the code prints a classification report that

includes precision, recall, and F1-score for each class (Parasitized and Uninfected). These metrics

offer a detailed view of the model's performance, highlighting how well it distinguishes between

the two classes. The report helps in assessing the model's effectiveness and identifying areas for

improvement.

42
Figure 4.5b Shows the code matrix

43
Figure 4.5c: Shows the confusion matrix and the classification report

44
CHAPTER FIVE

SUMMARY, CONCLUSION AND RECOMMENDATION

5.0 Introduction

This chapter outlines the study's limitations and summarizes the investigation from the

introduction to the conclusion.

5.1 Summary

This study will focus on utilizing machine language to create a model that can detect parasitic cells

by relying on cell images obtained from the microscope. The methodology chapter details the data

collection, analysis of the model, design, and implementation procedures. Data was sourced from

Kaggle, specifically the "Cell Images for Detecting Malaria" dataset, which contains images of

parasitized and uninfected blood cells. A Convolutional Neural Network (CNN) was designed

using TensorFlow and Keras to classify these images. The CNN model consists of three

convolutional layers, a flattening layer, a dense layer, and an output layer, all aimed at

distinguishing between parasitized and uninfected cells.

The project follows a systematic approach using the Software Development Life Cycle (SDLC),

ensuring structured development and minimizing risks. The dataset is split into training and testing

sets, and various Python libraries are employed for data visualization and preprocessing. The CNN

model's architecture is described in detail, including its layers and functions. The implementation

chapter showcases the steps taken in developing the model, including data visualization,

preprocessing, and model creation. The results demonstrate the model's effectiveness in detecting

malaria-infected cells.

45
5.2 Conclusion

The developed CNN model demonstrates robust performance in classifying parasitized and

uninfected cell images, achieving high accuracy and effectively reducing loss over epochs. The

systematic approach of the SDLC, combined with the use of advanced data visualization and

preprocessing techniques, contributes to the model's success. The results indicate that the model is

well-suited for the task, showcasing consistent improvements in accuracy and stability across

training and validation datasets.

5.3 Limitations

• Dataset Specificity: The model was trained specifically on the "Cell Images for Detecting

Malaria" dataset, which may limit its generalizability to other types of datasets or real-

world applications without further adjustments and retraining.

• Data Quality and Diversity: The dataset used may not encompass all variations of malaria-

infected and uninfected cells, potentially impacting the model's performance on new,

unseen data.

• Computational Resources: Training deep learning models like CNNs require substantial

computational power, which might be a limitation for individuals or organizations with

limited access to high-performance computing resources.

• Overfitting: Despite measures to prevent it, the model may still be prone to overfitting,

especially given the high number of parameters in CNNs and the specific characteristics of

the training dataset.

46
5.4 Recommendations

• Expand Dataset: To improve the model's generalizability, it is recommended to expand the

dataset by including images from diverse sources and varying conditions.

• Data Augmentation: Implement more sophisticated data augmentation techniques to

increase the variability of the training data, thereby improving the model's robustness.

• Model Optimization: Explore and experiment with different model architectures and

hyperparameter tuning to optimize the model's performance.

• Cross-Validation: Use cross-validation techniques to better assess the model's performance

and reduce the risk of overfitting.

• Real-World Testing: Validate the model with real-world data to assess its practical

applicability and make necessary adjustments based on the findings.

• Computational Efficiency: Investigate methods to reduce the computational load, such as

model pruning or quantization, making the model more accessible for deployment in

resource-constrained environments.

47
REFERENCE
Abadi, M., Barham, P., Chen, J., Chen, Z., Davis, A., Dean, J., ... & Zheng, X. (2016). TensorFlow:
A system for large-scale machine learning. In *12th {USENIX} Symposium on Operating
Systems Design and Implementation ({OSDI} 16)* (pp. 265-283).

Ahmad, H. I. (2019). Malaria prediction using Bayesian and other machine learning
techniques (Master's thesis, African University of Science and Technology).

Baheti, P. (2024). A Comprehensive Guide to Convolutional Neural Networks. V7.


https://www.v7labs.com/blog/convolutional-neural-networks-guide

Bajpai, V. K., Mishra, A., & Deep, S. (2020). Deep learning models for automated diagnosis of
malaria disease using microscopic blood smear images. In 2020 International Conference
on Computational Intelligence and Knowledge Economy (ICCIKE) (pp. 1-5). IEEE.
https://doi.org/10.1109/ICCIKE48582.2020.9319361

Dong, Y., Jiang, Z., Shen, H., Pan, W., Williams, L. A., Osen, K. K., ... & Sahni, N. (2017).
Evaluations of deep convolutional neural networks for automatic identification of malaria
infected cells. In 2017 IEEE EMBS International Conference on Biomedical & Health
Informatics (BHI) (pp. 101-104). IEEE. https://doi.org/10.1109/BHI.2017.7897226

Harris, C. R., Millman, K. J., van der Walt, S. J., Gommers, R., Virtanen, P., Cournapeau, D., ... &
Oliphant, T. E. (2020). Array programming with NumPy. *Nature*, 585(7825), 357-362.
https://doi.org/10.1038/s41586-020-2649-2

Iradukunda, O., Che, H., Uwineza, J., Bayingana, J. Y., Bin-Imam, M. S., & Niyonzima, I. (2019).
Malaria Disease Prediction Based on Machine Learning. School of Computer Science and
Technology, Beijing Institute of Technology, Beijing, China.

Kataria, P., Surela, N., Chaudhary, A., Das, J., & Das, J. (2022). MiRNA: Biological Regulator in
Host-Parasite Interaction during Malaria Infection. International Journal of Environmental
Research and Public Health, 19(4), 2395.
Kazeem, I., & Adebanji, S. (2021). A model for predicting malaria outbreak using machine
learning technique. Scientific Annals of Computer Science.

Kohli, K., & Das, A. K. (2018). Clinicopathological profile of malaria patients in an Central
African United Nations hospital. https://doi.org/10.18203/2320-6012.ijrms20184915
Liang, Z., Powell, A., Ersoy, I., Poostchi, M., Silamut, K., Palaniappan, K., & Hossain, M. A.
(2018). CNN-based image analysis for malaria diagnosis. In 2018 IEEE International
Conference on Bioinformatics and Biomedicine (BIBM) (pp. 2714-2721). IEEE.
https://doi.org/10.1109/BIBM.2018.8621490

Mishra, M. (2021, December 15). Convolutional Neural Networks, Explained - Towards Data
Science. Medium. https://towardsdatascience.com/convolutional-neural-networks-
explained-9cc5188c4939?gi=92ba89675a70

48
Python Software Foundation. (n.d.). Shutil — high-level file operations. In *Python
documentation*. Retrieved from https://docs.python.org/3/library/shutil.html

R. Tuteja Malaria (2007). An Overview. As published in The FEBS Journal

Rajaraman, S., Antani, S. K., Poostchi, M., Silamut, K., Hossain, M. A., Maude, R. J., ... & Thoma,
G. R. (2018). Pre-trained convolutional neural networks as feature extractors toward
improved malaria parasite detection in thin blood smear images. PeerJ, 6, e4568.
https://doi.org/10.7717/peerj.4568

Tangpukdee, N., Duangdee, C., Wilairatana, P., & Krudsood, S. (2009). Malaria diagnosis: A brief
review. The Korean Journal of Parasitology, 47(2), 93-102.
https://doi.org/10.3347/kjp.2009.47.2.93

Zhang, L., Xie, J., Shen, C., Ji, X., Wang, Y., & Ye, Q. (2019). Blood cell image classification
using convolutional neural networks. Journal of Medical Systems, 43(11), 353

49
APPENDIX

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import tensorflow as tf

import shutil

import zipfile

import os

import random

from tensorflow.python.keras.optimizer_v2 import rmsprop as rp

from tensorflow.keras.preprocessing.image import ImageDataGenerator

from shutil import copyfile

from os import getcwd

import matplotlib.pyplot as plt

from sklearn.metrics import confusion_matrix, classification_report

print(os.listdir(r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj'))

try:

os.mkdir(r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images')

os.mkdir(r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images/training')

os.mkdir(r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images/testing')

50
os.mkdir(r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images/training/para')

os.mkdir(r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images/training/uninf')

os.mkdir(r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images/testing/para')

os.mkdir(r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images/testing/uninf')

except OSError:

pass

def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE):

files = []

for filename in os.listdir(SOURCE):

file = os.path.join(SOURCE, filename)

if os.path.getsize(file) > 0:

files.append(filename)

else:

print(filename + " is zero length, so ignoring.")

training_length = int(len(files) * SPLIT_SIZE)

testing_length = len(files) - training_length

shuffled_set = random.sample(files, len(files))

51
training_set = shuffled_set[:training_length]

testing_set = shuffled_set[training_length:]

for filename in training_set:

this_file = os.path.join(SOURCE, filename)

destination = os.path.join(TRAINING, filename)

shutil.copyfile(this_file, destination)

for filename in testing_set:

this_file = os.path.join(SOURCE, filename)

destination = os.path.join(TESTING, filename)

shutil.copyfile(this_file, destination)

# Define source and destination directories

PAR_SOURCE_DIR = r'C:\Users\Belema\Desktop\DAVID

ADEBESIN\proj\cell_images\Parasitized'

TRAINING_PAR_DIR = r'C:\Users\Belema\Desktop\DAVID

ADEBESIN\proj\images\training\para'

TESTING_PAR_DIR = r'C:\Users\Belema\Desktop\DAVID

ADEBESIN\proj\images\testing\para'

52
UNI_SOURCE_DIR = r'C:\Users\Belema\Desktop\DAVID

ADEBESIN\proj\cell_images\Uninfected'

TRAINING_UNI_DIR = r'C:\Users\Belema\Desktop\DAVID

ADEBESIN\proj\images\training\uninf'

TESTING_UNI_DIR = r'C:\Users\Belema\Desktop\DAVID

ADEBESIN\proj\images\testing\uninf'

# Split ratio

split_size = 0.8

# Splitting the data

split_data(PAR_SOURCE_DIR, TRAINING_PAR_DIR, TESTING_PAR_DIR, split_size)

split_data(UNI_SOURCE_DIR, TRAINING_UNI_DIR, TESTING_UNI_DIR, split_size)

print(len(os.listdir(r"C:\Users\Belema\Desktop\DAVID

ADEBESIN/proj/images/training/para/")))

print(len(os.listdir(r"C:\Users\Belema\Desktop\DAVID

ADEBESIN/proj/images/testing/para/")))

print(len(os.listdir(r"C:\Users\Belema\Desktop\DAVID

ADEBESIN/proj/images/training/uninf/")))

print(len(os.listdir(r"C:\Users\Belema\Desktop\DAVID

ADEBESIN/proj/images/testing/uninf/")))

53
train_datagen = ImageDataGenerator(

rescale=1.0/255.,

rotation_range=40,

width_shift_range=0.2,

height_shift_range=0.2,

shear_range=0.2,

zoom_range=0.2,

horizontal_flip=True,

fill_mode='nearest'

model = tf.keras.models.Sequential([

tf.keras.layers.Conv2D(32, (3,3), activation='relu', input_shape=(150, 150, 3)),

tf.keras.layers.MaxPooling2D(2,2),

tf.keras.layers.Conv2D(64, (3,3), activation='relu'),

tf.keras.layers.MaxPooling2D(2,2),

tf.keras.layers.Conv2D(128, (3,3), activation='relu'),

tf.keras.layers.MaxPooling2D(2,2),

tf.keras.layers.Conv2D(128, (3,3), activation='relu'),

tf.keras.layers.MaxPooling2D(2,2),

54
tf.keras.layers.Flatten(),

tf.keras.layers.Dense(512, activation='relu'),

tf.keras.layers.Dense(1, activation='sigmoid')

])

# Compile the model using the specified optimizer

model.compile(optimizer="rmsprop", loss='binary_crossentropy', metrics=['acc'])

# Display the model summary

model.summary()

from tensorflow.keras.callbacks import EarlyStopping

early_stopping = EarlyStopping(monitor='val_loss', patience=3, restore_best_weights=True)

TRAINING_DIR = r'C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images/training/'

train_datagen = ImageDataGenerator( rescale = 1.0/255. )

train_generator = train_datagen.flow_from_directory(TRAINING_DIR,

batch_size=10,

class_mode='binary',

55
target_size=(150, 150))

VALIDATION_DIR = r"C:\Users\Belema\Desktop\DAVID ADEBESIN/proj/images/testing/"

validation_datagen = ImageDataGenerator( rescale = 1.0/255. )

validation_generator = validation_datagen.flow_from_directory(VALIDATION_DIR,

history = model.fit(

train_generator,

epochs=5,

validation_data=validation_generator,

callbacks=[early_stopping]

%matplotlib inline

import matplotlib.image as mpimg

import matplotlib.pyplot as plt

#-----------------------------------------------------------

# Retrieve a list of list results on training and test data

56
# sets for each training epoch

#-----------------------------------------------------------

acc=history.history['acc']

val_acc=history.history['val_acc']

loss=history.history['loss']

val_loss=history.history['val_loss']

epochs=range(len(acc)) # Get number of epochs

#------------------------------------------------

# Plot training and validation accuracy per epoch

#------------------------------------------------

plt.plot(epochs, acc, 'r', "Training Accuracy")

plt.plot(epochs, val_acc, 'b', "Validation Accuracy")

plt.title('Training and validation accuracy')

plt.figure()

#------------------------------------------------

# Plot training and validation loss per epoch

57
#-----------------------------------------------

plt.plot(epochs, loss, 'r', "Training Loss")

plt.plot(epochs, val_loss, 'b', "Validation Loss")

plt.title('Training and validation loss')

batch_size=10,

class_mode = 'binary',

target_size = (150, 150))

# Confusion Matrix

validation_generator.reset()

Y_pred = model.predict(validation_generator, len(validation_generator))

y_pred = np.round(Y_pred).astype(int).flatten()

true_classes = validation_generator.classes

class_labels = list(validation_generator.class_indices.keys())

cm = confusion_matrix(true_classes, y_pred)

58
print('Confusion Matrix')

print(cm)

# Plotting confusion matrix without seaborn

plt.figure(figsize=(8, 8))

plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)

plt.title('Confusion Matrix')

plt.colorbar()

tick_marks = np.arange(len(class_labels))

plt.xticks(tick_marks, class_labels, rotation=45)

plt.yticks(tick_marks, class_labels)

# Normalize the confusion matrix

cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]

thresh = cm.max() / 2.

for i, j in np.ndindex(cm.shape):

plt.text(j, i, f"{cm[i, j]:.2f}",

horizontalalignment="center",

59
color="white" if cm[i, j] > thresh else "black")

plt.ylabel('True label')

plt.xlabel('Predicted label')

plt.show()

# Classification Report

print('Classification Report')

target_names = ['Parasitized', 'Uninfected']

print(classification_report(true_classes, y_pred, target_names=target_names))

60

You might also like