Deep Learning Use Case

Improving medical prediction of pneumonia cases using Deep Learning

This article is a case study of how to apply ML to the needs of use in the world of health, providing value in the case of medical diagnosis. Using the latest technology in neural networks we are able to recognise in an image, thanks to prior training, what we need. In this use case, we identify the presence or absence of pneumonia in an X-ray. Thanks to the precision achieved after training, the results are more than 95 percent correct, identifying infections that are even less obvious or undetectable to the human eye. Convolutional neural networks belong to the field of neural networks. However, they are different from the multilayer perceptron or others such as recurrent neural networks. Their application is based on two-dimensional matrices, and they are effective in computer vision applications, both in classification and segmentation. From a functional point of view, neural networks need a large amount of data to learn the feature to be predicted: in this case, the presence or absence of pneumonia.
Captura de pantalla 2021 09 15 a las 17.13.05
Captura de pantalla 2021 09 15 a las 17.13.19

Fig1. Example of dataset image with pneumonia AND example of normal dataset. Lung X-ray with pneumonia shows opaque spots on the image.

The dataset released in 2018 by Kermany et al. has a sample of 5840 images belonging to lung radiographs labelled as pneumonia diagnosis and non-pneumonia X-ray radiographs. These images have been selected under human quality control and labelled according to an expert’s diagnosis before being validated for training in the system.

1- Dataset Preparation

These datasets will be used in the different processes of developing the neural network model. In the first training stage, we show the AI over 5,000 images and indicate whether or not there is pneumonia. During this process the neural network will analyse image by image and find patterns. Once the training is finished, we can move on to the testing stage: we apply another dataset of about 624 images and our neural network will be able to check its progress by identifying the disease in the X-rays. It will go back to the previous step as long as it has not exceeded the percentage of success we have indicated. When we consider that it has successfully learned, we can move on to the last step: validation. Based on 18 images, half of which will be positive for pneumonia and half negative, we obtain a final hit metric.
Captura de pantalla 2021 09 15 a las 17.15.48

Fig 2. The dataset is subdivided into Train, Test and Validation sets.

Captura de pantalla 2021 09 15 a las 17.16.47

Fig 3. Division of the dataset into training, test and validation sets with the processes used for each dataset.

These datasets will be used in the different processes of developing the neural network model. In the first training stage, we show the AI over 5,000 images and indicate whether or not there is pneumonia. During this process the neural network will analyse image by image and find patterns. Once the training is finished, we can move on to the testing stage: we apply another dataset of about 624 images and our neural network will be able to check its progress by identifying the disease in the X-rays. It will go back to the previous step as long as it has not exceeded the percentage of success we have indicated. When we consider that it has successfully learned, we can move on to the last step: validation. Based on 18 images, half of which will be positive for pneumonia and half negative, we obtain a final hit metric.

2- Model Architecture

The convolutional network architecture consists of multiple layers of convolutional filters of various dimensions. As classification networks, at the beginning is the feature extraction phase, performing progressive dimensionality reduction with a final perceptron layer to improve classification. The convolution layers aim to learn the image features, and the final perceptron layers classify them as labelled in a human-supervised manner. This technology meticulously analyses the images we have given it, progressively enlarging them down to the pixel, or even less, so that the margin of error left by having studied thousands of, in this case, X-rays, leaves us with percentages of 98-99 percent correct.
Captura de pantalla 2021 09 15 a las 17.19.13

Fig 4.  Schematic of convolutional neural network architecture. The convolutional layers help with feature learning, the final perceptron layers classify images with Pneumonia. 

3- Evaluating the performance of the model

When evaluating the performance of the network, we look at two functions that form a binomial: accuracy and loss. To evaluate the correct training, we must observe a behaviour in which the accuracy goes up and the loss goes down over the training time.
Captura de pantalla 2021 09 15 a las 17.21.40

Fig 5.  Loss and accuracy functions evaluating training and validation datasets.  

Conclusion

In just 4 hours of training and around 6,000 labelled images, we have managed to get our neural network to identify the presence of pneumonia in the X-rays studied with great precision, which would speed up a diagnosis of the disease and ensure that it would be accurate beyond what a human eye could detect, thanks to its training on scales that are imperceptible to us. To test its effectiveness, we conducted an experiment with a specific image. The result, with 96 percent certainty, indicates the presence of pneumonia in this patient.
Captura de pantalla 2021 09 15 a las 17.23.53

Do you want a data-driven solution?

projects scaled