ParametricModel#
- class relife.base.ParametricModel(*params)[source]#
Base class for ReLife models with parameters.
The class stores parameters in a tree structure, exposes them as a flat vector with
get_paramsandset_params, and tracks fitting results.Examples
>>> class ModelA(ParametricModel): ... def __init__(self, a, b): ... super().__init__(a, b) >>> class ModelB(ParametricModel): ... def __init__(self, baseline : ModelA): ... super().__init__() ... self.baseline = baseline >>> model_a = ModelA(1, 2) >>> model_b = ModelB(model_a) >>> model_b.get_params() array([1, 2])
Methods
Get the parameters of this model.
Whether fitting results are set.
Whether at least one parameter value is set.
Set the parameters of this model.
- get_params()[source]#
Get the parameters of this model.
- Returns:
- out1darray of floats
Model parameters.
Notes
If parameter values are not set, they default to
np.nanvalues.
- set_params(new_params)[source]#
Set the parameters of this model.
- Parameters:
- new_params1d array-like of floats
Model parameters.
Notes
set_paramsdefinition expects an array-like of floats. At runtime, complex parameters might be setted temporarily to approximate fitted parameters covariance. This is contradictory to the given typing. At the moment, we don’t see a better solution and we believe that this is actually a limitation of what can be expressed in the static typesystem.