/Chest-X-Ray-Deep-Learning-Project

This repository includes my Chest X-Ray Deep Learning-Flatiron School Module 4 Project. For this project, I made use of OS to access the data. The Pandas, NumPy, Matplotlib, Seaborn, and Plotly libraries were used to explore the data. Keras was used to build the image classifier.

Primary LanguageJupyter Notebook

Building Image Classifier With Keras

Detecting Pneumonia in Patients Using Chest X-Ray Images (Pneumonia) Dataset

Screen Shot 2020-08-10 at 1 15 15 PM

My intent with this project was to build a simple deep learning neural network that would be capable of performing binary classification on Chest X-Ray Images (Pneumonia) from Kaggle.com click here. I had to import a module that would serve as an operating system interface from python in the form of OS in order to interact directly with the directories located on my computer. Keras was used extensively in this project in order to make use of all of its deep learning capabilities. Numpy was used in the manipulation of images in the form of arrays. Pandas, Matplotlib, Seaborn, and Plotly were utilized in the exploratory phase of this project in order to visualize the data.

Screen Shot 2020-08-10 at 2 14 45 PM

I started with importing the necessary modules and libraries needed for this project. I then went ahead and performed the rudimentary data exploration phase by reading in some images as examples of what the data looks like. I also assigned certain directories to their respective variables in order to make use of them in the visualization and deep learning model building stages. I then went ahead and created simple histograms and pie charts comparing people with and without pneumonia lung disease in each of the 3 directories (train, test, and val).

Screen Shot 2020-08-10 at 2 34 46 PM

Screen Shot 2020-08-10 at 2 16 35 PM

Screen Shot 2020-08-10 at 2 16 52 PM

Screen Shot 2020-08-10 at 2 17 16 PM

Screen Shot 2020-08-10 at 2 22 23 PM

Screen Shot 2020-08-10 at 2 25 08 PM

Arguably, the most difficult part of this project was constructing the deep learning convolutional neural network to classify the images. I played around with certain parameters in terms of batch size and epochs. There were a lot of moving pieces when it came to initializing this model in order to make it the most efficient possible. I made use of sigmoid and relu activation functions. The final stage was to evaluate my model and the accuracy percentage turned out to be ~90% and the loss percentage was ~36%. In conclusion, I would say that the model turned out alright, although I'd like expand on this work in the future and see if there is any way I could descrease the loss at all. The weights are saved under model_parameters.h5 after running this project in its entirety.

Screen Shot 2020-08-10 at 2 26 56 PM

Screen Shot 2020-08-10 at 2 27 58 PM

Screen Shot 2020-08-10 at 2 28 27 PM

The model performed quite well in the training phase as it shows it improved in accuracy as the epochs increased, while also reducing the loss. The model accuracy of ~90% and model loss of ~36% on the test data suggests that the model did quite well in classifying the images it was provided with. We would able to rely on this model to classify the images with significant amount of certainty whether it is an image showing lungs as being either positive or negative for Pneumonia. These types of results are what we are looking for when conducting tests based on model performance. This type of neural network algorithm can be of great help to any medical professional working in the field and attempting to diagnose a patient.

Screen Shot 2020-08-10 at 2 30 33 PM

Screen Shot 2020-08-10 at 2 30 55 PM

Screen Shot 2020-08-10 at 2 31 13 PM

Screen Shot 2020-08-10 at 2 31 28 PM

Key takeways:

1. The neural network may be used to aid the healthcare professional in stream-lining the diagnosing process when classifying images. This may allow for a quicker return time and greater patient satisfaction. Which would, in turn, lead to the potential for more positive outcomes because the positive patients can begin treatment right away as opposed to waiting lenghty periods of time for the results to arrive.

2. There is the prospect of less mistakes being made while also looking at a greater amount of pictures at any given time. Having a doctor look at countless pictures of patients' lungs can be quite a lengthy process, which can lead to many errors being made along the way. A neural network can be employed in order to cut out some of the work and make initial deductions. This would relieve any doctor's stress at having to sift through a great deal of images. The neural network would be able to assign probabilities to each image and then the doctor can step in and look at each image with a more rigorous eye to determine the diagnosis.

3. Implementing a neural network can prove to yield a greater ROI for the institution in the long-run. Therefore, the doctors would be allowed more time to invest or focus their time on less repetitive tasks that cannot be automated. The less time the doctors expend looking at images to arrive at a diagnosis, the more time they can allocate to dealing with more demanding procedures.

Screen Shot 2020-08-10 at 2 42 42 PM