Module risk

operalib.risk implements risk model and their gradients.

class operalib.risk.ORFFHingeLoss[source]

Define Hinge loss for ORFF models and its gradient.

Methods

__call__(coefs, ground_truth, phix, ker) Compute the hinge loss value for ORFF models.
functional_grad  
functional_grad_val  
__call__(coefs, ground_truth, phix, ker)[source]

Compute the hinge loss value for ORFF models.

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

phix : {LinearOperator}

X ORFF mapping operator acting on the coefs

Returns:
float : Empirical ORFF hinge loss
__init__()[source]

Initialize Hhnge ORFF loss.

__weakref__

list of weak references to the object (if defined)

class operalib.risk.ORFFLSLoss[source]

Define Least squares loss for ORFF models and its gradient.

Methods

__call__(coefs, ground_truth, phix, ker) Compute the Least squares loss value for ORFF models.
functional_grad(coefs, ground_truth, phix, ker) Compute the Least squares loss gradient for ORFF models.
functional_grad_val(coefs, ground_truth, …) Compute the Least squares loss gradient and value for ORFF models.
__call__(coefs, ground_truth, phix, ker)[source]

Compute the Least squares loss value for ORFF models.

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

phix : {LinearOperator}

X ORFF mapping operator acting on the coefs

Returns:
float : Empirical ORFF least square loss
__init__()[source]

Initialize Least squares ORFF loss.

__weakref__

list of weak references to the object (if defined)

functional_grad(coefs, ground_truth, phix, ker)[source]

Compute the Least squares loss gradient for ORFF models.

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

phix : {LinearOperator}

X ORFF mapping operator acting on the coefs

Returns:
float : Empirical ORFF least square loss gradient
functional_grad_val(coefs, ground_truth, phix, ker)[source]

Compute the Least squares loss gradient and value for ORFF models.

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

phix : {LinearOperator}

X ORFF mapping operator acting on the coefs

Returns:
tuple : Empirical ORFF least square loss value and gradient
class operalib.risk.ORFFRidgeRisk(lbda, loss='LS')[source]

Define Ridge risk for ORFF models and its gradient.

Methods

__call__(coefs, ground_truth, phix, ker) Compute the Empirical ORFF ridge risk.
functional_grad(coefs, ground_truth, phix, ker) Compute the gradient of the Empirical ORFF ridge risk.
functional_grad_val(coefs, ground_truth, …) Compute the gradient and value of the Empirical ORFF ridge risk.
__call__(coefs, ground_truth, phix, ker)[source]

Compute the Empirical ORFF ridge risk.

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

phix : {LinearOperator}

X ORFF mapping operator acting on the coefs

Returns:
float : Empirical ORFF ridge risk
__init__(lbda, loss='LS')[source]

Initialize Empirical ORFF 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(coefs, ground_truth, phix, ker)[source]

Compute the gradient of the Empirical ORFF ridge risk.

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

phix : {LinearOperator}

X ORFF mapping operator acting on the coefs

Returns:
{vector-like} : gradient of the Empirical ORFF ridge risk
functional_grad_val(coefs, ground_truth, phix, ker)[source]

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

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

phix : {LinearOperator}

X ORFF mapping operator acting on the coefs

Returns:
Tuple{float, vector-like} : Empirical ORFF ridge risk and its gradient
returned as a tuple.
class operalib.risk.ORFFSCSVMLoss[source]

Define the Simplex Cone Support Vector Machine loss and its gradient.

Methods

__call__  
functional_grad  
functional_grad_val  
__call__(...) <==> x(...)[source]
__init__()[source]

x.__init__(…) initializes x; see help(type(x)) for signature

__weakref__

list of weak references to the object (if defined)

class operalib.risk.OVKRidgeRisk(lbda)[source]

Define Kernel ridge risk and its gradient.

Methods

__call__(coefs, ground_truth, Gram[, …]) Compute the Empirical OVK ridge risk.
functional_grad(coefs, ground_truth, Gram[, …]) Compute the gradient of the Empirical OVK ridge risk.
functional_grad_val(coefs, ground_truth, Gram) Compute the gradient and value of the Empirical OVK ridge risk.
__call__(coefs, ground_truth, Gram, weight=None, zeronan=None)[source]

Compute the Empirical OVK ridge risk.

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

Gram : {LinearOperator}

Gram matrix acting on the coefs

weight: {LinearOperator}
zeronan: {LinearOperator}
Returns:
float : Empirical OVK ridge risk
__init__(lbda)[source]

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(coefs, ground_truth, Gram, weight=None, zeronan=None)[source]

Compute the gradient of the Empirical OVK ridge risk.

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

Gram : {LinearOperator}

Gram matrix acting on the coefs

weight: {LinearOperator}
zeronan: {LinearOperator}
Returns:
{vector-like} : gradient of the Empirical OVK ridge risk
functional_grad_val(coefs, ground_truth, Gram, weight=None, zeronan=None)[source]

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

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

Coefficient to optimise

ground_truth : {vector-like}

Targets samples

Gram : {LinearOperator}

Gram matrix acting on the coefs

L : array, shape = [n_samples_miss, n_samples_miss]

Graph Laplacian of data with missing targets (semi-supervised learning).

Returns:
Tuple{float, vector-like} : Empirical OVK ridge risk and its gradient
returned as a tuple.