QSVM.construct_kernel_matrix

QSVM.construct_kernel_matrix(x1_vec, x2_vec=None, quantum_instance=None)[source]

Construct kernel matrix, if x2_vec is None, self-innerproduct is conducted.

Notes

When using statevector_simulator, we only build the circuits for Psi(x1)|0> rather than Psi(x2)^dagger Psi(x1)|0>, and then we perform the inner product classically. That is, for statevector_simulator, the total number of circuits will be O(N) rather than O(N^2) for qasm_simulator.

Parameters
  • x1_vec (numpy.ndarray) – data points, 2-D array, N1xD, where N1 is the number of data, D is the feature dimension

  • x2_vec (numpy.ndarray) – data points, 2-D array, N2xD, where N2 is the number of data, D is the feature dimension

  • quantum_instance (QuantumInstance) – quantum backend with all settings

Returns

2-D matrix, N1xN2

Return type

numpy.ndarray

Raises

AquaError – Quantum instance is not present.