Extended Quantum Computing Patterns
Quantum Classification
Aliases: –
Tags:
© L. Stiliadou, J. Barzen, M. Beisel, F. Leymann, and B. Weder, Patterns for Quantum Machine Learning, in Proceedings of the 17th International Conference on Pervasive Patterns and Applications (PATTERNS), Xpert Publishing Services (XPS), 2025.
Intent
How to train a classifier to assign new data points to one of multiple classes using a quantum device?
Context
New data points need to be classified into one of several different classes. A labeled set of training data is given.
Forces
Classifying data is getting increasingly more difficult when the feature space becomes larger [Havlicek et al., 2019]. While quantum computing enables solving this problem by utilizing efficient quantum algorithms, it also leads to additional challenges. For example, high-dimensional data sets can lead to large quantum circuits that may not be successfully executable on today’s Noisy Intermediate-Scale Quantum (NISQ) devices [Preskill, 2018]. Additionally, quantum approaches can suffer from exponential cost concentration, which makes models less sensitive to input data, leading to generalization problems [Thanasilp et al., 2024] [Arrasmith et al., 2022].
Solution
Train a classifier using a quantum device to classify new data points precisely. In Figure 3, an overview of two different approaches for training a classifier is depicted. Classifiers can either be trained using (i) a kernel-based method or (ii) a variational method. Generally, the input for training a classifier is an initial set of labeled data \(\{(x_i, y_i)\}^n_{i=1}\), where \(x_i\) are the feature vectors, \(y_i\) are the labels, i.e., real numbers, and n is the size of the training set. In the kernel-based approach, a quantum kernel is used to measure the similarities between data points by mapping them into a high-dimensional Hilbert space and computing the inner product of their corresponding quantum states. This quantum kernel is computed for all pairs of training data by applying a unitary \(U_ϕ(x_i)\) to encode each data point xi into a quantum state. The adjoint operation \(U^{\dagger}_ϕ(x_j)\) is then applied to calculate the overlap between the states corresponding to \(x_i\) and \(x_j\). Then, a classical algorithm, e.g., a classical support vector machine Burges, 1998], is used for computing the classifier based on the previously calculated kernel. Alternatively, the variational method optimizes the parameters of a quantum circuit to directly realize the classifier. In this approach, a data point x is first encoded into a quantum state using a unitary \(U_ϕ(x)\), which maps the classical data into a quantum state. Once the data are encoded, a parameterized quantum circuit is applied. The circuit produces an output whose expectation value < V > determines the predicted label for a given data point x. The parameters of the circuit are iteratively optimized by a classical optimizer that minimizes a quantum cost function that calculates the differences between the predicted and actual labels from the data set.
Result
After the training process, the classifier can be used to assign new data points to one of the existing classes. Utilizing a quantum classifier may enable training a more accurate classifier than using a classical classification technique [Kavitha and Kaulgud, 2024]. Quantum classifiers still function under the influence of noise as they are resistant to a small number of misclassifications [Havlicek et al., 2019]. This is particularly important with the noisiness of today’s quantum devices. However, mitigation mechanisms must be implemented to address the challenges, such as cost concentration in kernel values or flatness in the optimization landscape [Cerezo et al., 2021] [Thanasilp et al., 2024].
Examples
An example is the kernel-based quantum support vector machine [Rebentrost et al., 2014], achieving logarithmic complexity with respect to both the data dimension and the number of training examples. Another example is the variational quantum support vector machine [Havlicek et al., 2019] [Gentinetta et al., 2024], which uses a parameterized quantum circuit to directly implement a SVM on a QPU.
Related Patterns
The Quantum Random Access Memory (QRAM) Encoding pattern [Weigold et al., 2021a] can be utilized to achieve a speed-up when encoding data. A quantum classifier can be realized using a Variational Quantum Algorithm (VQA) [Weigold et al., 2021b].
This pattern is a refinement of Quantum-Classic Split (Leymann 2019). Within the quantum computation, Initialization (Leymann 2019) is used.
Known Uses
To train the quantum classifier, different approaches can be used, e.g., variational quantum support vector machines [Ramirez, 2024] [Havlicek et al., 2019], quantum decision trees [Lu and Braunstein, 2014], and quantum nearest neighbor classification [Roga et al., 2023]. Furthermore, quantum classifiers have been applied in different application areas, e.g., image recognition [Li et al., 2024], analyzing the sentiments of sentences [Ruskanda et al., 2023], and predicting air pollution [Farooq et al., 2024].