Use of Machine Learning in detecting Skin Cancer.
In this article, we will look into the methodology of an ML application used to detect Skin Cancers.
Skin is the largest organ in the body. Skin contains some cells called Melanocytes. These melanocytes secrete "Melanin", the dark pigments seen at some places of your skin as "Moles".
These melanocytes may proliferate more than normal to turn cancerous above a limit. Below that limit and above the normal pattern of proliferation of a cell it is Benign.
These changes arising from these melanocytes are classified into two types -
The Malignant/Cancerous changes in the melanocytes is called Malignant Melanoma
Skin cancer is the most common of all cancers.
Those are classified into two types...
Melanotic Skin Cancers(MSC) - 5% of the total cases
Non-Melanotic Skin Cancers(NMSC) - 95% of the total cases
Malignant Melanoma -
This cancer arises from the melanocytes usually in the skin but can form anywhere, such as in the Bowel Mucosa, Retina of Eye and the Leptomeninges where the melanocytes exist.
Here we will be discussing Cutaneous Malignant Melanoma(i.e specifically the Skin Cancer).
Let us learn some facts regarding this cancer-
It is the most aggressive cutaneous malignant tumour.
Although it accounts for less than 5% of skin malignancy generally it is responsible for more than 75% of deaths related to skin malignancy(skin cancer).
Worldwide, Malignant Melanoma accounts for 3% of all cancers. It is common cancer in young adults and is the most likely cause of cancer-related death.
It is largely caused by exposure to UV radiations. More seen in white-skinned races(no offence ;)) that are not suitable for sun exposure.
A condition called Xeroderma pigmentosum acts like a precursor for Malignant melanoma which increases the relative risk of developing Malignant Melanoma to 1000.
The risk factors for developing Malignant melanoma(MM) are:
Xeroderma pigmentosum (relative risk = 1000).
Post medical or family history of MM (Malignant Melanoma) with dysplastic naevi (relative risk = 22-1269).
Previous Melanoma (relative risk = 84).
High total number of naevi (relative risk = 3.4, if >20 naevi).
Dysplastic naevi (10% lifetime risk).
Red hair (relative risk = 3).
Tendency to freckle (relative risk = 1.9)
Immune compromised conditions: HIV infection, Hodgkin's disease, cyclosporin A therapy.
GCPN (increased risk).
History of sunburn - especially in childhood.
Sometimes naevus (Benign) may turn into MM: 10-20% chance.
How can we identify this?
Observe the following changes in your naevus-
Change in size - any adult naevus > 6mm is suspected(for reference a lead pencil diameter is 7mm) and anything changing to >10mm is more likely to be malignant than benign.
Shape - irregular or any changes
Colour - any changes
Surface(nodularity or ulceration)
Satellite lesions(discrete pigmented areas spreading away from the primary)
Tingling/itching/serosanguinous discharge(usually late signs)
Blood supply: melanomas > 1mm thick have a blood supply that can be found with a hand-held Doppler monitor, so 'Doppler-positive' pigmented lesions should be excised.
Sites where you may observe this cancer-
Head & Neck - 25%
Trunk - 25% (most common in males)
Lower Limb - 25% (most common in females)
Upper Limb - 11%
Other sites - 14%
The other sites include...Eye, Bowel, Genetilia, Nasophatynx etc.
Clinical Types of Melanoma:
Superficial Spreading Melanoma-
The most common type of MM(70%).
Most likely arises from a pre-existing naevus(benign).
A better prognosis(recovery).
2. Nodular Melanoma-
Most aggressive type.
Grows into the skin vertically.
3. Lentigo Maligna Melanoma-
Presence of slow-growing, variegated brown melanoma.
Positively correlated with prolonged and intense sun exposure.
4. Acral Lentiginous melanoma-
Affects the soles of feet and palms of the hand.
Okay, how does this cancer spreads?
This cancer can spread through...
To various organs like Brain, Lungs, Liver etc.
Can also spread from mother to fetus.
Awesome, we discussed a lot! Let's dive into the application of Machine Learning to detect Skin Cancers.
The machine learning applications use images of skin lesions and then classifies them. At present many state of the art Deep Learning applications are being used to assist dermatologists.
An Australia-based AI software, Moleanalyzer, calculates and compares the size, diameter, and structure of moles. This tool helps in differentiating between benign and malignant lesions. FotoFinder
Here we will look at a simple application to classify skin lesions...
The dataset is taken from the ISIC (International Skin Image Collaboration) Archive. The International Skin Imaging Collaboration: Melanoma Project is an academia and industry partnership designed to facilitate the application of digital skin imaging to help reduce melanoma mortality.
The dataset consists of 1800 pictures of benign moles and 1497 pictures of malignant classified moles. The pictures have all been resized to low resolution (224x224x3) RGB. We will look at how a ML model classifies a Dysplastic mole into benign or malignant.
So, we can say that we are having 2 different classes - Benign and Malignant.
We are using Convolutional Neural Network to classify the images and then analyse the model performance.
CNN models use train images to learn the features used for classification. The learned features/parameters are then used on test images to validate how well the model is working.
Testing and Model metrics
1. Data Collection-
We are going to use the above mentioned dataset to build the model. The dataset directory has the following structure:
- benign (1440 images)
- malignant (1197 images)
- benign (360 images)
- malignant (300 images)
2. Data Preprocessing-
Human brain can identify images easily. But the machines work with numbers, i.e in their view everything is a number of an array of numbers. So, how can a machine view an image? Any guess?
Yes, the images are nothing but an array of pixels. The resolution of each image in the dataset is 224 x 224 x 3, therefore there are 150528 pixel values.
Let us look at an example how machines view the images:
In real-world the images may have different orientations, which affects the models’ performance. Thus we will be using image augmentation techniques on the images, so that the model can extract prominent features.
Look at the following example -
3. Model Building-
CNN is a type of neural network mainly used for Computer Vision tasks like Image Classification, Image Recognition and many more.
The above model is having 4 Convolutional Layers. From the 1st layer simple features like vertical lines, horizontal lines, curved lines, etc are learned. While going deep into the upcoming layers the model ignores irrelevant features and learns the prominent features.
Convolution - A method used to produce a feature maps - an array of image features
MaxPooling - Used to select prominent features from the feature map
Dropout - A regularisation technique which randomly drops the nodes
At the end, the output neuron generates either 0 or 1. Where 0 represents Benign and 1 represents Malignant.
4. Training- The model is trained on train images.
5. Model Metrics -
During the training process the model learn the important features by reducing the loss factor and thus increasing the accuracy factor
We can see that training accuracy increases from 0.55 to 0.83, whereas the testing(validation) accuracy increases from 0.5980 to 0.7920.
The training loss is reduced from 0.7031 to 0.3051, whereas the testing loss is reduced from 0.6624 to 0.4051.
i.e we can say that this model is 80% accurate.
6. Predictions -
Let us use a benign tumour image to check how the model predicts
Well, the output 0 means, it is benign. Hmm, the model predicted truely.
Let us look how the model predicts an image consisting mole
Hmm, great it predicted as benign.
This is a basic model used to give an idea how a ML model is built and used to predict Skin Cancers.
Use of these models:
- Melanoma when recognised and treated in its earliest stages, is readily curable.
- Many research groups are working on building ML models to predict the skin cancers accurately.
Predicting at a higher rate doesn't mean there's a 100% chance of occurrence. The prediction is just a probability, one shouldn't solely depend on these models.
Therefore the traditional way of diagnosis by a physician and a pathologist through microscopic and macroscopic features is final.
Investigations-to confirm it as a cancer, to know the spread and the extent of spread:
Excision biopsy of the tumour.
FNAC of Lymph node.
Sentinel lymph node Biopsy (SLNB).
Dermoscopy - Early cases.
MRI of the site.
The Breslow thickness of the primary tumour offers the best correlation with survival in stage I disease. The higher the mitotic index, the poorer the prognosis of the primary tumour; this has greater significance than the presence or absence of ulceration.
- Alexander Breslow, 1928-1980, American Pathologist.
The presence of lymph node metastases is the single most important prognostic index in melanoma, outweighing both tumour and host factors. The number of affected nodes and the presence of extra nodal extension are also significant outcome predictors. Once regional nodes are involved clinically, 70-85% of patients will have occult distant metastases.
Resources and Reference
Bailey and Love Short Practice of Surgery
Clarifai - CNN
AnalyticsVidhya - Image Classification
Kaggle - CNN for Skin Cancer Detection