Can Artificial Intelligence be used to Predict Heart Attacks?

Original article was published by Ava Gharib on Artificial Intelligence on Medium

Can Artificial Intelligence be used to Predict Heart Attacks?

Image from Memorial Herman Heart and Vascular Institute

About 1 in every 3 deaths in America is from a heart failure. The CDC rates heart disease as the № 1 cause of death in the United States. It’s clearly a prevalent problem in our modern day society. But what if I told you there was a way to predict when heart attacks would occur, saving thousands of lives?

Artificial Intelligence

Artificial Intelligence (AI for short) is our solution! Before you learn just how a robot can predict a fatal heart failure, you need a little background. AI is the ability of a computer to perform tasks deemed “intelligent”, such as classifying images or emails. So read on to find just how this system works!

Image created by author

The two main types of AI are Expert Systems and Machine Learning. Expert Systems is where a human programs a computer to do a specific task. Machine Learning uses algorithms to model and learn from data. In our example of creating a machine that can predict when a heart attack will occur, there is no human that can do so. Thus, we cannot use Expert Systems to solve this.

We must use Machine Learning. The two main types of Machine Learning are Supervised and Unsupervised learning. Their names describe how the machine learns. Let me explain just what that means.

Supervised Learning

Supervised learning uses labeled data. It’s very efficient, but it has some limitations. For example, all of the input and the output data must be known. In addition, there is a problem with training your model too well, and it’s called “overfitting.” This means that some random fluctuations that happen to appear multiple places in the training data are learned the same as concepts by the model. However, these concepts do not necessarily apply to new data, as they are just coincidences, and will deteriorate the model’s ability to generalize.

Unsupervised Learning

Unsupervised learning draws its conclusions by finding similar characteristics in data and clustering them together. While it is not as efficient as Supervised Learning, the advantage is that no labels are needed which is particularly beneficial given that the majority of data in the world is not labelled. Additionally, overfitting of Unsupervised data is not a concern.

Choosing the right type of Machine Learning

Now that we know the two main types of machine learning, which one would be most useful for predicting when a heart attack will strike? There are dozens of Supervised and Unsupervised machine learning algorithms, each taking a different approach. For studying heart attacks, we’d have to train our machine from data in which we know certain factors from patients’ previous data. All of this data would be labeled, thus it makes more sense to use Supervised Learning.

Inputs and Outputs

How exactly would we make a Supervised Learning machine predict heart attacks? We’d have to collect data such as age, weight, height, blood pressure, and EKG tracings from patients, and also whether each patient had a heart attack within the year. We want our machine to use this data to learn what patterns are associated with heart attacks. We can then have our machine detect those patterns in a different group of patients to determine who in this group will have a heart attack that year. Now here comes the good part!

How do we train our machine?

A common analogy is a classroom, but with an evil teacher. The teacher randomly builds the students, then tests them without teaching them. The student with the best score is selected and more students are built like that. The other students are disposed of. The next student to score the highest becomes the model student and all others are removed. This process, called back propagation neural network, continues until it is near perfect, with the machine “learning” each time.

Image from Colocation America

Wouldn’t this take ages to find a combination with a high accuracy? Well, our classroom is not like a normal 25-kid classroom. This classroom has thousands upon thousands of machines being built, tested, and deleted simultaneously.

In the case of our robot who can predict heart attacks, the test would look something like the following:

Age: 73. Weight: 230 lbs. Height: 5’9″. Blood pressure: 150/90.

Heart attack within the year? Yes or No.

The machine would then predict Yes or No. Then, we check the data to see if the patient in question did have a heart attack that year. If reality and the machine’s prediction align, the machine is correct, and if not, it’s incorrect. Once a machine consistently scores as well as you would like (e.g. 98%), your machine is ready to be used on new patients.

Now you have a machine that can take some input values and tell pretty accurately whether one will have a heart attack within the year!

Where is this implemented?

In the 2019 International Conference on Nuclear Cardiology hosted in Paris, researchers from Lisbon, Portugal presented a study conducted on a machine that has the ability to predict heart attacks with “modest accuracy”. The algorithm uses 85 variables to calculate risk in individuals.

The author of this study, Dr. Luis Eduardo Juarez-Orozco, said, “The algorithm progressively learns from the data and after numerous rounds of analyses, it figures out the high dimensional patterns that should be used to efficiently identify patients who have the event. The result is a score of individual risk.” This is the machine we have detailed in this article!


Artificial Intelligence is a broad topic referring to anything “intelligent” that a machine does. When it’s programmed to do a specific task by a person, it’s known as Expert Systems, and when the machine learns on its own, it’s referred to as Machine Learning. Machine Learning learns from data; when this data is labelled and categorized, it is called Supervised Learning, and when this data is unlabelled, its name is Unsupervised Learning. It may seem overwhelming, but this technology exists in our modern-day world!