COVID 19 Prediction using Chest X-Ray Scans

Rishit Toteja
Analytics Vidhya
Published in
4 min readAug 19, 2021

INTRODUCTION :

With the increasing number of COVID 19 cases globally, there has been a lot of burden upon the doctors. Any usual COVID test takes about 1–2 days to get the final report. So there is a need to develop a test that could output the results faster so that necessary action can be taken at an early stage.

With the advent of Artificial Intelligence and Deep Learning, it’s possible to devise a supervised learning model which could predict a particular disease given some input features.
This was the aim of my project, i.e., to build a neural network that could predict if a person has the COVID-19 disease or not by looking at the chest X-Ray scans with high accuracy.

This project could reduce a lot of burden on doctors and get faster and more accurate reports.

Source : Google Images

LIBRARIES AND DATASET USED

The whole project was made in python language and carried out on google colab environment. For designing the neural network, Keras sequential API was used with TensorFlow as the backend.

For Visualizing Data and Data Analysis: pandas, matplotlib, and NumPy libraries were used.

The dataset was obtained from an open-source website, kaggle.com. The dataset contained the lungs X-ray images of both groups, i.e., non-COVID 19 and COVID 19 infected patients.

DATA PREPROCESSING AND DATA AUGMENTATION

In order to pass the training data to our model, we had first to preprocess it and divide it into training testing and validations sets.

Data Augmentation: Data augmentation is a fundamental and valuable technique to implement on our training data, making our model more efficient. In data augmentation, we basically try to change the orientation of the image, flip the image (vertical or horizontal), blur the image, etc., to increase our training dataset.

BUILDING A CONVOLUTIONAL NEURAL NETWORK

Convolutional neural networks or ConvNet is a class of neural networks, which are most commonly used to analyze visual images.

The model built was sequential with a combination of convolutional layers, pooling layers, dropout layers, flattening layers, dense layers with relu activation, and an output layer with sigmoid activation.

Since our task was binary classification in this project, i.e., to predict COVID 19 positive or COVID 19 negative, I used a sigmoid activation on the final output layer. For performing gradient descent on the neural network, I used Adam optimizer with a learning rate of 0.001.

The model was finally trained on the training dataset, and then I evaluated the model. I did a lot of hit and trial runs to fine-tune the number of epochs for the model to be trained on, and the highest training and validation set accuracy was obtained at 35 epochs

MODEL EVALUATION

VISUALIZTION :

To visualize the accuracy as well as the losses on the training and validation dataset after each epoch, I plotted them with the help of the matplotlib library.

Finally, the model was also evaluated on the test set, i.e., the images which it had never seen before, and the accuracy was found out to be 98.14 %

The final results of the model were :

  1. Training Set Accuracy : 97.38 %
  2. Training Set Loss : 0.0875
  3. Validation Set Accuracy : 97.79 %
  4. Validation Set Loss: 0.0744
  5. Test Set Accuracy : 98.14 %
  6. Test Set Loss : 0.06641

REFERENCES

  1. Google Colab Project Link : https://colab.research.google.com/drive/1oeA2Rp5B_8VWtOXEoY7R4dQMaO4pZe_y?usp=sharing
  2. Github project Link : https://github.com/RishitToteja/Prediction-of-COVID-19-using-Chext-X-ray-Images-Convolutional-Neural-Network-CNN
  3. Dataset used Source : https://github.com/RishitToteja/Chext-X-ray-Images-Data-Set

--

--

Rishit Toteja
Analytics Vidhya

Hi there, I am Rishit Toteja. I have profound knowledge about Deep Learning, Data Sceince and Python. I have keen interest in Electronics. I love to play chess