ParametricModel#
- class relife.model.ParametricModel[source]#
Base class to create a parametric model.
Any parametric model must inherit from ParametricModel.
Methods
Compose with new
ParametricModel
instance(s).Copy current instance.
Change local parameters structure.
Attributes
Number of parameters.
Parameters values.
Parameters names.
- compose_with(**kwcomponents)[source]#
Compose with new
ParametricModel
instance(s).This method must be seen as standard function composition exept that objects are not functions but group of functions (as object encapsulates functions). When you compose your
ParametricModel
instance with new one(s), the followings happen :each new parameters are added to the current
Parameters
instanceeach new ParametricModel instance is accessible as a standard attribute
Like so, you can request new ParametricModel components in current ParametricModel instance while setting and getting all parameters. This is usefull when ParametricModel can be seen as a nested function (see Regression).
- Parameters:
- **kwcomponentsvariadic named
ParametricModel
instance Instance names (keys) are followed by the instances themself (values).
- **kwcomponentsvariadic named
Notes
If one wants to pass a dict of key-value, make sure to unpack the dict with ** operator or you will get a nasty TypeError.
- property nb_params#
Number of parameters.
- Returns:
- int
Number of parameters.
- new_params(**kwparams)[source]#
Change local parameters structure.
This method only affects local parameters. ParametricModel components are not affected. This is usefull when one wants to change model parameters for any reason. For instance Regression models use new_params to change number of regression coefficients depending on the number of covariates that are passed to the fit method.
- Parameters:
- **kwparamsvariadic named floats corresponding to new parameters
Float names (keys) are followed by float instances (values).
Notes
If one wants to pass a dict of key-value, make sure to unpack the dict with ** operator or you will get a nasty TypeError.
- property params#
Parameters values.
- Returns:
- ndarray
Parameters values of the model
Notes
If parameter values are not set, they are encoded as np.nan value.
Parameters can be by manually setting`params` through its setter, fitting the model if fit exists or by specifying all parameters values when the model object is initialized.
- property params_names#
Parameters names.
- Returns:
- list of str
Parameters names
Notes
Parameters values can be requested (a.k.a. get) by their name at instance level.