squlearn.kernel.loss.negative_log_likelihood.NLL

class squlearn.kernel.loss.negative_log_likelihood.NLL(sigma=0.0)

Negative log likelihood loss function. This class can be used to compute the negative log likelihood loss function for a given quantum kernel \(K_{\theta}\) with variational parameters \(\theta\). The definition of the function is taken from Equation 5.8 Chapter 5.4 of Ref. [1].

The log-likelihood function is defined as:

\[L(\theta) = -\frac{1}{2} log(|K_{\theta} + \sigmaI|)-\frac{1}{2} y^{T}(K_{\theta} + \sigmaI)^{-1}y-\frac{n}{2} log(2\pi)\]
Parameters:

sigma – (float), default=0.0: Hyperparameter for the regularization strength.

References

[1]: Carl E. Rasmussen and Christopher K.I. Williams, “Gaussian Processes for Machine Learning”, MIT Press 2006

Methods:

compute(parameter_values: ndarray, data: ndarray, labels: ndarray) float

Compute the negative log likelihood loss function.

Parameters:
  • parameter_values (np.ndarray) – The parameter values for the variational quantum kernel parameters.

  • data (np.ndarray) – The training data to be used for the kernel matrix.

  • labels (np.ndarray) – The training labels.

Returns:

The negative log likelihood loss value.

Return type:

float

set_quantum_kernel(quantum_kernel: KernelMatrixBase) None

Set the quantum kernel matrix to be used in the loss.

Parameters:

quantum_kernel (KernelMatrixBase) – The quantum kernel matrix to be used in the loss.