nemos.regularizer.Regularizer#
- class nemos.regularizer.Regularizer(**kwargs)[source]#
Bases:
Base
,ABC
Abstract base class for regularized solvers.
This class is designed to provide a consistent interface for optimization solvers, enabling users to easily switch between different regularizers, ensuring compatibility with various loss functions and optimization algorithms.
- allowed_solvers#
Tuple of solver names that are allowed for use with this regularizer.
- default_solver#
String of the default solver name allowed for use with this regularizer.
Attributes
Methods
__init__
(**kwargs)get_params
([deep])From scikit-learn, get parameters by inspecting init.
Abstract method to retrieve the proximal operator for this solver.
penalized_loss
(loss, regularizer_strength)Abstract method to penalize loss functions.
set_params
(**params)Set the parameters of this estimator.
- property allowed_solvers: Tuple[str]#
- property default_solver: str#
- get_params(deep=True)#
From scikit-learn, get parameters by inspecting init.
- Parameters:
deep
- Return type:
dict
- Returns:
- out:
A dictionary containing the parameters. Key is the parameter name, value is the parameter value.
- abstract get_proximal_operator()[source]#
Abstract method to retrieve the proximal operator for this solver.
- Return type:
Callable
[[Any
,float
,float
],Tuple
[Array
,Array
]]- Returns:
The proximal operator, which typically applies a form of regularization.
- abstract penalized_loss(loss, regularizer_strength)[source]#
Abstract method to penalize loss functions.
- Parameters:
loss (
Callable
) – Callable loss function.regularizer_strength (
float
) – Float the indicates the regularization strength.
- Return type:
Callable
- Returns:
A modified version of the loss function including any relevant penalization based on the regularizer type.
- 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 (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance