SVRLoss¶
- class SVRLoss(**kwargs)[source]¶
Bases:
KernelLossThis class provides a kernel loss function for regression tasks by fitting an
SVRmodel from scikit-learn. Given training samples, \(x_{i}\), with labels, \(y_{i}\), and a kernel, \(K_{θ}\), parameterized by values, \(θ\), the loss is defined as:\[SVRLoss = -0.5 \sum_{i,j} \beta_i \beta_j K_θ(x_i, x_j) - \epsilon \sum_{i} |\beta_i| + \sum_{i} y_i \beta_i\]where \(\beta_i = \alpha_i - \alpha_i^*\) are the optimal Lagrange multipliers found by solving the standard SVR quadratic program. Note that the hyper-parameters
Candepsiloncan be specified through the keyword args.Minimizing this loss over the parameters, \(θ\), of the kernel is equivalent to minimizing the optimized dual objective of the SVR, which is a proxy for the primal objective (a combination of the model complexity and the training error).
See https://arxiv.org/abs/2105.03406 for further details on kernel training (though it focuses on classification, the principle applies to regression).
- Parameters:
**kwargs – Arbitrary keyword arguments to pass to SVR constructor within SVRLoss 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.
- Parameters:
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 datalabels (ndarray) – A length-N array containing the truth labels
- Returns:
A loss value
- Return type: