Using a Neural Network to Predict Pneumonia From X-Ray Images

According to the American Lung Association, 'Pneumonia is an infection of the lungs that may be caused by bacteria, viruses, or fungi. The infection causes the lungs' air sacs (alveoli) to become inflamed and fill up with fluid or pus. That can make it hard for the oxygen you breathe in to get into your bloodstream. The symptoms of pneumonia can range from mild to severe, and include cough, fever, chills, and trouble breathing.'


Pneumonia Infographic


Patients with pneumonia could have the following symptoms:

  • Cough that produces phlegm or sometimes blood
  • Fever
  • Shortness of breath or difficulty breathing
  • Chills or shaking
  • Fatigue
  • Sweating
  • Chest or muscle pain

If a person is suspected of having pneumonia, a doctor will begin by asking the patient about their medical history and symptoms. Next will be a physical exam, so the doctor can listen to the patient's lungs. In checking for pneumonia, a doctor will listen for abnormal sounds like crackling, rumbling or wheezing. If the doctor thinks the patient may have pneumonia, an imaging test like an x-ray may be performed to confirm the diagnosis.


A chest x-ray may show area of inflammation, similar to the image above, which is a clear indicator of pneumonia. This indicator would lead to a diagnosis, and recommendation for a medical remedy. The question posed here is: Could an Artificial Neural Network perform this diagnostic task from an x-ray image? If so, how well could it perform?


Today's experiment is an attempt to answer this question utilizing a dataset available on kaggle.com including 5,683 labeled chest x-ray images of both Pneumonia cases and non-pneumonia cases. The graph below showcases the distribution of these two different classes in the dataset.


To the untrained eye, instances of pneumonia do not appear much different from 'normal' cases. Here are a couple randomly grabbed images from the dataset:



In order to make predictions about the classifications of these images, I build a convolutional neural network with 7 layers. The output layer gives us a prediction of either 0 or 1 corresponding to 'Normal' or 'Pneumonia'. This neural network was trained and fit on 100 epochs of the entire training dataset. I fed the model new data to test its performance, on which it recorded 88.5% overall accuracy. Below is the confusion matrix from the model's predictions on this new data.






We hold our healthcare professionals to a very high standard, expecting our doctors to correctly diagnose us 100% of the time. However, at any given visit, an individual's symptoms could indicate tens of thousands of different ailments. Doctors, while well trained, are still   humans after all and bound to make mistakes & mis-diagnose. If we could incorporate machine learning techniques like the one outlined here into the medical diagnosing phase of a patient's visit, perhaps we could better identify conditions. I am in no way advocating for replacing medical professionals with computers, but rather allowing doctors to incorporate these types of results into their decision-making process. I hope to continue to fine-tune this model in attempt to increase the accuracy score as much as possible. Thanks for reading!



Comments

  1. CAD systems review of mammograms have improved breast cancer recognition by 7.4%. Data scientists are making great strides in diagnostics. The applications are boundless!

    ReplyDelete
  2. The content you've posted here is fantastic because it provides some excellent information about Diagnostic Medical Supplies Online Order Usa that will be quite beneficial to me. Thank you for sharing that. Keep up the good work.

    ReplyDelete
  3. Thanks for publishing such great information. You are doing such a great job. This information is very helpful for everyone. Keep it up. Thanks. Read more info about Blood Pressure Monitor With Ac Adapter Usa

    ReplyDelete

Post a Comment

Popular posts from this blog

Using a Neural Network to Classify Lego Figures

Artwork Locator