leaspy.models.generic
Classes
Generic model (temporary until |
Module Contents
- class GenericModel(name, **kwargs)
Bases:
leaspy.models.base.BaseModelGeneric model (temporary until
AbstractModelis really abstract).TODO: change naming after AbstractModel was renamed?
- Parameters:
- name
str The name of the model.
- **kwargs
Hyperparameters of the model.
- name
- Attributes:
- Parameters:
name (str)
- parameters: leaspy.utils.typing.KwargsType
- get_hyperparameters(*, with_features=True, with_properties=True, default=None)
Get all model hyperparameters.
- Parameters:
- with_features, with_properties
bool(defaultTrue) Whether to include features and respectively all _properties (i.e. _dynamic_ hyperparameters) in the returned dictionary.
- defaultAny
Default value is something is an hyperparameter is missing (should not!).
- with_features, with_properties
- Returns:
- :obj:`dict` { hyperparam_name
str-> hyperparam_valueAny }
- :obj:`dict` { hyperparam_name
- Return type:
leaspy.utils.typing.KwargsType
- load_parameters(parameters, *, list_converter=np.array)
Instantiate or update the model’s parameters.
- Parameters:
- parameters
dict Contains the model’s parameters.
- list_convertercallable
The function to convert list objects.
- parameters
- Return type:
None
- load_hyperparameters(hyperparameters, *, with_defaults=False)
Load model hyperparameters from a
dict.- Parameters:
- Raises:
LeaspyModelInputErrorIf inconsistent hyperparameters.
- Parameters:
hyperparameters (leaspy.utils.typing.KwargsType)
with_defaults (bool)
- Return type:
None
- save(path, **kwargs)
Save
Leaspyobject as JSON model parameter file.Default save method: it can be overwritten in child class but should be generic…
- abstractmethod compute_individual_trajectory(timepoints, individual_parameters)
Compute scores values at the given time-point(s) given a subject’s individual parameters.
- Parameters:
- timepointsscalar or array_like[scalar] (
list,tuple,numpy.ndarray) Contains the age(s) of the subject.
- individual_parameters
dict[str, Any] Contains the individual parameters. Each individual parameter should be a scalar or array_like.
- timepointsscalar or array_like[scalar] (
- Returns:
torch.TensorContains the subject’s scores computed at the given age(s). The shape of the tensor is
(1, n_tpts, n_features).
- Parameters:
individual_parameters (dict)
- Return type: