BaseKernel#

class BaseKernel(*, feature_map=None, enforce_psd=True)[ソース]#

ベースクラス: ABC

An abstract definition of the quantum kernel interface.

The general task of machine learning is to find and study patterns in data. For many algorithms, the datapoints are better understood in a higher dimensional feature space, through the use of a kernel function:

\[K(x, y) = \langle f(x), f(y)\rangle.\]

Here K is the kernel function, x, y are n dimensional inputs. f is a map from n-dimension to m-dimension space. \(\langle x, y \rangle\) denotes the dot product. Usually m is much larger than n.

The quantum kernel algorithm calculates a kernel matrix, given datapoints x and y and feature map f, all of n dimension. This kernel matrix can then be used in classical machine learning algorithms such as support vector classification, spectral clustering or ridge regression.

パラメータ:
  • feature_map (QuantumCircuit) – Parameterized circuit to be used as the feature map. If None is given, ZZFeatureMap is used with two qubits. If there’s a mismatch in the number of qubits of the feature map and the number of features in the dataset, then the kernel will try to adjust the feature map to reflect the number of features.

  • enforce_psd (bool) – Project to closest positive semidefinite matrix if x = y. Default True.

Attributes

enforce_psd#

Returns True if the kernel matrix is required to project to the closest positive semidefinite matrix.

feature_map#

Returns the feature map of this kernel.

num_features#

Returns the number of features in this kernel.

Methods

abstract evaluate(x_vec, y_vec=None)[ソース]#

Construct kernel matrix for given data.

If y_vec is None, self inner product is calculated.

パラメータ:
  • x_vec (ndarray) – 1D or 2D array of datapoints, NxD, where N is the number of datapoints, D is the feature dimension

  • y_vec (ndarray | None) – 1D or 2D array of datapoints, MxD, where M is the number of datapoints, D is the feature dimension

戻り値:

2D matrix, NxM

戻り値の型:

ndarray