Skin Cancer Prediction
Skin Cancer Prediction
1
Chapter 3
Methodology
3.1 Introduction
The methodology section outlines the particular stages and procedures necessary to ensure
the project's successful completion, acting as a road map for carrying out the whole project.
In this situation, a data engineering model is used to direct the process, highlighting the
crucial tasks of selecting the data sets, training the models, and producing automated models.
This model not only clarifies the importance of these crucial activities but also offers a
planned framework for carrying them out.
The initial stage of the research is a thorough analysis of the difficulties in creating a skin
cancer detection system. This contains a critical analysis of earlier studies, with an emphasis
on significant dermatology-related papers by scholars like (Gouda, Sama, Al-Waakid,
Humayun, & Jhanjhi, 2022) and (Agrahari, Agrawal, & Subhashini, 2022). By highlighting
the diverse uses of machine learning algorithms for skin cancer classification, these studies
2
shed crucial light on the complicated realm of skin cancer detection. The information gained
from this analysis serves as the foundation for determining the research's direction,
methodology, and goals and lays the platform for the creation of a thorough framework for
real-time skin cancer diagnosis.
The choice of dataset has a significant influence on the objective of creating a reliable skin
cancer detection model, making it an important stage in the research process. To make sure
they are in accordance with the objectives and challenges of the study, it is necessary to
evaluate the datasets that are already accessible carefully.
Skin cancer detection using deep learning strongly relies on feature engineering, which
influences the model's sensitivity to minuscule inputs associated with malignancy. The
features' careful design increases the model's reliability and accuracy, allowing it to catch
complex patterns indicative of many forms of skin cancer. Effective feature selection and
extraction are crucial for the system to be able to identify and distinguish between a wide
range of skin lesions using imaging data. The dataset choice has a direct impact on the
system's overall reliability and effectiveness in real-time skin cancer detection applications,
which also has an impact on the capacity of the model to generalize to new and untested
situations. This phase demands meticulous examination and analysis to ensure that the
selected dataset significantly assists in achieving the primary research aims.
In this stage, the carefully curated dataset acts as the model's training ground, enabling it to
automatically recognize and categorize different types of skin cancer based on the supplied
data. The model is exposed to a wide range of skin lesions and the diagnoses that go along
with them, which helps it develop a profound awareness of complex patterns and
correlations. The model improves its internal parameters through repetitive training cycles,
becoming more adept at identifying the traits and traits indicative of various skin cancer
situations. The accuracy of the model and its capacity to generalize to real-world events are
directly influenced by the efficiency of this training process, which ultimately determines
how well the model performs in real-time skin cancer detection. As a result, this phase of the
3
research is crucial since it is at this point that the model transforms from a simple idea into a
sophisticated tool that can precisely identify skin cancer from imaging data.
After the training procedure is finished, this stage comprises running model tests to evaluate
the system's capacity to identify skin cancer automatically.
The evaluation of the skin cancer detection model is a crucial stage in determining its
effectiveness and robustness. To evaluate the model's precision and dependability in spotting
various skin cancer forms, a variety of criteria can be used.
Because it covers a number of critical concerns that are hurdles in this area, the HAM10000
dataset was selected for neural network training in the automated detection of pigmented skin
lesions. The "Human Against Machine with 10,000 Training Images" (HAM10000) dataset
was created specifically to overcome the challenges caused by the limited size and lack of
variety in existing mesoscopic image datasets. This dataset was meticulously acquired from
various populations and recorded using several modalities to provide a more thorough
depiction of skin illnesses and lesion types. The HAM10000 dataset, which comprises 10,015
dermatoscopic pictures, offers a diverse training set for academic machine learning. It covers
a wide spectrum of significant diagnostic categories within the realm of pigmented lesions,
including “Actinic keratoses and intraepithelial carcinoma (apiece), basal cell carcinoma
(bcc), benign keratosis-like lesions (solar lentigines / seborrheic keratoses and lichen-planus
like keratoses, bkl), dermatofibroma (df), melanoma (mel), melanocytic nevi (nv), and
vascular lesions (angiomas, angiokeratomas, pyogenic granulomas, and hemorrhage, vasc)”.
The skin cancer detection model's training and testing stages follow a strict two-step
procedure that was rigorously planned to evaluate the model's performance and its capacity
for generalization. This methodological rigor makes sure the model can apply what it has
learned to situations in real life that it has never faced. The training dataset, which serves as
4
the model's educational basis, is presented to it during the first training phase. In this stage,
the model diligently seeks and understands complex data patterns. The training dataset
includes a wide variety of skin lesions, each of which represents unique properties. For the
model to react appropriately to the variety of features included in the training dataset, it must
modify its internal settings and representations. Thanks to this adaptive learning process, the
model may continually increase the accuracy of its detection and classification, assuring its
competence in categorizing various forms of skin cancer. A special testing dataset made up of
images of skin lesions that the model has never seen is introduced after the training phase.
This distinction is crucial because it mimics circumstances in which the model will need to
apply its expertise to evaluate odd or uncharted skin lesions. The model's applicability and
ability to accurately predict the types of skin cancer in these uncharted domains are assessed
throughout the testing phase. The testing step that follows is an important assessment process
since it assesses the model's fitness for deployment in the real world. By presenting the model
with images of previously unseen skin lesions, it assesses the model's capacity for
generalization. The exact reproduction of real-world events, which displays the model's
ability to adapt and provide relevant information in dynamic, ever-changing clinical contexts,
demonstrates the model's reliability and adaptability.
The Jupyter Notebook environment has wisely been used as the main platform for model
construction and evaluation in the development and experimentation of the skin cancer
detection model. In order to construct and improve machine learning models iteratively,
Jupyter Notebook provides a flexible and dynamic workspace that seamlessly blends code,
visuals, and documentation. This platform supports a step-by-step model creation process and
allows for real-time display and data analysis of model performance. Additionally, the
research team can work together effectively, share insights, and organize and document
findings thanks to Jupyter Notebook's collaborative features. This improves the overall
research process and fosters effective teamwork in the pursuit of skin cancer detection
excellence.
3.5 Summary
5
The study approach is described in the methodology chapter and includes data gathering from
the HAM10000 dataset, preparation via picture augmentation and standardization, and the
creation of the CNN model architecture. The model is trained to utilize particular
optimization strategies, and its effectiveness is assessed using particular metrics. The
systematic and structured path toward reaching the study objectives is ensured by this
systematic approach, which also serves as a clear road map for the succeeding phases of
experimentation and analysis.
6
Chapter 4
4.1 Introduction
The underlying concepts of the skin cancer detection project are examined, and the structure
of our creative solution is developed. Our project's cornerstones—model design and training
—are the result of a great deal of study, data preparation, and methodological thought. The
architecture of our deep learning model is painstakingly designed, and adapted to the
particular complexities of skin lesion identification, and the path of turning raw data into
useful insights is started. The challenges of creating a model that can not only diagnose many
types of skin cancer but also adapt to real-world circumstances and demonstrate the highest
levels of performance are traversed with a particular focus on achieving robustness, accuracy,
and ethical considerations.
Exploratory Data Analysis (EDA) was the first step in the model design process. Its goal was
to gain deep insights into the characteristics and distribution of the dataset, allowing for a
thorough understanding of its complexity and the identification of potential issues that needed
to be addressed. One of the challenges was the problem of class imbalance in the dataset,
with some forms of skin cancer being underrepresented. To address this imbalance,
oversampling techniques were meticulously applied, resulting in the creation of a more
balanced dataset that ensured the model would not be skewed towards the majority class,
thereby maintaining its capacity to detect rarer skin cancer types effectively.
The model training phase was started with a well-prepared dataset. AlexNet, a deep learning
network well known for its strengths in image classification problems, was selected for this
challenge because of its suitability for the challenging task of skin cancer diagnosis from the
images. The investigation did not, however, only concentrate on AlexNet. Comparative
analyses were carried out with models like Random Forest, Decision Tree, and K-Nearest
Neighbors (KNN) in order to make sure that the model's performance was measured against
other effective machine learning models. The relative benefits and limitations of each model
were evaluated through a thorough evaluation procedure, which finally helped determine the
best method for skin cancer diagnosis.
7
4.3 Model Training
In the process of training the model, a novel strategy is used in which a Dense AlexNet
architecture is developed, with a focus on the addition of dense layers as the main innovation.
Our distinctive contribution resides in the incorporation of thick layers inside this framework,
despite the fact that the AlexNet architecture's effectiveness in image classification tasks has
long been acknowledged. These interwoven, deep layers allow for the capturing of intricate
patterns, complex relationships, and high-level abstractions within the skin lesion images,
greatly boosting the model's ability to extract and represent features. Our model is enabled by
this ground-breaking use of dense layers to detect and categorize different types of skin
cancer with unprecedented accuracy, as well as adjust to the complex and subtle properties of
dermoscopic images. The model's performance has also undergone a thorough evaluation
through comparisons with other machine learning models. With the help of this thorough
evaluation, we can compare our innovative strategy to well-known models and acquire
important insights into its benefits and drawbacks with regard to the classification of skin
cancer. This comparative analysis highlights the reliability and effectiveness of our Dense
AlexNet architecture, establishing it as a potential and ground-breaking method for enhancing
skin cancer early detection.
Several crucial libraries were imported and loaded to support different project elements.
These packages include Imbalanced-Learn (imblearn) for oversampling strategies,
Imbalanced-Learn (Seaborn) for data visualization, Matplotlib for plot generation, NumPy for
numerical operations, and TensorFlow for building deep learning models. To build and set up
the neural network architecture, fundamental TensorFlow library features, including the
Sequential model and layers like Conv2D, Flatten, Dense, and MaxPool2D were also
imported. Together, these libraries support the thorough foundation for skin cancer detection
used in this project.
8
Step 2: Loading the dataset
A code snippet that read the dataset using the "pandas" library and then stored the
information in the "data" variable was used to load the dataset. The feature variables x were
then obtained by removing the 'label' column from the dataset, and the target variable y which
represents the labels—was then retrieved from the dataset. This code made it easier to load
and organize the dataset efficiently for further analysis and model training.
This piece of code is essential for the Exploratory Data Analysis stage of the project. The
frequency distribution of several groupings of skin illnesses in the dataset is evaluated and
illustrated using it. The numerical class labels are mapped to their respective illness names
using the 'classes' dictionary, creating meaningful labels for improved interpretation. The
frequency of each illness class is then displayed in a bar plot using the function from the
Seaborn library. A deeper comprehension of the dataset's composition and imbalances is
made possible by these insightful insights into the class distribution of the dataset provided
9
by this graphic. Such EDA is essential for directing further research stages, especially when it
comes to the description and identification of skin cancer.
This code snippet plays a crucial role in the data exploration and analysis process,
concentrating on comprehending the gender-specific disease distribution within the dataset. It
uses a pie chart visualization style to show how many patients are male and female. The pie
chart is made using the plt . pie function, and the function provides the counts of male and
female patients. Researchers can evaluate any potential gender-related patterns or
discrepancies in the occurrence of skin diseases thanks to the chart's clear and concise
overview of the dataset's gender distribution. When it comes to understanding how gender
might connect to the occurrence of skin diseases, this analysis offers insightful information
that can guide further phases of the research.
10
Figure 3. Gender of Patents
11
This code is used to create and show a histogram that depicts the age distribution of the
patients in the dataset. The histogram is produced using the sns . histplot function with the
data source. The visual representation of patient age distribution provided by the visualization
makes it possible to examine patterns, peaks, and trends in age frequencies. The age
demographics of the dataset are revealed by this histogram, which is an integral aspect of the
exploratory data analysis (EDA) procedure and can be crucial for comprehending how age
affects the prevalence and diagnosis of skin diseases.
12
13
This code segment is used to produce a visualization that displays the dataset's gender-
specific distribution of disease localization on the body. It creates a bar plot using
the'sns.barplot' function. Information about gender and disease localization is included in the
data, which was derived from tabular data. With the extra feature of gender representation, this
graphic offers invaluable insights into how skin disorders are dispersed throughout various
body areas. Researchers can better understand potential trends and variations in disease
occurrence across different body areas and gender groups by visualizing the frequency of
illness localization for both sexes. This understanding is essential for dermatological analysis
and diagnosis.
14
Step 4: Oversampling
The feature data x is then reshaped into a deep learning model-friendly format, specifically
with dimensions (-1, 28, 28, 3), to accommodate picture data. The code then standardizes the
feature data x by deducting the mean and dividing it by the standard deviation. Finally, to
simplify the model training and assessment procedure, the data is divided into training and
testing sets using the train¿ function, with 80% of the data allotted to training X train ', Y train ,'
and 20% to test.
The code starts by establishing a Sequential model, an essential Keras element that enables
the sequential ordering of neural network layers. When layers are stacked consecutively in
deep learning architectures for tasks like image classification, sequential models are
especially well-suited. The convolutional Layer, identified by the model, is the first layer
introduced. Add the following formula:
Conv 2 D(96 ,(11, 11), strides=(4 , 4 ), input shape =(28 , 28 ,3), activation=relu).
Each of the 96 filters in this layer has a (11, 11)kernel ¿ ¿. The selection of a stride of (4, 4)
implies that during feature extraction, the convolution operation leaps four pixels in both the
horizontal and vertical axes. In order to add nonlinearity to the layer's output, it also makes
use of the activation function for Rectified Linear Units (ReLU). Convolutional layers are a
cornerstone of image classification models because they are essential for capturing local
patterns and features in images. A Max Pooling layer is added using a model after the
convolutional layer . Add the following: MaxPooling 2 D((3 ,3), strides=(2 , 2)). Max
15
pooling is a method of downsampling that minimizes the feature maps' spatial dimensions
while maintaining their key characteristics. A (3, 3) pooling window with a stride of (2, 2) is
used in this situation.
16
Following that, the model adds another convolutional layer, this time using 256 filters of size
(5, 5) and once more using the ReLU activation function. The retrieved features are further
refined in this layer. To down sample the feature maps and more efficiently capture important
data, a second Max Pooling layer, similar to the first, is implemented.
The model then includes two further Convolutional Layers. The preceding convolutional
layer, which employs 384 filters and a (3, 3) kernel size, is followed by a second
convolutional layer. Convolutional layers that come after one another extract features in more
detail, allowing the model to recognize more intricate patterns in the input. This architecture's
final convolutional layer, which employs 256 filters with a (3, 3) kernel size, improves the
model's ability to recognize complex features. After this convolutional stack, the feature maps
are down-sampled using a second Max Pooling layer. To prepare the data for the fully linked
layers, a flattened layer is added. This layer converts multi-dimensional feature mappings to
one-dimensional representations.
Two Fully Connected Layers, each with 4096 units, are added to the design and are each
activated by the ReLU function. High-level abstractions and intricate relationships within the
data are learned by these dense layers. The Output Layer, which is essential for classifying
skin cancer, is added last. According to the model, it uses the softmax activation
function . add ¿ where 7 is the total number of different skin cancer classification classes that
need to be created. The softmax function simplifies the classification process by converting
the model's raw output into probability distributions over these classes. The model is
assembled to complete the code segment. The accuracy metric for model evaluation, the
Adam optimizer for model weight updates, and the categorical cross-entropy loss function are
all specified. This code essentially implements a thorough Dense AlexNet architecture
specifically designed for skin cancer categorization. Deep convolutional layers are used to
extract complex information from dermoscopic images, and fully linked layers are then used
to provide high-level classifications. Using this design, tasks requiring the categorization and
detection of skin cancer should be performed more precisely and efficiently.
17
Step 6: Model Training
The model training process must be configured using the provided code snippet. The
optimizer and loss function to be utilized for training the skin cancer classification model are
specified. The loss function is specifically set to sparse_categorical_crossentropy, which is a
good option when the goal values are integers that reflect class labels. For multi-class
classification problems like the categorization of skin cancer, this loss function quantifies the
discrepancy between projected class probabilities and the actual class labels. Additionally, the
' adam ' optimizer is used, a popular optimization technique renowned for its success in deep
neural network training. With the aid of the Adam optimizer, training may be completed more
quickly and models perform better.
18
4.4 Summary
The architecture of the model is presented, the training regimen is carried out, and the
analysis of loss and accuracy metrics are all covered in detail in this chapter's explanation of
the model training process. Including convolutional layers, max-pooling layers, thick layers,
and an output layer, the model architecture is fully illustrated. The model is then put through
a lot of training, with the parameters being tweaked frequently using the Adam optimizer and
sparse categorical cross-entropy loss function. The model's internal parameters are modified
using gradient descent and backpropagation, and it is trained to identify intricate patterns in
dermoscopic pictures across a number of epochs. The model's performance measures,
including accuracy and loss, are also represented visually. These representations provide
information about the model's convergence and optimization.
19
Chapter 5
Model Evaluation
5.1 Introduction
Machine learning and deep learning model construction must include a crucial stage called
model evaluation, which marks the end of the training procedure. It entails a thorough
evaluation of a model's performance and its capacity to identify patterns in new data and
generate precise predictions or classifications. The key indicator of how well a model
generalizes its discovered patterns and correlations to actual situations is model evaluation.
Depending on the particular goal and objectives, this phase includes a range of approaches,
measurements, and procedures aimed to evaluate different aspects of a model's effectiveness.
In order to help data scientists, academics, and practitioners make educated decisions about
model deployment, fine-tuning, or additional iterations, model evaluation's ultimate purpose
is to offer insights into the model's strengths, flaws, and opportunities for improvement. It is
essential for ensuring that deep learning and machine learning models are trustworthy,
dependable, and effective tools for tackling real-world issues in a variety of fields.
20
The model's astoundingly high accuracy of 98.95% reflects its outstanding ability to make
precise predictions or classifications on the provided dataset. This exceptional level of
accuracy highlights the model's skill in identifying intricate patterns and correlations within
the data, making it a strong and trustworthy tool for the particular task at hand. With such a
high accuracy rate, the model's predictions closely match the labels for the ground truth,
giving rise to confidence in its potential for use in real-world applications and decision-
making procedures.
To fully assess the performance of the Dense AlexNet model, a comparison research was
carried out, which included printing the classification reports of many well-known machine
learning models, including Decision Tree, Random Forest, and K-Nearest Neighbors (KNN).
Precision, recall, F1-score, and support are just a few of the performance measures included
in the classification reports for each class in the dataset. Because of this detailed analysis, the
21
performance of the Dense AlexNet in relation to various rival models can be properly
examined. We can learn a lot about how the Dense AlexNet performs in terms of precision in
correctly classifying each class, recall of instances of each class, harmonic mean of precision
and recall (F1-score), and support or frequency of each class within the dataset by carefully
examining these reports. Such a comparison analysis is essential for identifying the
advantages and disadvantages of the Dense AlexNet model and enabling data-driven choices
regarding its applicability for particular tasks and applications.
22
23
The Dense AlexNet stands out among the studied models with an excellent accuracy rate of
99%, outperforming all other models. This exceptional accuracy result highlights the Dense
AlexNet's superior performance in accurately categorizing instances within the dataset. It
confirms its status as the best-performing model in this comparison research by achieving the
highest accuracy as well as the best overall performance score across a variety of metrics.
This outstanding outcome demonstrates the Dense AlexNet's prowess in challenging
classification tasks, making it an appealing option for applications requiring the highest
degree of precision and accuracy.
24
Figure 7. Comparative Performance of Machine Learning algorithms
Below is the table of comparative analysis of the models implemented along with the dataset
used and accuracy. As depicted above in figure 7., the proposed model outperforms other
models with a significant amount. Also, for fair comparison same dataset has been taken for
other model’s evaluation
Based on the Dense AlexNet architecture, the created model came out on top in the
comparative study, scoring an excellent accuracy score of 98.95%. This extraordinary degree
25
of precision highlights the Dense AlexNet model's efficacy and superiority to the other
models considered. It reaffirms the Dense AlexNet's status as the top-performing model in the
analysis, showcasing its capacity to perform admirably in the task of skin cancer
classification and illuminating its promise for real-world applications demanding great
precision and accuracy in diagnosis and detection.
2. ResNet Model
In research, a skin cancer detection system was developed using a convolutional neural
network (CNN) (Garg, Maheshwari, & Shukla, 2021). The quality of dermoscopy pictures of
skin cancer was improved using this technology using noise reduction and resolution
improvement techniques in image processing. The dataset was expanded using a variety of
picture augmentation approaches, boosting the available training images. Additionally, a
transfer learning approach was applied, especially with the ResNet model, to enhance the
accuracy of picture classification. The weighted F1 scores for the CNN model's accuracy,
recall, and other metrics were all 0.88, 0.74, and 0.77, respectively. Additionally, the transfer
learning method combined with the ResNet model yielded a remarkable accuracy rate of
90.51%.
In their study (Gessert, Nielsen, Shaikh, Werner, & Schlaefer, 2020), which examined the
deployment of ensembles of multi-resolution efficient networks for a particular job, the
researchers attained an accuracy of 74.2%. This strategy made effective use of multi-
resolution techniques and ensemble approaches for the deep learning model.
5.5 Summary
26
Numerous performance criteria are used in the evaluation process, and each one provides a
different perspective on the capabilities of the models. To get a complete picture of how each
model performs, metrics including accuracy, precision, recall, F1-score, and support are
closely examined. These metrics evaluate the models' recall of examples belonging to each
class as well as their accuracy in correctly categorizing cases. The F1 score is a standardized
indicator of recall and precision. The support measure also highlights the frequency with
which each class appears in the dataset, revealing critical information about class imbalances
and their impact on model performance. The chapter also offers a thorough analysis of the
categorization reports created for each model. These studies offer a detailed analysis of the
model's performance on a per-class basis, highlighting their advantages and disadvantages in
identifying various forms of skin cancer. This degree of detail is essential for identifying
specific areas where the models perform well or need to be improved. Lastly, the goal of this
comparative study is to contribute to the ongoing advancement of medical image analysis and
the early diagnosis of skin cancer by identifying areas for improvement and confirming the
effectiveness of the developed skin cancer classification model.
27
Chapter 6
6.1 Conclusion
With the development and assessment of a strong skin cancer classification model, this study
aims to address a critical issue in the field of healthcare. It is crucial to identify skin cancer
early and correctly diagnose it because it is still a serious public health concern. With the goal
of developing a useful method for automated skin cancer diagnosis, this study sets out to
harness the potential of deep learning, in particular the Dense AlexNet architecture. We have
adopted a meticulous and thorough approach to model building and evaluation during the
duration of this project. We started by assembling a large and varied dataset, the HAM10000
dataset, which included several forms of skin cancer. The model was trained and tested using
this dataset as a base. We developed a Dense AlexNet model using a fresh method and dense
layers to improve its feature extraction and classification capabilities by utilizing the potential
of deep learning. Beyond the creation of models, the research includes careful analysis and
validation. By comparing our model to well-known machine learning models that are
frequently employed in medical image processing, we undertook a thorough comparison
analysis. This research outlined areas for further improvement and offered insightful
information about the model's capabilities. The outcomes highlight the excellence of our
Dense AlexNet model, which achieved a remarkable accuracy of 98.95% and establishes it as
a promising tool for precise skin cancer diagnosis. The research has enormous potential for
improving patient outcomes, easing the strain on healthcare systems, and detecting cancer
early. The effectiveness of our model motivates further research to increase the accuracy and
generalizability of similar models and demonstrates the use of deep learning techniques in
medical picture analysis. Although this work represents a significant progress, the road to a
more widely available, precise, and effective skin cancer diagnosis continues, supported by
developments and innovations in the fields of artificial intelligence and deep learning.
The study's findings open up a wide range of ground-breaking new possibilities for the area
of deep learning-based skin cancer diagnostics. The need for precise and effective diagnostic
28
tools in medicine is increasing as technology develops. First first, there is a big chance to
improve model designs even further. Deep learning is a dynamic field, and new architectures
are always being developed. Researchers may look at cutting-edge models like EfficientNets,
Transformers, and attention-based models to improve the accuracy and efficacy of skin
cancer detection models. By experimenting with these architectures, we might be able to
achieve higher levels of performance and diagnose more types of skin cancer. Another
intriguing area for future investigation is multi-modal data integration. It is possible to have a
more thorough understanding of a patient's skin condition by incorporating several data
sources, such as dermoscopic pictures, patient metadata, and genetic data. This all-
encompassing strategy may produce more precise and individualized diagnostic tools,
enhancing patient outcomes and therapeutic choices. The field of real-time detection is
another one that has potential. The quality of care for patients may be dramatically impacted
by the ability to identify skin cancer in real time, whether in clinical settings or through
telemedicine. Healthcare workers may make quick decisions and give patients rapid feedback
by optimizing models for real-time processing and distribution on mobile devices. Last but
Education and awareness initiatives for the general public and healthcare professionals are
essential. The suitable and effective use of AI in skin cancer diagnosis may be facilitated by
raising understanding of its advantages and disadvantages, ensuring that informed decisions
are made.
29