Analysing X-rays for pneumonia in children aged 0–5 using machine learning
La Paz. Machine Learning. 2021 (La Paz 2021) Around the world, there is a fairly common problem in most hospitals and that is that as they exist daily, a fairly large number of people looking for…
A learning project shared by the community. The article documents its team, methods and results; it does not establish that the prototype is ready for real-world use.

This archive includes automatic translations. Audio, video and text inside images remain in their original language.
Editorial note: this article documents an educational project and its results on the data used. It does not establish clinical validation or authorisation to diagnose or treat patients. Proposed healthcare applications are retained as the team’s goals, not demonstrated capabilities.
La Paz. Machine Learning. 2021
(La Paz 2021) Around the world, there is a fairly common problem in most hospitals and that is that as there is a fairly large number of people seeking medical attention on a daily basis, the care system tends to collapse and a large number of people do not receive medical attention that may be urgent. We have to take into account that the variety of patients and the variety of cases to be treated within a hospital is enormous. However, one of the most important diseases that must be treated quickly after diagnosis is pneumonia in children from 0 to 5 years of age. At present, Machine Learning allows us to make an automatic and rapid diagnosis of pneumonia.
Childhood pneumonia is the infectious disease that causes the most deaths in children every day throughout the world. On average, more than 800,000 children under 5 years of age die from pneumonia each year, meaning a child dies from pneumonia every 39 seconds. The most shocking thing in this situation is that according to the article published by UNICEF on January 20, 2020, almost all of these deaths are preventable. The abysmal number of child deaths due to pneumonia is due to the fact that this disease can be transmitted when breathing particles suspended in the air.
Problem:
Taking into account the enormous number of cases of pneumonia in children under 5 years of age, how can we implement Artificial Intelligence to make the diagnosis of childhood pneumonia more efficient?
Objective:
The main objective of this project is to develop an Artificial Intelligence capable of analyzing x-rays of infants who are 3 years of age or younger. In this way, any infant who has x-rays of their lungs can be diagnosed in a matter of seconds and can be taken to a care area instead of first having to go through a general doctor who must make the diagnosis if the infant has pneumonia or not.
Datasets:
The “Chest X-Ray Images (Pneumonia)” dataset found on the Kaggle platform was used. This dataset contains 5,863 images divided into 2 categories: train (89.4% of the total dataset), test (10.6% of the total dataset). These two categories will be used respectively to train and test our model. Likewise, it is important to mention that each category of the dataset is divided into two parts, the first is composed of x-rays of infants without pneumonia, this division is called: “NORMAL”

The second part is called: “PNEUMONIA” and is where the x-rays of infants who have pneumonia are found:


Pneumonia identification process:
In order to make a good identification of pneumonia we have decided to use the grayscale filter found in the cv2 library. This filter allows us to highlight the different important areas of the human body. In this way the analysis is more accurate and the accuracy of the model is higher. Likewise, it is important to keep in mind that if we did not pass the images through a filter it would be dangerous since the model would be based only on the original image and there would be no option to eliminate noise from the image.

In the previous image you can see how the lungs look more highlighted by applying the aforementioned filter.
Subsequently, a normalization was performed on all the pixels of each image so that every value goes from 0 to 1.
Likewise, we have used the Keras library to include DataAugmentation within our DataSet. This addition allows our model to slightly increase the accuracy already obtained with the grayscale filter since it rotates, zooms and moves the image horizontally and vertically.
Once the filter is added, each image is analyzed and a homogeneous opacity present at the level of the lungs is looked for, this is the main effect of pneumonia.
Models:
The model that we have implemented is CNN (Convolutional Neural Network). In summary, it is a type of artificial neural network with supervised learning which can identify different input characteristics, so to speak, that in some cases cannot be intuited.
Convolutions consist of taking the entire image in pixels and applying a kernel (a small matrix) every certain number of pixels, which alters the original image depending on the kernel we are applying.
Results
- Training & Validation Accuracy + Testing Accuracy & Loss

- confusion matrix

An implementation of the confusion matrix metric was attempted but due to a version problem, the desired data could not be obtained.
- Accuracy:

- User tests:

Taking into account that if the prediction is close to 1 it means that the image is of healthy lungs and if it is close to 0 it means that the image corresponds to lungs with pneumonia symptoms, the predictions made by our model are correct.
Conclusions and Recommendations
In conclusion it could be seen that:
- It is recommended to use gray filters to improve the quality of the images
- So that it does not overload the virtual machine, if it is scheduled in a queue, it is necessary to change the image size so that it can read all the images in the dataset.
- In the implemented Data Augmentation, it is recommended that it be applied to improve accuracy.
- It is recommended to implement normalization to make the prediction more accurate.
References:
https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia
http://acodigo.blogspot.com/2013/05/procesamiento-de-imagenes-en-opencv.htmlHow to Configure Image Data Augmentation in Keras – Machine Learning MasteryImage data augmentation is a technique that can be used to artificially expand the size of a training dataset by…machinelearningmastery.com
SyDoJa

Pneumonia
“X-Ray Diagnoses with Pneumonia in Children between 0 and 5 years old with Machine Learning”
MEMBERS:
Dylan Chambi Frontanilla
Joseph Anthony Meneses Salguero
Samuel Matias Escobar Bejarano
COURSE:
Machine Learning
LA PAZ 10/09 — BOLIVIA-2021
More artificial intelligence!
The mission of Saturdays.ai is to make artificial intelligence more accessible (#ai4all) through intensive courses and programs where projects for good are carried out (#ai4good).
Explore our AI master’s programme at https://saturdays.ai/master-ia-online/
If you want to learn more about artificial intelligence join our community at community.saturdays.ai or visit us on our website www.saturdays.ai Join us!
A history of the Saturdays.AI community. Originally published on Nov 11, 2021.
← More community stories


