SVCLoss#

class SVCLoss(**kwargs)[kaynak]#

Bases: KernelLoss

This class provides a kernel loss function for classification tasks by fitting an SVC model from scikit-learn. Given training samples, \(x_{i}\), with binary labels, \(y_{i}\), and a kernel, \(K_{θ}\), parameterized by values, \(θ\), the loss is defined as:

\[SVCLoss = \sum_{i} a_i - 0.5 \sum_{i,j} a_i a_j y_{i} y_{j} K_θ(x_i, x_j)\]

where \(a_i\) are the optimal Lagrange multipliers found by solving the standard SVM quadratic program. Note that the hyper-parameter C for the soft-margin penalty can be specified through the keyword args.

Minimizing this loss over the parameters, \(θ\), of the kernel is equivalent to maximizing a weighted kernel alignment, which in turn yields the smallest upper bound to the SVM generalization error for a given parameterization.

See https://arxiv.org/abs/2105.03406 for further details.

Parametreler:

**kwargs – Arbitrary keyword arguments to pass to SVC constructor within SVCLoss evaluation.

Methods

evaluate(parameter_values, quantum_kernel, data, labels)[kaynak]#

An abstract method for evaluating the loss of a kernel function on a labeled dataset.

Parametreler:
  • parameter_values (Sequence[float]) – An array of values to assign to the user params

  • quantum_kernel (TrainableKernel) – A trainable quantum kernel object to evaluate

  • data (ndarray) – An (N, M) matrix containing the data N = # samples, M = dimension of data

  • labels (ndarray) – A length-N array containing the truth labels

Dönüşler:

A loss value

Dönüş türü:

float