nemos.regularizer.Ridge#

class nemos.regularizer.Ridge[source]#

Bases: Regularizer

Regularizer class for Ridge (L2 regularization).

This class equips models with the Ridge proximal operator and the Ridge penalized loss function.

Attributes

__init__()#

Methods

__init__()

allow_solver(algo_name)

Add an algorithm to the list of compatible solvers.

check_solver(solver_name)

Raise an error if the given solver is not allowed.

get_params([deep])

From scikit-learn, get parameters by inspecting init.

get_proximal_operator(params, strength)

Retrieve the proximal operator.

penalized_loss(loss, params, strength)

Return a function for calculating the penalized loss.

set_params(**params)

Set the parameters of this estimator.

classmethod __init_subclass__(**kwargs)#

Set the set_{method}_request methods.

This uses PEP-487 [1] to set the set_{method}_request methods. It looks for the information available in the set default values which are set using __metadata_request__* class attributes, or inferred from method signatures.

The __metadata_request__* class attributes are used when a method does not explicitly accept a metadata through its arguments or if the developer would like to specify a request value for those metadata which are different from the default None.

References

classmethod allow_solver(algo_name)#

Add an algorithm to the list of compatible solvers.

Parameters:

algo_name (str) – Name of the optimization algorithm to add.

Return type:

None

property allowed_solvers: Tuple[str]#
check_solver(solver_name)#

Raise an error if the given solver is not allowed.

Return type:

None

Parameters:

solver_name (str)

property default_solver: str#
get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

get_params(deep=True)#

From scikit-learn, get parameters by inspecting init.

Parameters:

deep – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Return type:

dict

Returns:

A dictionary containing the parameters. Key is the parameter name, value is the parameter value.

get_proximal_operator(params, strength)#

Retrieve the proximal operator.

Parameters:
  • params (Any) – The parameters to be regularized.

  • strength (Any)

Return type:

Callable[[Any, float, float], Tuple[Array, Array]]

Returns:

The proximal operator, applying regularization to the provided parameters.

penalized_loss(loss, params, strength)#

Return a function for calculating the penalized loss.

Return type:

Callable

Parameters:
set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (Any) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance