Deep Learning methods can help in diagnostics of COVID-19

by Pavel Kochubey

Machine learning encapsulates the way artificial intelligence is programmed to learn through experience, not unlike the human mind. This process includes a natural development of specific skills over a period of time.

This can be seen in businesses in the field of communication as virtual receptionists listen to the requests of customers to send them to the correct operator. AI exists in entertainment as human chess players compete against computer players. Furthermore, the use of AI and machine learning have been expanding throughout the field of health care.

There are many ways the healthcare system is already implementing AI. Systems are being used to help physicians diagnose cancer more accurately, an algorithm that works to pair a patient's symptoms with certain illnesses. There are programs designed to catch diseases such as cancer in the earlier stages that are more difficult to diagnose. These were just a few examples of how AI and machine learning are being used in the medical world, and there are many more ideas already being administered in the field. The possibilities with AI are endless, limited only by human imagination.

Check more examples of artificial intelligence here

In 2020 the healthcare field has faced a tremendous challenge as it tackles the outbreak of COVID-19 worldwide. The health care system has been overworked, and many medical professionals are left exhausted and hopeless. It is in such situations that the implementation of AI seems most appropriate, in an attempt to help professionals deal with this crisis efficiently. An important role of AI is to assist human workers in day to day tasks and to perform with accuracy and efficiency. AI brings to the table several benefits. For example, AI does not suffer from exhaustion, it does not get bored with menial tasks, and it does not miss small details that a human eye may accidentally jump over.

In most cases, companies already have access to a wealth of data that can be used to train AI. The article below showcases one way that programmers may learn to build their own AI to help with this current medical crisis.

Detecting COVID-19 in X-ray images using ML.NET.

Attention! The methods described in this article are for educational purposes only. This is not a strong scientific study, the article does not describe a reliable and accurate diagnostic system for COVID-19, this has not been tested from either a professional or academic point of view. This article is for people who are interested in incorporating deep learning into their practices, and for people who want to learn through practice, this article does not contain a deep theoretical concept about machine learning and the methods used in it.

ML.NET

ML.NET is a free, cross-platform, open-source machine learning framework made specifically for .NET developers. Developing and supporting simple classic tasks is all about preparing data for training and a couple of mouse clicks. Here are all the pre-prepared scenarios that are currently supported:

Binary and multi-class classification
Price prediction
Image classification
Recommendation

You can also build your own machine learning scenario, which is limited only by your imagination. You can read more about ML.NET on the official website.

About the machine learning process

We'll use supervised learning. This is when there is a dataset that a supervisor has prepared in advance. The accuracy of this data should be close to 100%. To classify images - the supervisor assigns each picture to a certain class, and the class acts as a label. For example, it differentiates between different pictures of different things like a picture of a flower, a cat, or a dog.

https://www.cs.toronto.edu/~kriz/cifar.html

For now, we will not go into the types of neural networks and how they affect accuracy, as we will be using the pre-trained model in ML.NET. Let's assume that the algorithm chosen by default gives satisfactory accuracy.

If this is the case, it is necessary to understand how the training of the model will take place. Deep learning is a long and difficult process, so why is it that we will be able to train a model in just a few minutes? The key is the use of transfer learning. It is a process that incorporates a ready model of machine learning, but the resulting classes are redefined according to classes for your data.

https://www.cs.toronto.edu/~kriz/cifar.html

Dataset for training

The basis of any machine learning is data, and the more of it, the better. Good data needs to be taken from somewhere and processed, prepared before it can be sent into the deep learning process. I found the article COVID-19 Image Data Collection by reading the link to GitHub this repository contains X-ray images of patients who tested positive for COVID-19. However, we need to compare viral pneumonia with a normal state or bacterial pneumonia, for this purpose Kaggle has a good collection of Chest X-Ray Images (Pneumonia) dataset from which we can take a normal lung state. Let's start creating our dataset, for this we will download all the links above.

Code

https://github.com/ieee8023/covid-chestxray-dataset

Let's write a script on python, which will prepare and pull out the images with positive results on COVID-19. Run this script at the root of the COVID-19 Image Data Collection project.

From the Kaggle dataset, drag the pictures from the normal state folder to yourself. You can download the data set I prepared by the link. It contains 128 pictures for each class (normal and covid-19).

Create a project in Visual Studio 2019

If you already have Visual Studio 2019 installed, you will only need to install Model Builder to prepare the model for deep learning.

Create a new project, Console App (.NET Core).

After creating a project, right-click on the project, select Add and Machine Learning item.

In the window that appears, select Image Classification. On the next step, specify the path to the images. Here the screen will display how the structure of directories should look, whose names will be used as class names.

https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia

Press Train and wait for the neural network to process our data. After a brief moment (the speed of which depends on your data and the algorithm that the neural network is using to learn), you will see a report on the training method used and the accuracy of the neural network.

Click Evaluate and try to submit images of X-rays that the neural network has not seen before. I have 5 images with positive results on COVID-19 and 5 with a normal state. All 5 with positive results are successfully detected by the network, here is one of the results:

https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia

From the validation set, 4 out of 5 normal lung states are detected correctly. One image is detected as COVID positive, which is, in principle, a network error. Correct prediction for the normal state of the lung:

https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia

To finish the model generation process, click the Code button and then on the next window the Add Project button. After that, you will add new projects with a prepared model that you can use in your application for prediction. Read more about how to train the model on new data in the official documentation of The ML.NET Model Builder tool.

What's next

ML.NET allows you to quickly and easily train the neural network on your data. All you have to do is prepare a good data set.

In our example, to reduce neural network error and, as a result, increase accuracy, you need to increase the data sets on which the neural network will be trained. What can you do to improve the neural network?

Use fresh data from the repositories.
Expand the normal dataset and see how the result will change.
Replace a fully normal dataset with a bacterial pneumonia dataset.

Each of these items can drastically change the quality of the model. Please leave comments below to get more involved in the learning process and how machine learning can benefit the healthcare system or other applicable fields.

If, after reading this article, you have any questions about AI and machine learning or you want to know more about how these ideas can help your industry, we are happy to open up this conversation. For anyone interested in expert advice, we offer free consultation services, don't hesitate to contact us and connect!

Bio:

Pavel
Pavel Kochubey is a software developer with a long catalog of experience. His primary role includes teaching developers to get results with modern machine learning methods via hands-on tutorials

Editor and collaborator Maria Birger

Previous How to use AI in Business Communications
Next Machine Learning in Clinical Research

Make Your Business Vision a Reality

Step 1

Tell us about
your business needs

Step 2

We analyze and
contact you

Step 3

We provide a FREE
no obligation estimate

Let's Talk
Let's Discuss Your Project or the Software Team You Need
(Ex: 919-373-5059)
(optional)