---
title: Variational Quantum Classifiers (VQC)
url: https://www.emergentmind.com/topics/variational-quantum-classifiers-vqc
type: topic
---

# Variational Quantum Classifiers (VQC)

A Variational Quantum Classifier (VQC) is a hybrid quantum–classical supervised learning model in which classical data are mapped into a quantum state, processed through a parameterized quantum circuit (variational ansatz), and measured to yield class probability estimates. The trainable circuit parameters are optimized via classical algorithms to minimize a task-specific loss function. VQCs are uniquely positioned to exploit the representational power of quantum circuits for nonlinear pattern recognition, particularly on Noisy Intermediate-Scale Quantum (NISQ) devices. Below, the architecture, training principles, design trade-offs, scalability, and practical benchmarks are detailed with direct reference to quantum machine learning applications such as B-cell epitope prediction [2504.11846].

## 1. Circuit Architecture and Data Encoding

The canonical VQC circuit is structured in three stages:
1. **Data-encoding layer** ($U_{\Phi(x)}$): A nonlinear feature map encodes the $n$-dimensional classical input vector $x=(x_1,\ldots,x_n)$ via angle encoding onto $n$ qubits. The encoding uses per-qubit single-qubit rotations:
   \[
   U_{\Phi(x)}\,|0\rangle^{\otimes n} = \bigotimes_{j=1}^n RZ(f_j(x))\,RX(g_j(x))\,|0\rangle
   \]
   where $f_j$ and $g_j$ are problem-dependent nonlinear functions (implemented in Qiskit). This produces a state $|\Phi(x)\rangle$ reflecting the original data distribution but embedded in Hilbert space.

2. **Variational (trainable) layer** ($W(\boldsymbol{\theta})$): Composed of $\ell$ repeated sublayers, each consisting of:
   - An entangling block $U_{\text{ent}}$ (e.g., five consecutive SWAP gates) that couples all qubits.
   - A pattern of local, trainable single-qubit rotations $R(\theta_j)$ (typically $RY$ or $RZ$):
     \[
     W(\boldsymbol{\theta}) = \prod_{l=1}^\ell \left[\text{Entangle}~U_{\text{ent}};~\text{Local rotations}\bigotimes_{j=1}^n R(\theta_{j,l})\right]
     \]

3. **Measurement**: After application of the variational circuit, a single-qubit $Z$ measurement (on, e.g., qubit 1) yields the expectation $\langle Z \rangle$, and empirical class probabilities are estimated through repeated sampling.

The total parameter count is $m = n \times \ell$ for $n$ qubits and $\ell$ variational layers.

## 2. Objective Function, Gradient Evaluation, and Training Protocol

The VQC training is based on minimizing the expected misclassification probability over the dataset $T$. For each sample $x_i$ with label $y_i$:
- The output class probability $p_y(x)$ is estimated from $R$ repeated circuit executions as $p_y(x) = r_y / R$, with $r_y$ as the number of outcome $y$.
- The loss function is defined as
  \[
  L(\theta) = \sum_{i=1}^t \Pr\bigl(\hat{m}(x_i;\theta) \neq y_i | x_i \in T\bigr)
  \]
  An analytical approximation is supplied via the sigmoid of a scaled difference between $p_y$ and a bias term:
  \[
  \Pr\bigl(\hat{m}(x_i) \neq y_i\bigr) \approx \text{sig}\Bigg(\sqrt{R} \cdot \left[2^{-y_i b} \frac{p_y}{\sqrt{2 p_y (1-p_y)}}\right]\Bigg)
  \]
  where $b$ is an empirically chosen bias and $\text{sig}(x) = 1/(1 + e^{-x})$.

Parameter optimization utilizes the parameter-shift rule for exact and hardware-implementable gradients:
\[
\frac{\partial L}{\partial \theta_j} = \frac{L(\theta_j + \pi/2) - L(\theta_j - \pi/2)}{2}
\]
Parameters are updated in an iterative inner loop, typically with gradient descent:
\[
\theta^{(t+1)} = \theta^{(t)} - \eta\,\nabla L(\theta^{(t)})
\]
where $\eta$ (learning rate) is tuned empirically.

Training proceeds in an online manner (batch size $= 1$), iterating over all samples: execute the circuit, evaluate $p_y$, compute loss, compute gradients, and update parameters, until convergence.

## 3. Practical Implementation—Hyperparameters and Pseudocode

The operational hyperparameters include:
- $R$: number of shots per forward pass (controls statistical noise).
- $\eta$: learning rate, often $0.1$–$0.01$ in Qiskit-based experiments.
- $\ell$: circuit depth, set according to the computational budget and expressivity needs.

The pseudocode implementing the VQC workflow is:
1. Initialize $\theta_0$, select the feature map $U_\Phi$ and ansatz $W$, set $R$, $\eta$.
2. For each training sample $x_i$:
   a. Prepare $|0\rangle^{\otimes n}$, apply $U_{\Phi(x_i)}$ and $W(\theta)$.
   b. Perform $R$ repeated measurements; accumulate $r_y$ and compute $p_y$.
3. Calculate $L(\theta)$ and its gradients via the parameter-shift rule.
4. Update parameters $\theta$.
5. Repeat until loss convergence.
6. For inference, assign label $y = \arg\max_y p_y(x)$ after executing $U_{\Phi(x)} W(\theta^*)$.

## 4. Empirical Performance and Comparison with Quantum SVM

On the B-cell epitope dataset, the VQC achieves:
- Accuracy (ACC): $73\%$
- Area under the ROC Curve (AUC): $0.703$
- Matthews correlation coefficient (MCC): $0.148$

Comparative QSVM performance on the same dataset yields $70\%$ ACC, $0.71$ AUC, and $0.42$ MCC. Thus, the VQC slightly outperforms QSVM in raw accuracy but is less robust to class imbalance (lower MCC). This highlights VQC's capacity for nonlinear pattern modeling—increased accuracy at the cost of reduced sensitivity to minority classes, a known challenge in variational models without explicit cost-sensitivity or oversampling [2504.11846].

## 5. Applications, Scalability, and Limitations

VQCs are applicable wherever high-dimensional, nonlinear classification is required but computational and hardware efficiency is essential (e.g., bioinformatics, as in B-cell epitope prediction). The variational approach allows direct adaptation to complex data distributions and is compatible with NISQ-era limitations via shallow depth and batchwise updates.

However:
- Class imbalance remains an outstanding issue—VQCs as constructed are not inherently sample-balance aware.
- The stochasticity from measurement shots must be managed with sufficiently large $R$, with classical optimizer hyperparameters tuned for the resulting noise profile.
- Circuit design, particularly the feature map nonlinearity and ansatz depth, critically influences both expressivity and trainability.

A plausible implication is that deploying VQC for strongly imbalanced biomedical datasets will require incorporation of additional techniques such as cost-sensitive loss or class-conditional resampling to maximize both raw and balanced accuracy.

## 6. Design Considerations for Future Work

The VQC paradigm supports generic deployment across domains—feature map, ansatz structure, loss, and training procedures are modular. However, practical improvements necessitate:
- Optimizing the choice of $f_j$ and $g_j$ in the feature map for specific data modalities.
- Integrating advanced optimizers that mitigate gradient noise.
- Extending evaluation metrics beyond accuracy to include robust measures like MCC for imbalanced datasets.
- Benchmarking against both quantum and classical baselines for comprehensive assessment.

Given the observed class imbalance sensitivity, future iterations should prioritize improved loss formulations and data augmentation strategies to ensure VQC scalability to larger, more heterogeneous datasets [2504.11846].

Source: https://www.emergentmind.com/topics/variational-quantum-classifiers-vqc