SVCLoss#
- class SVCLoss(**kwargs)[source]#
Bases :
KernelLoss
This class provides a kernel loss function for classification tasks by fitting an
SVC
model from scikit-learn. Given training samples, , with binary labels, , and a kernel, , parameterized by values, , the loss is defined as:where
are the optimal Lagrange multipliers found by solving the standard SVM quadratic program. Note that the hyper-parameterC
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.
- Paramètres:
**kwargs – Arbitrary keyword arguments to pass to SVC constructor within SVCLoss evaluation.
Methods
- evaluate(parameter_values, quantum_kernel, data, labels)[source]#
An abstract method for evaluating the loss of a kernel function on a labeled dataset.
- Paramètres:
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 dataN = # samples, M = dimension of data
labels (ndarray) – A length-N array containing the truth labels
- Renvoie:
A loss value
- Type renvoyé: