Predicting Early Heart Diseases With Quantum Support Vector Machines

A Detailed Overview on QSVMs and Their Impact Towards Disease Prediction

Priyal Taneja
13 min readApr 3, 2023

In the United States of America, one person dies from a cardiovascular disease every 34 seconds.

It took me roughly ~32 seconds to type that sentence out.

It’s absolutely insane.

Within the minute I’ve spent writing this article so far, 2 people have probably passed away with their cause of death being a heart disease of some sort. By the end of your read, the number will stand at ~26 people. Within a year, an estimated 17.9 million people die each year globally from cardiovascular diseases.

Quantifying it in that sense is extremely scary, but it also provides a clearer indication of the magnitude of the problem.

Before getting into anything else, I want to understand the problem in its entirety. We’ve already figured out the quantitive impact of heart diseases. But, what about the basic fundamentals that are responsible for that number? What are its affecting variables? What is the root cause?

Of course, risk factors that impact the number include one’s record of smoking, high blood pressure, high cholesterol etc. But, when boiling this number down to determine why it’s so high — despite us having control on our habits that create those risk factors — it comes down to how often these diseases can go undetected. That is the root cause of the heart disease mortality rate being within the millions.

Like many other complex conditions, you’re not aware of it being present until its reached an advanced stage, as the early phases usually don’t have any obvious symptoms for us to question.

It’s why heart diseases are named as a ‘silent killer’ — because they silently progress over time, and by the time symptoms appear, it’s usually too late to prevent serious complications or death.

So, based on information, reducing that number down can fall into one of two paths; curing the disease at its last stage or diagnosing it earlier, when we are able to treat it.

The issue with the former is the complexity behind the solution — it’s nearly impossible to reverse the heart’s lack of ability to pump blood, due to the significant damage done.

But, diagnosing the disease earlier is a step towards streamlining the large rate of deaths that stem from heart diseases, so that we can manage and tackle this condition when are able to ‘easily’ do so.

We need to take action towards avoiding preventable mortality rates.

Status Quo — What’s Being Done?

Currently, scientists have been exploring a range of solutions — including screening programs, advanced imaging technologies, biomarkers, wearable devices and telemedicine — to test for risk factors of heart diseases. But, one of the greatest focuses right now lies within the field of Artificial Intelligence.

Right now, we’ve identified that there’s risk factors that may impact one having to battle a heart disease, including:

  • Age
  • Gender
  • Family History
  • Smoking
  • High Blood Pressure
  • High Cholesterol
  • Diabetes
  • Obesity
  • Physical Inactivity
  • Unhealthy Diet

After a while, making connections or determining patterns between those risk factors’ state & its correlation to a heart disease can help us. So, if someone had a high age, high blood pressure level and history of smoking, you could predict that they’re at risk for a heart disease — allowing for more preventative measures within their lifestyle to avoid or detect the disease earlier.

Humans could do this manually, but it is a time-consuming and labor-intensive process. Also, human analysis is subject to errors and biases, which can impact the accuracy and reliability of the results.

So. Technology. That’s our next bet.

We can leverage artificial intelligence to analyze vast amounts of data quickly and accurately along with identifying patterns and trends that may not be apparent to human analysts. This is done specifically through something called Support Vector Machines.

Formally, Support Vector Machines (SVMs) are a type of machine learning algorithm that can be used for classification and regression analysis problems.

They work by creating a boundary (also called a ‘hyperplane’) that separates different classes of data points in a high-dimensional space. The hyperplane’s goal is to maximize the margin between the data points of different classes, so that unseen data can be classified in the same manner.

Visual Representation of SVMs

If technical terms made no sense, let’s turn our sports brains on. Think of the SVM as a football coach that’s trying to create a good defensive strategy. The coach needs to create a game plan that effectively defends against the opposing team’s offensive strategy, so he’ll separate the different types of players accordingly on the field.

Support Vector Machines are very common. I’m sure we’re used to our mailing softwares predicting which email is meant for your inbox and which one is spam — and SVMs are responsible for all of that.

In the context of diagnosis prediction, they’re quite strong as well… to a certain extent. They’re a powerful tool as the data is complex & high-dimensional, and its accuracy is strong.

But, even though AI technology has advanced significantly, there is still a limit to the amount of data that our AI models can effectively analyze. Unfortunately, this limit is considerably smaller than the amount of data required to make accurate predictions in real-world scenarios.

This limitation creates the solution to be one that’s inefficient and less effective for practical purposes.

Leveraging Quantum Support Vector Machines

The key to overcoming this barrier between the problem and an efficient solution are Quantum Support Vector Machines.

Quantum + Support Vector Machines = QSVMs

Note: This is probably a good time to highlight that if you’ve never heard of quantum computing before, the next part of this article won’t be easily digestible. So, I’d recommend reading my Quantum Computing 101 article first, and then coming back to this. Either way, I hope you learn something new today!

QSVMs are exactly what you might be thinking; they’re a quantum machine learning algorithm that use the principles of quantum mechanics to perform classification and regression tasks.

The basic idea behind them is that they use quantum computers to perform the computations we would with a SVM algorithm, in a more efficient manner. Therefore, QSVMs are resolving our efficiency challenge while preserving the current status of what we’re doing. Super simple.

But, let’s breakdown how Quantum Support Vector Machines work and how we can predict heart diseases earlier with this algorithm.

Data Preparation

Of course, we’ve identified that we need to analyze a bunch of data, prior to our predictions. So, our first step is to prepare that data into a manner that is understandable by the quantum computer, because currently we’re working with classical data.

It’s represented as:

Here, |xrepresents a classical input data vector which is transformed into a quantum state — |Φ(x)⟩ — through applying a unitary operator — U(x)|0⟩ — to its initial quantum state |0.

Without its complexity, the filtered data of risk factors for heart diseases (so the most relevant factors that is cleaned out without any biases or duplicates) is transformed into a quantum state using a quantum feature map, and this feature map is a unitary operation that maps classical data to a quantum state through applying a sequence of quantum gates.

This ‘feature map’ being discussed can be implemented through various quantum circuits, but the most common ones are quantum Fourier transform or amplitude encoding.

These two techniques have the end goal of mapping the classical input into a way that it can be processed by quantum algorithms, but the paths there differ from each other:

  1. Quantum Fourier transform (QFT): This quantum circuit transforms classical data into a quantum state that has the property of being periodic, which can help within certain types of classification problems that require periodic functions. And, this is done through manipulating the states with a series of Hadamard and controlled-phase gates to a set of qubits.
  2. Amplitude Encoding: This quantum circuit encodes the classical data into amplitudes of a quantum state through using the input data’s binary representation to provide it with a quantum representation of its amplitude, as in quantum mechanics the state of a quantum system is described by a wave function. It allows the quantum state to represent a much larger space of data than classical data, which can be useful for certain types of classification problems, such as those involving high-dimensional data.

The choice of the quantum feature map within a QSVM depends on the nature of the data and the specific problem being solved, and these are simply the most common feature maps. Regardless, the intention behind the circuit is the exact same — to translate the classical input data of our risk factors into a quantum state.

Quantum Kernel Calculation

Once our data is prepped and ready to go, we can proceed forward to our next step.

Now, we calculate a matrix — an array of numbers — that describes how similar each pair of input data points are in their quantum feature representation. And, this is done through a Quantum Kernel Calculation.

The results from this matrix can help us classify; heart disease present or healthy heart? Formally, the two categories we’ve stated for classification are known as ‘classes’ and since there’s two classes, it’s a binary classification problem.

The type of matrix we’re specifically looking for is called a kernel matrix, and it describes the pairwise inner products between the quantum feature vectors corresponding to the input data points.

In simple terms, this means that a mathematical operation with the vectors of the quantum states are calculated, to obtain a measure of similarity between those two data points in their quantum feature representation. That similarity value can help us form the hyperplane, so we can correctly categorize our data into its binary classifications.

So, let’s say that we preprocessed our data through amplitude encoding. The quantum kernel function for the circuit is defined as:

Here, |ϕ(x)⟩ and |ϕ(x’)⟩ are the quantum states corresponding to the input data points x and x’, respectively, and ⟨ϕ(x)| and ⟨ϕ(x’)| are their conjugate transpose states.

In order to determine the quantum kernel matrix for a set of input data points, we can use a quantum circuit to apply the amplitude encoding circuit to all pairs of data points, before measuring the overlap between their quantum states — which can be done through quantum phase estimation.

This algorithm estimates the eigenvalues of the unitary transformation matrix — U(x, x’) = U(x)† U(x’) — that is in correspondence to the quantum kernel function. And, once the estimated eigenvalues have been obtained, we can use those to compute the quantum kernel matrix that will calculate the inner-products.

It can be represented as…

… where λ_k and u_k are the eigenvalues and eigenvectors of the matrix U(x, x’), and u_ik and u_jk are their corresponding components for the k-th eigenstate.

All that’s happening within this computation is the calculation of the the kernel value Kij by summing up the product of the eigenvalues and corresponding eigenvector entries for all k. This is equivalent to taking the inner product between the i-th and j-th columns of the eigenvector matrix, weighted by the corresponding eigenvalues.

Once that step is completed, a hyperplane — that creates a margin to separate data points for a healthy heart and a heart-disease-infected heart — should be formed.

Quantum SVM Training

Moving onto the most important part of this algorithm, the computer’s training.

Just like humans, our machines need to learn a task before mastering it. And, in this case, it’s more than important to ensure that our quantum computer is fully trained on how to predict someone being at risk for a heart disease.

The goal within this step is to optimize the parameters of our circuit to achieve the best classification results. This is usually done through optimization algorithms such as the QAOA or the VQE.

Either way, these algorithms are used to minimize the cost function — which is a measure of the model’s accuracy and how well it fits the training data.

Mathematically, it’s represented as…

where:

  • w = weight vector
  • b = bias term
  • xi = training input vector
  • yi = corresponding output label
  • λ = regularization parameter

Throughout this process, all the potential parameters value within the quantum circuit are represented through a Hamiltonian matrix. So, through here, the optimization algorithm works by finding the ground state of the Hamiltonian, which corresponds to the minimum energy state of the system.

Either way, the quantum circuit iteratively modifies the parameters of the model to find the minimum value of the cost functions. And, these parameters involve those in the equation above, including: the weight vector, the bias term and the kernel parameters. In the end, the optimization algorithm seeks to minimize the cost function by finding the optimal values of these parameters.

This is usually the most time-consuming aspect of the algorithm, but it’s also vital for the circuit to familiarize itself with the all of the data points — in order to confidently make the correct analysis.

Measurement and Prediction

And, here comes the final step that concludes our algorithm.

Now, we’ll work towards obtaining a classical output from the quantum state that was prepared and manipulated in the previous steps. So, remember when we ‘mapped’ the classical states onto a quantum state? We’re essentially reversing that through mapping the existing quantum states onto its classical states.

This is done through a measurement that projects the quantum state onto a classical state — and, this outcome can be any of the possible classical states that correspond to the quantum state amplitudes.

Once our model is fully trained, in order to get the class label on a new input data point, the same steps in the training phase are applied where the input data is first encoded into a quantum state using the quantum feature map, and the quantum kernel is calculated using the same process as in training. So, when a new input reaches this stage, it’ll go through the processes above before getting measured into the two classes within this problem.

Anyways, the measurement process is a crucial step in the QSVM algorithm, as it enables the extraction of classical information from the quantum state — which is what humans will use to further communicate results.

The measurement can be mathematically expressed as the probability of obtaining a particular classical state |i⟩ given the quantum state |ψ⟩ as:

Here, |i⟩ represents one of the possible classical output states that can be obtained upon measurement, and ⟨i| represents the corresponding conjugate transpose of |i⟩. And, the notation ⟨i|ψ⟩ represents the inner product between the classical state |i⟩ and the quantum state |ψ⟩.

And, the absolute value square of ⟨i|ψ⟩ represents the probability of obtaining the classical output state |i⟩ when measuring the quantum state |ψ⟩.

All in all, you’ve finally received your classical output that can be used to dictate whether or not someone is at risk for a heart disease or not.

A Quantum Advantage?

In theory, QSVMs have the potential to offer an exponential speedup in comparison to classical SVMs, as they leverage quantum computers. The ability of quantum computers to perform certain computations in parallel can provide users with a ‘quantum advantage’ that can improve the efficiency of the existing solution.

The main area in which Quantum Support Vector Machines have this speedup is within the kernel calculation step. Within classical SVMs, the kernel matrix must be explicitly computed, which means the kernel function is applied to all pairs of data points. This creates a time-consuming step for larger datasets.

In contrast, QSVMs can use quantum algorithms to calculate the kernel matrix in parallel, and it’s implicitly computed using quantum circuits. This difference between these steps allows for a faster and more memory-efficient process.

Limitations

However, the limitations in relation to this solution cannot be ignored, as it’s still a long time before this is deployed for regular use.

Decoherence is the number one risk. Quantum computers are susceptible to noise, which means qubits are sensitive to compute on due to their external environment which can often interfere and mess-up the existing quantum states. This would be problematic for tasks such as disease prediction, as you require accurate results that humans can blindly trust.

Adding onto decoherence, QSVMs need a high number of qubits, and since we know they’re sensitive, having more qubits that aren’t definitive in producing accurate results would be hard to manage. The connectivity between the qubits may be difficult to achieve with the current quantum computers available today.

Long-Term Impact

But, all of these limitations are being worked on as the development of quantum computers continue. When we reach a point in building quantum computers where issues like the number of qubits and noise don’t exist, the long-term impact of leveraging QSVMs to predict early heart diseases can be significant.

We’ve already determined that early detection and accurate diagnosis of heart disease can help prevent the ‘silent killer’ and the serious health complications involved.

Through a fully-developed QSVM, the earlier interventions can ultimately save lives — helping to reduce the status quo (17.9 million people globally) so we don’t see those around us losing their lives to a silent killer.

Hey, I’m Priyal, a 17-year-old driven to impact the world using emerging technologies. If you enjoyed my article or learned something new, feel free to subscribe to my monthly newsletter to keep up with my progress in quantum computing exploration and an insight into everything I’ve been up to. You can also connect with me on LinkedIn and follow my Medium for more content! Thank you so much for reading.

--

--

Priyal Taneja

​a 17 year old who’s ambition revolves around working on solving complex problems to meaningfully contribute to the world https://priyaltaneja.typedream.app/