Pairwise classification using quantum support vector machine with Kronecker kernel

We investigated the potential application of quantum computing using the Kronecker kernel to pairwise classification and have devised a way to apply the Harrow-Hassidim-Lloyd (HHL)-based quantum support vector machine algorithm. Pairwise classification can be used to predict relationships among data and is used for problems such as link prediction and chemical interaction prediction. However, in pairwise classification using a Kronecker kernel, it is very costly to calculate the Kronecker product of the kernel matrices when there is a large amount of data. We found that the Kronecker product of kernel matrices can be represented more efficiently in time and space in quantum computing than that in classical computing. We also found that a pairwise classifier can be effectively trained by applying the HHL-based quantum support vector machine algorithm to the Kronecker kernel matrix. In an experiment comparing a classical algorithm with a quantum support vector machine with a Kronecker kernel run on a quantum computing simulator, the misclassification rate of the latter was almost the same as that of the former for the same pairwise classification problem in some cases. This indicates that a quantum support vector machine with a Kronecker kernel algorithm can achieve accuracy equivalent to that of the classical algorithm more efficiently and scalably. This finding paves the way for applying quantum machine learning to predicting relationships in large-scale data.


Introduction
A machine learning algorithm uses training data as input, learns the rules and properties inherent in the data, and solves problems such as regression and classification for unknown data. These algorithms are currently used in various fields, such as recommendation systems for e-commerce sites (Sheikh et al. 2019) and reaction prediction for chemical substances (Stocker et al. 2020), and represent one of the key technologies supporting artificial intelligence.
Domingos, a machine learning researcher, categorized machine learning researchers into five major tribes: symbolists, connectionists, evolutionists, Bayesians, and analogists (Domingos 2015). Each tribe has different ideas about learning and a core algorithm. Connectionists consider the brain to be represented by its operating principles and learn by adjusting the strength of connections between neurons. Analogists see similarities between situations as the key to learning and thus reasoning about other similarities. Their core algorithm is the support vector machine (SVM), a machine learning algorithm proposed in Cortes and Vapnik (1995). It is a general-purpose algorithm that can be applied to regression problems, classification problems, etc. It finds the optimal solution by maximizing the margin.
The use of SVM in combination with the kernel method, which uses a kernel function to represent the similarity between the data, enables data to be mapped into a feature space for training and prediction. The use of a kernel trick enables various feature mapping functions to be virtually used without explicitly computing highdimensional feature mappings. This is a major advantage of the kernel method, and the flexibility to choose a feature mapping function for the target problem makes it possible to use the appropriate feature space for the problem. This improves the classification accuracy of the learned model. Another advantage of the kernel method is that it has clear theoretical properties, such as the fact that learning with SVM is often formulated as a convex optimization problem (Bishop 2006), which guarantees that a global optimal solution can be found.
There are, however, disadvantages of the kernel method, such as its computational complexity. When calculating the inner product of the data using the feature mapping function, the amount of calculation is substantially higher when using large-scale datasets, which may become a bottleneck in the training process. Connectionist approaches using deep neural networks are thus often used for large-scale datasets, but they also have disadvantages, such as model complexity (which makes it impossible to guarantee the optimality of the learning results), low interpretability, and a lack of theoretical understanding of generalization performance. For these situations, recently, some research has focused on the dynamics of neural networks in learning (Jacot et al. 2018).
The use of various machine learning models has been increasing along with the growth of big data. However, the increasing amount of data that is handled increases the time it takes to train machine learning models. Therefore, it is important to develop models that are scalable with the amount of training data.
Quantum computing is used in various fields, including quantum mechanics (Nielsen and Chuang 2010). In quantum computing, the key to gaining an advantage over classical computing is to make effective use of two unique properties: superposition and entanglement. Superposition is the ability to maintain multiple states simultaneously, which is generally not easy to do with classical computing. Superposition makes it possible to compute in parallel and to use amplitudes, or degrees of overlap, in calculations. Entanglement enables a dependency to be introduced between the states of each qubit, making it possible to create more complex superposition states.
Various research has been conducted on high-performance algorithms that use these properties, including Shor's algorithm (Shor 1994), used for prime factorization, and Glover's algorithm (Grover 1996), used for the fast search of unordered data. Many other algorithms have been proposed that can reduce computational complexity compared to the currently used algorithms. Some groups (Arute et al. 2019;Zhong et al. 2020) have recently published research results showing that quantum computing is faster than classical computing on certain tasks. There are also some quantum-inspired methods, which are classical methods based on the idea of existing quantum methods. Liu et al. (2021) tackles the classical computational complexity tasks in Arute et al. (2019) and shows that classical methods can tackle the same task almost as fast as quantum model.
In quantum machine learning, exponential speedup based on the Harrow-Hassidim-Lloyd (HHL) algorithm has attracted much attention, and various models have been developed. Machine learning algorithms that aim to quadratic acceleration using Grover's algorithm (Grover 1996) have also been developed. A recent trend is not only to use fast quantum algorithms to accelerate machine learning subroutines, but also to theoretically discover machine learning tasks or domains that are relatively easy for quantum computing but difficult for classical computing. As a result of recent algorithmic developments, expectations for quantum computing have been rising in recent years.
Hardware for quantum computers has also been the subject of intense research. A variety of materials for quantum computers are being considered, including superconductors, ion traps, and light. Each material has certain advantages and disadvantages in terms of performance, such as ease of integration, the number of clocks, and the fidelity of gate operations, and it remains to be seen which material will bring the greatest advantage.
Despite the rising expectations, the problem settings in which quantum computing can demonstrate its superiority over classical computing are very limited at present because of the noise factor and limited hardware scalability. This makes finding useful applications a major issue. The use of quantum computing in machine learning should speed up the linear algebra operations used in the computation and is thus a candidate application. The quantum SVM ) is an algorithm for quantum machine learning and, under certain conditions, it can exponentially reduce computational complexity compared to existing SVMs. The implementation of quantum SVM is studied in Li et al. (2015) and Yang et al. (2019).
We have devised a quantum SVM with the Kronecker kernel for the pairwise classification problem, which is the problem of determining whether two sets of data satisfy a certain relationship. It has been studied in a number of classical computing methods. Kronecker kernel, one of the kernels used in pairwise classification, is difficult to apply to large-scale data in classical computing because the Kronecker product of the kernel matrix is huge. On the other hand, in quantum computing, the Kronecker product of matrices can be expressed simply by using the tensor product of quantum states, so the computational complexity is smaller than that in classical computing. This means that it is easy to scale up to large-scale data. We thus hypothesize that the pairwise problem is a candidate problem setting in which quantum computing may have an advantage.

Methods for simple classification problem
Before discussing the pairwise classification problem, we first discuss a simple version of the problem to make the subsequent explanation easier to understand. The classification problem is to predict the label assignment of the test data using training data for which the label assignment is already known. Here, we focus on the binary classification problem, the simplest classification problem. Let d ∈ ℕ be the dimension of feature vector, the set X ⊂ ℝ d be a dataset, vector x ∈ X be a data point, and set C + , C − ⊂ ℝ d be two classes that divide set ℝ d ; i.e., In the binary classification problem, the values of x and f (x) are given for some x as a training dataset but not for a test dataset. The goal of the binary classification problem is, for a new data point x ∈ ℝ d in the test dataset, to predict the value of f (x).

Kernel method
One approach to solving pairwise classification problems is to use the kernel method (Schölkopf et al. 2002), which enables classification in a high-dimensional space by replacing the inner product of data points in the model formula with a kernel function. Different kernel functions yield different classification boundaries.
Let k be a function of two variables over ℝ d (this explanation also applies when k is a two variables function over arbitrary set X; but for simpleness, we describe here the case X = ℝ d ). Function k is a kernel function over ℝ d if it satisfies two conditions: holds for all x, y ∈ ℝ d . (ii) positive semidefiniteness, i.e., holds for any n ∈ ℕ and all {x 1 , … , Here we define ⟨⋅�⋅⟩ as a regular inner product in ℝ d ; i.e., for x, y ∈ ℝ d such that x = [x 1 , … , x n ] T , y = [y 1 , … , y n ] T , Then, for any mapping Φ ∶ ℝ d → H (Hilbert space), is a kernel function. From this, we can consider the inner products of the elements of ℝ d in H by using k. An example kernel is a linear kernel k(x, y) = ⟨x�y⟩ , the simplest type of kernel. There are many kinds of kernel functions, such as polynomial kernel k(x, y) which is an extension of the linear kernel, and Gaussian kernel k(x, y) = exp(− ‖x − y‖ 2 ) , ∈ ℝ is the hyper parameter. This means that the kernel best suited to solving the problem can be selected. The mapping of data in another space is called kernel trick. This mapping Φ is called feature mapping, and the SVM model is based on this trick.
We also define the n × n matrix K X for the dataset X = {x 1 , … , x n } so that (i, j) element of K X is ⟨x i �x j ⟩ . We call the matrix K X as kernel matrix over X .

Least squares support vector machine
The least squares support vector machine (LS-SVM) is a classical classification model derived from the SVM, proposed in Suykens and Vandewalle (1999). In this section, we consider an LS-SVM model for the binary classification problem. For the training data point x ∈ ℝ d , we assume that the correct answer label is determined by t ∈ {+1, −1} . In this case, the linear model can be used to estimate the label for the data point x . Here, b ∈ ℝ is the bias parameter and w = [w 1 , … , w dim H ] ∈ H (dim H is the dimension of Hilbert space H ) is the weight vector. The function ∶ ℝ d → H , the feature mapping function, is used to move the raw data into another (usually highdimensional) space, where it may become linearly separable. The sign of y(x) calculated using these values is then used as the prediction of the classification class. That is, prediction label ỹ(x) for data point x is given by In the LS-SVM problem setting, the formulation in a mathematical optimization problem is given as subject to the constraints Given y = {+1, −1} , we have holds, and we assume e i = y i − w T (x i ) + b . Solving this problem using the Lagrange multiplier method, holds by the condition that tialL � tialw = 0 for Then, prediction model (1) to be rewritten as where a 1 , … , a n ∈ ℝ and b ∈ ℝ are parameters that need to be obtained in order to perform the classification. In the LS-SVM model, the parameters are obtained by dividing the problem into multiple linear equations and solving the equations. Specifically, we solve The is a positive number (hyperparameter), and I n is the n × n identity matrix. We define the matrix F X as Then Eq.
(3) can be expressed as We can now solve the Eq. (3) by inverse matrix calculation; then follows (we can choose the hyperparameter so that F X has an inverse matrix). Doing this gives the values of the parameters a and b, and the prediction can be made using the formula (2).

Quantum support vector machine
Quantum SVM uses quantum computing and was proposed in Rebentrost et al. (2014). The basic idea is the same as that of the LS-SVM classification model. Its use of quantum computing speeds up the calculation of the inverse matrix, a computationally expensive part of the classical LS-SVM algorithm.
The whole model of quantum SVM is shown in Fig. 1. This model is composed of four registers, and qubits in the first and fourth registers are used as ancilla qubits. Here, we note that the figures of quantum circuits are drawn using Quantikz (Kay 2019) in this paper. The behavior of the quantum SVM can be summarized as follows: 1. Prepare a quantum state from the training data. The model is shown in Fig. 2. At that time, training data are pre-normalized and encoded in the third register. When the training data is Fig. 1 Outline of quantum SVM model comprising three main parts: train, test, and signed swap test (prediction). In the train part, the quantum state is calculated using training data, and training data is encoded as a quantum state for prediction. In the test part, test data is encoded as a quantum state. In the signed swap test part, measurement is repeated many times and the inner product of the states is estimated from the result of measurement

Fig. 2
Outline of the train part in existing quantum SVM model. First, applying amplitude encoding(AE), encoding training data label as amplitude in the third register, the state becomes �0⟩�0⟩�t⟩ . And then applying HHL algorithm with K X , the state becomes �1⟩�0⟩�a⟩ . 1 in the first register means success of the HHL algorithm. Lastly, by amplitude encoding in the second register, the state becomes �1⟩�x⟩�a⟩ this training data is encoded as �x⟩ = 1 After encoding, obtain parameters for prediction by using the training data encoded in the quantum state and applying the HHL algorithm (Harrow et al. 2009). This algorithm is a powerful quantum algorithm that enables the inverse matrix to be calculated more quickly than classical methods. It solves linear equations in the form A�y⟩ = �b⟩ in a quantum state, and the result is the quantum state equivalent to �y⟩ = A −1 �b⟩ . Using HHL algorithm and the quantum state corresponds to [0 t] T , the state corresponds to [b a] T is obtained as a quantum state �a⟩ (see Eq. 4). Lastly, apply amplitude encoding of training data in the second register. 2. Prepare a quantum state from the test data. The model is shown in Fig. 3. Apply amplitude encoding of test data in the second register and Hadamard gates in the third register to make a superposition state. X gate in the first register is applied to take the inner product with the state that HHL algorithm succeeded. 3. Determine the sign of the inner product between the quantum state �x⟩ corresponding to data point x of the test data and A −1 �b⟩ = �a⟩ obtained in (1). Swap test operation is performed to measure the inner product of the parameters and the new data point. The sign of the inner product is used in the classification problem with the SVM, so a variant of the swap test is used to obtain the sign of the inner product. We call this a signed swap test, the method proposed in Zhao et al. (2019).
Signed swap test is performed as follows. We assume that � 1 ⟩ and � 2 ⟩ in the following are real-valued vectors and set a goal to obtain the (signed) value of ⟨ 1 � 2 ⟩.

Prepare the state
2. Apply a Hadamard gate to the first qubit so that the state changes to .
3. Measure the first qubit. The probability of obtaining 0 from the first qubit is This means that we know that ⟨ 1 � 2 ⟩ = 2p 0 − 1 . Therefore, we can predict the value of the inner product of � 1 ⟩ and � 2 ⟩ by again measuring the first qubit and calculating the probability of obtaining 0.
The final prediction class is determined on the basis of the sign of the inner product obtained in this way. This means, for example, that we can predict that the label is +1 when the value of y(x) ≥ 0 and −1 otherwise.

Pairwise classification problem
Pairwise classification is a problem in which two data points are given as input and the problem is to determine if they satisfy a certain relationship, investigated in Oyama and Manning (2004). This formulation is used in many problem settings, such as link prediction (Yokoi et al. 2017) and chemical interaction prediction (Ben-Hur A et al. 2005). It is used, for example, to determine whether user x likes item z and whether chemical compounds x and z react chemically.
Here, we define the pairwise classification problem. Let d 1 , d 2 ∈ ℕ , X ⊂ ℝ d 1 and Z ⊂ ℝ d 2 be datasets, x ∈ X and z ∈ Z be d 1 -dimensional and d 2 -dimensional data points, and R be some relation over X × Z . We define (x, z) ∈ X × Z as a pair of data points and define the function f as In the pairwise classification problem, values of f (x, z) are given for the training datasets but not for the test datasets. The goal is, for a new data point (x,z) ∈ ℝ d 1 × ℝ d 2 , to predict the value of f (x,z) . In the training data, information about the class to which each data point belongs is not given. Instead, information is given about whether two data points satisfy a certain relationship, which requires a model suitable for pairwise classification.

Kronecker kernel
The Kronecker kernel is used to solve problems such as pairwise classification. When two pairs of data points ((x 1 , z 1 ), (x 2 , z 2 )) are extracted from the product set X × Z ( x 1 , x 2 ∈ X , z 1 , z 2 ∈ Z , (x 1 , z 1 ), (x 2 , z 2 ) ∈ X × Z ), the Kronecker kernel function k ⊗ is defined as This function satisfies the two conditions discussed in Section 2.1.1. On the basis of this representation, Kronecker kernel matrix can be expressed as f (x, z) = +1 (x and z satisfy relation R) −1 (otherwise) .
k ⊗ ((x 1 , z 1 ), (x 2 , z 2 )) = k X (x 1 , x 2 )k Z (z 1 , z 2 ). Fig. 3 Outline of the test part in existing quantum SVM model. X gate is applied for the first register to match �1⟩ in the first register of the training part. Amplitude encoding for the second register encodes test data. Hadamard gate for the third register makes superposition state to evaluate the inner product where ⊗ means the Kronecker product. The Kronecker product of matrices A and B is an r A r B × c A c B matrix defined as where A is a matrix r A × c A and B is a matrix r B × c B . A standard kernel matrix stores the inner products between the data, and the Kronecker kernel stores the inner products between data pairs. From the above definition, the inner product of Pair1(x 1 , z 1 ) and Pair2(x 2 , z 2 ) can be expressed as This expression of the inner product of data pairs intuitively tells us that, when x 1 and x 2 are similar and z 1 and z 2 are similar, then Pair1 and Pair2 can be thought similar. In later discussion, to simplify the problem, we assume that X = Z . In the general case, X ≠ Z , our model can be applied with little change. In the following part, we define the dimensions of x ∈ X and z ∈ Z is d, and the numbers of elements in X and Z is n respectively.

Computational complexity for solving pairwise classification problem with Kronecker kernel
Here, we analyze the computational complexity of the inverse calculation for a kernel matrix, an n × n semidefinite matrix. To simplify the problem, we discuss the case in which the model is used without an offset term. In classical computing, Gaussian elimination is one of the general methods used to calculate the inverse of a general regular matrix, and its complexity is O(n 3 ) . As a classical approximation method, conjugate gradient method (Hestenes and Stiefel 1952) is used, whose complexity is O(ns log(1∕ )) (Dervovic et al. 2018). Conjugate gradient method can be applied in the condition that the matrix is real symmetric and s-sparse, which means that the number of non-zero elements in the matrix is at most s. The value is called condition number and is defined as the absolute value of the ratio of the largest singular value to the smallest singular value; implies the error between the obtained values and the accurate values.
In quantum computing, we can apply the HHL algorithm, the calculation of which is the bottleneck in the quantum SVM, in O(s poly(log(s ∕ ))) time complexity (Childs et al. 2017). We thereby achieve a computational complexity of O(s poly(log(s ∕ ))) by assuming the use of quantum random access memory (QRAM) (Giovannetti et al. 2008), by which we can encode the training and test data in O(log n) time. Therefore, when the kernel matrix is sparse, especially when s = O(log n) , quantum computing can perform the inverse matrix computation exponentially faster than classical computing for n.
For the pairwise classification problem with the Kronecker kernel, the matrix of the pairwise kernels has O(n 2 ) rows and O(n 2 ) columns, which causes the large computational complexity. In this case, the computational complexity of the SVM increases is O(n 6 ) . With the conjugate gradient method, the complexity is O(n 2 s 2 2 log(1∕ )) . For the complexity of the space, if the elements of the Kronecker kernel matrix are stored explicitly, at least O(n 4 ) memory is needed. It is thus difficult to prepare memory large enough to store the Kronecker kernel matrix for a large dataset. Applying these algorithms to large datasets is thus difficult due to time and space complexities.

Proposed model
We have devised a quantum SVM model with a Kronecker kernel for solving pairwise classification problems. The outline of our model is the same as the existing model (Fig. 1), and our model also comprises three parts: train, test, and signed swap test.
First, initial state �0⟩�0 … 0⟩�0 … 0⟩�0⟩ is prepared using O(log n) qubits to store information. Next, a Hadamard gate is applied to the fourth register, and the state becomes The fourth register is used to estimate the sign of the inner product. The circuit in the training part (Fig. 4) uses three registers �0⟩�0 … 0⟩�0 … 0⟩ and here we only focus on these three registers. First, amplitude encoding of the training data label is applied and the state becomes to �0⟩�0 … 0⟩�t⟩ . Next, HHL algorithm is applied. In the phase estimation part of the HHL algorithm, controlled-e i F X⊗Z gates are applied; this calculation is done like the controlled-e i F X in the original quantum SVM model. Here, F X⊗Z is defined as By applying the HHL algorithm to the state (�0⟩�0 … 0⟩�t⟩) , the state becomes �1⟩�0 … 0⟩� ⟩ where �a⟩ = b�1⟩ + ∑ n 2 i=1 a i �i + 1⟩ . The training data is then again encoded as a quantum state so that the state is �1⟩�x, z⟩�a⟩ , here �x, z⟩ = �x⟩�z⟩ . We define this state � train ⟩ , and at this point the overall quantum state is The circuit in the test part (Fig. 5) also uses three registers �0⟩�0 … 0⟩�0 … 0⟩ . The test data are encoded as a quantum state and superposed equally. The state is then ∑ n 2 +1 i=1 �1⟩�x,z⟩�i⟩ . We define this state � test ⟩ , and at t h i s p o i n t t h e ove r a l l q u a n t u m s t a t e i s 1 √ 2 (� train ⟩�0⟩ + � test ⟩�1⟩) . After this, the inner product ⟨ train � test ⟩ is calculated. The evaluation is done using the signed swap test, described in Section 2.1.3, and finally the prediction is obtained. The complexity of the proposed model is reflected in the bottleneck, i.e., calculation of the HHL algorithm, so changing the implementation of the HHL algorithm affects the total complexity of our model. The time complexity of the fastest HHL algorithm is O(s poly(log(s ∕ ))) . Therefore, if the kernel matrix has O(n 2 ) rows and O(n 2 ) columns, the complexity of the fastest HHL algorithm is O(s 2 2 poly(log(s ∕ ))) . This is better than O(n 2 s 2 2 log(1∕ )) of the conjugate gradient method, the fastest classical matrix inversion algorithm. Especially in the case s, , 1∕ = O(poly(log n)) , when s, , 1∕ grow exponentially smaller than n, the proposed algorithm achieves exponential acceleration compared to classical algorithms (Dervovic et al. 2018). This implies the possibility of quantum advantage in time complexity for the dataset such that the kernel matrix is sparse. In this case, the time complexity of the proposed quantum model for pairwise classification is O(poly(log n)) against O(n 2 poly(log n)) of the existing classical model. It is a larger reduction than in the case of binary classification, where O(n poly(log n)) in the classical model reduced to O(poly(log n)) in the quantum model.
We use O(log n) qubits to store the training and test data, some (constant) qubits for binary expression of the eigenvalue in the HHL algorithm, and some qubits as ancilla qubits. Therefore, if only O(log n) qubits are needed for the binary expression of eigenvalue K X ⊗ K Z , the space complexity of our model is O(log n) , smaller than the O(n 4 ) of the classical methods. In terms of space complexity, our model can be applied to large datasets.

Setup
In an experiment, we performed pairwise classification using a quantum SVM with a Kronecker kernel and a classical LS-SVM with a Kronecker kernel, both on the same dataset. For a Kronecker kernel, we use two different base kernels, the linear kernel K X⊗Z (x, z) = ⟨x�z⟩ and the quadratic kernel (polynomial kernel with degree 2 and no bias term) K X⊗Z (x, z) = ⟨x�z⟩ 2 . The results were used to determine whether the quantum SVM with a Kronecker kernel has the same classification rate as the classical LS-SVM. We use Gaussian elimination for the calculation of the inverse matrix in the classical LS-SVM model.
In terms of hardware, classical and quantum methods use the same computer, WA9A-G200/WT. For the execution of quantum circuits, we use the simulator (qasm_simulator) in Qiskit, a quantum computing framework provided by IBM. Note that we did not use an actual quantum computer but rather a simulator due to the size of the circuit needed in the experiment. An actual quantum computer without error collection system would not be able to provide accurate calculation results because of its high error rate, which causes unintentional change of quantum state and measurement results. The results come probabilistically, so the prediction result is determined by the results of 8192 runs.
In the experiment, we used the basic OCR image dataset, where each example contains an image of a digit, used in a previous study (Li et al. 2015). Each image in the dataset has 128 × 128 size, and each pixel has two values 0 and 1, which corresponds to white and black. Since this dataset is too large to process the data directly on a simulator, we used the features calculated from the data as input data instead of the original image data. By feature extraction, we used two regularized values instead of raw image input. An extracted feature vector, not the raw image input, was also used for the classical model.
First, we calculated the horizontal (HR) and vertical (VR) ratios of pixels. HR is the ratio of the number of black pixels in the upper half of the image to the number of black pixels in the lower half of the image, and VR is the Fig. 4 Outline of the train part in the proposed quantum SVM model. First, encoding training data label as amplitude in the third register, the state becomes �0⟩�0⟩�t⟩ . And then applying HHL algorithm with K X⊗Z , the state becomes �1⟩�0⟩�a⟩ . 1 in the first register means success of HHL algorithm. Lastly, encoding training data as amplitude in the second register, the state becomes �1⟩�x, z⟩�a⟩ Fig. 5 Outline of the test part in the proposed existing quantum SVM model. X gate is applied for the first register to match �1⟩ in first register of training part. By amplitude encoding for second register, encoding test data in second register. Hadamard gate for third register makes superposition state to evaluate inner product ratio of the number of black pixels in the left half of the image to the number of black pixels in the right half of the image. Then, we calculate elements of the feature vector v ′ 1 and v ′ 2 by v � 1 = HR × 1.3 − 0.62 and v � 2 = VR × 0.95 − 0.42 (linear mapping). Next, v ′ 1 and v ′ 2 are scaled to v 1 and v 2 so that (v 1 ) 2 + (v 2 ) 2 = 1 holds. This regularized feature vector (v 1 , v 2 ) is used as input of training and test data. These definitions of feature vectors are after the definitions used in Li et al. (2015) and Yang et al. (2019).
We use only the images of 6 and 9. Two images (an image of 6 and an image of 9) in the training dataset were used, so four pairs comprised the training dataset. Twenty images (ten images of 6 and ten images of 9) were prepared for the test dataset, so we tested 400 pairs in total. In this experiment, we define the pairwise relationship between two digits as whether the two numbers are the same or not. For example, we assign the value +1 for the relationship between two images of 6 and the value −1 for the relationship between an image of 6 and an image of 9.
We remark that the classical model also uses the extracted feature vector, not raw image input. In the experiment, we use one classical model and three quantum models, which vary in the size of circuit, and set value of with = 2 −5 , 2 −4 , … , 2 9 , to search the relation with hyperparameter.

Implementation
Our implementation model refers to Li et al. (2015) in many parts, but has some changes, so we mainly note the differences of the models. The general circuit of our model is shown in Fig. 6, which contains four registers.
In the model, m + 4 qubits in total (m is the number of qubits used for binary encoding of eigenvalues in quantum phase estimation (QPE)). In the implementation, we cut the bias term b for the simpleness of implementation. The detail of U train is shown in Fig. 7.
In the implementation model, P( ) and Ry( ) gate is defined as and the A † gate is defined as a complex conjugate of A gate, that is, AA † = A † A = I . At first, encode the training data label to the amplitudes of the third register. After that, the state of the third register is 1 2 ∑ 3 i=0 t i �i⟩ . Then, the QPE is applied to write the eigenvalue of F X⊗Z in the second register in the form of a binary expression. Next, using the state of the second register, write the inverse of the eigenvalues to the amplitude using the Ry (rotation around the y-axis) gate. After, uncomputation of QPE is done, and lastly encode training data to qubits in the second register. In this time, we encode data, not data label.
cos 2 − sin 2 sin 2 cos 2 , In the implementation, we separate controlled-e i F X⊗Z gates into two parts, controlled-e i −1 I gates and controlled-e i K X⊗Z gates. In implementation, we use the phase gate to express controlled-e i −1 I gates. And the detail of U test is shown in Fig. 8. After applying U train and U test , the signed swap test is needed to estimate the inner product but preparing the quantum state done in HHL algorithm, breaks the superposition. However, in reality, in this problem setting, the evaluation of the inner product can be done from the measurement results similarly to the case that superposition 1 √ 2 (�0⟩� train ⟩ + �1⟩� test ⟩) can be gained (Appendix 1). The quadratic kernel is implemented by replacing �x⟩ with �x⟩�x⟩ , and �z⟩ with �z⟩�z⟩ in the linear kernel. We have conducted experiments with the quadratic kernel only for m = 4 and 6 because at least 4 qubits are needed to encode data for the quadratic kernel.

Results
Results are shown in Figs. 9 and 10. For the proposed model, the experimental results show that the accuracy is sensitive to the value of . In the case of = 1 the proposed model achieves an accuracy of 1.0 for all m values. On the other hand, if the value of is small or large, the accuracy of the proposed model decreases, while the accuracy of the classical model remains high. When using the quadratic kernel, the accuracy of the proposed model becomes stable. In particular, the accuracy for small and large values of is significantly improved. For the classical model, the accuracy is not sensitive to when using either the linear kernel or the quadratic kernel. For the classical model, accuracy is 1.0 in all cases, that means the classical model achieves perfect classification in this dataset. In addition, accuracy in the classical model Fig. 6 Outline of implementation of our proposed model. In our experiment, the second register has m qubits, and the third register has 2 qubits. First applying Hadamard gate to the fourth register to make super position. Then, unitary circuits U train and U test are applied controlled by the state of the fourth register. After, X gate is applied to the qubit in the first register for the evaluation of the inner product. Lastly, the Hadamard gate is applied to the fourth register again and measure the state of the first and fourth registers does not change by the value of , which differs from the tendency of the proposed quantum model. We suppose this phenomenon is caused by the limitations on the representation of the eigenvalues in quantum SVM. Eigenvalues are precisely calculated in the classical model, but not necessarily in quantum SVM. In quantum phase estimation subroutine in quantum SVM, all eigenvalues of the kernel matrix, which is Hermitian matrix, are assumed to be included in the range [0, 1) to be calculated precisely. In fact, when the value of is too small, the eigenvalues of K X⊗Z + −1 I become too large (close to −1 ) that exceed the range [0, 1), which causes inaccurate results of calculation. When the value of is too large, the eigenvalues of K X⊗Z + −1 I are close to that of K X⊗Z , which are approximately (0.561, 0.188, 0.188, 0.063). In quantum SVM, the eigenvalues of K X⊗Z ∕2 m are binary encoded using m qubits, for example, 0.625 is expressed as Fig. 7 Outline of train part implementation of our proposed model. Encoding training data in the beginning, and applying HHL algorithm, then encodes training data in the second register. In the part of encoding training data, encode training data based on the index of the third register. We remark that measurement operation is not applied in the train part to avoid collapse of super position for the signed swap test 1 3

22
Page 10 of 13 0.1010 when m = 4 . This expression causes cancellation of significant digits because the eigenvalues are expressed in 1∕2 m increments, against that max eigenvalue of K X⊗Z ∕2 m is about 0.561∕2 m . These explanation gives the reason why the accuracy is insensitive to in classical SVM, but sensitive in quantum SVM. And execution time per datum can be seen propotional to hyper-parameter m, and it seems natural because the depth of quantum circuit in proposed model increases propotional to hyper-parameter m. And execution time does not vary by the value of , and execution time of the classical model is more than thousand times faster than the proposed model executed using the quantum simulator. We suppose that the advantage of the quantum method will be kept theoretically. The main purpose of the experiment with small data and the quantum simulator is to confirm implementability. The advantage of the quantum method will

Discussion
We investigated the theoretical speedup of pairwise learning obtained using the Kronecker kernel and showed that the accuracy of a model with a Kronecker kernel can approach that of the classical one. However, it is necessary to investigate whether an actual quantum device has performance comparable to that of conventional devices. From the results and findings gotten through this study, we present some discussion related to performance of quantum machine learning.
One such discussion is about kernel expression. Although making controlled-e i F X⊗Z gates is difficult in general, there is an algorithm which approximates such gate, known as density matrix exponentiation, used in Lloyd et al. (2014). However, applying this algorithm to our model seems difficult because density matrix exponentiation needs to calculate trace many times and then the superposition collapses by measurement. One way to solve this problem is using an algorithm which makes quantum state 1 √ 2 � 1 ⟩� 2 ⟩ from the quantum state � 1 ⟩� 2 ⟩ , and using this algorithm, we can make the state 1 √ 2 � train ⟩� test ⟩ from the state � train ⟩� test ⟩ , which can be prepared easily. However, such algorithm has not been found as far as we investigated. Therefore, finding such algorithm (or prove that such algorithm cannot be made) helps and improves our understanding for quantum machine learning. We should also focus on the complexity of adding the bias term b to the learning model. The matrix F X⊗Z is (n 2 + 1) × (n 2 + 1) matrix, and preparing such matrix as quantum state (in the form of density matrix) is complicated compared to the case without a bias term. Finding an effective implementation to prepare such a matrix will improve usability of the quantum SVM model.
And we should think about the performance of other kinds of pairwise kernel, such as the Cartesian kernel proposed in Kashima et al. (2010). Identifying which type of models benefit from quantum computation is very important as a step to develop quantum machine learning. We assumed that the Kronecker product can be computed faster in quantum computing, but more detailed research is needed on what kind of machine learning models and problems to which this approach can be applied. In addition, the size of the problems that can be handled by quantum computers is currently quite limited, so evaluating learning performance experimentally requires defining appropriate problems.

Conclusion
We present a model for applying a quantum support vector machine with a Kronecker kernel to pairwise classification. We theoretically demonstrated that the proposed model is faster and more scalable than the conventional models. Especially in the case that the kernel matrix is guaranteed to be very sparse, the proposed model can exponentially faster than the existing models. Under the specific condition, our model works in O(poly(log n)) for the size of training data n, while the existing classical model works in O(n 2 poly(log n)) . This reduction has a larger impact than the reduction from O(n poly(log n)) to O(poly(log n)) by the standard quantum SVM. In addition, we experimentally demonstrated that the accuracy of a model with a Kronecker kernel can approach that of the classical one. As for space complexity, the proposed model requires a very small amount of space compared to the existing models. This connection of pairwise learning with quantum machine learning is the first step towards developing a quantum pairwise learning domain.

Appendix: Calculation of inner product
Here, we prove that the inner product of quantum states can be predicted using our implement model.

Proof
After applying X gate to the first register, the state can be written as Under the condition that a 00 , a 10 are real number and� train ⟩, � test ⟩ are real number vectors (in the experiment setting, these constraints are guaranteed). Therefore, p 10 , p 11 are easily obtained from the calculation, so the inner product can be calculated.

Conflict of interest The authors declare no competing interests.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/. = 2p 10 − � p 10 + p 11 � � 2(p 10 + p 11 − 1 2 ) = p 10 − p 11 √ 2(p 10 + p 11 ) − 1