Module risk

operalib.risk implements risk model and their gradients.

class operalib.risk.KernelRidgeRisk(lbda)

Define Kernel ridge risk and its gradient.

Methods

__call__(dual_coefs, ground_truth, Gram) Compute the Empirical OVK ridge risk.
functional_grad(dual_coefs, ground_truth, Gram) Compute the gradient of the Empirical OVK ridge risk.
functional_grad_val(dual_coefs, ...) Compute the gradient and value of the Empirical OVK ridge risk.
__call__(dual_coefs, ground_truth, Gram)

Compute the Empirical OVK ridge risk.

Parameters:

dual_coefs : {vector-like}, shape = [n_samples1 * n_targets]

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

Gram : {LinearOperator}

Gram matrix acting on the dual_coefs

Returns:

float : Empirical OVK ridge risk

__init__(lbda)

Initialize Empirical kernel ridge risk.

Parameters:

lbda : {float}

Small positive values of lbda improve the conditioning of the problem and reduce the variance of the estimates. Lbda corresponds to (2*C)^-1 in other linear models such as LogisticRegression or LinearSVC.

__weakref__

list of weak references to the object (if defined)

functional_grad(dual_coefs, ground_truth, Gram)

Compute the gradient of the Empirical OVK ridge risk.

Parameters:

dual_coefs : {vector-like}, shape = [n_samples1 * n_targets]

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

Gram : {LinearOperator}

Gram matrix acting on the dual_coefs

Returns:

{vector-like} : gradient of the Empirical OVK ridge risk

functional_grad_val(dual_coefs, ground_truth, Gram)

Compute the gradient and value of the Empirical OVK ridge risk.

Parameters:

dual_coefs : {vector-like}, shape = [n_samples1 * n_targets]

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

Gram : {LinearOperator}

Gram matrix acting on the dual_coefs

Returns:

Tuple{float, vector-like} : Empirical OVK ridge risk and its gradient

returned as a tuple.