leaspy.models.time_reparametrized¶
Classes¶
Contains the common attributes & methods of the multivariate time-reparametrized models. |
Module Contents¶
- class TimeReparametrizedModel(name, source_dimension=None, **kwargs)[source]¶
Bases:
leaspy.models.mcmc_saem_compatible.McmcSaemCompatibleModelContains the common attributes & methods of the multivariate time-reparametrized models.
- Parameters:
- Raises:
LeaspyModelInputErrorIf inconsistent hyperparameters.
- Parameters:
- static time_reparametrization(*, t, alpha, tau)[source]¶
Tensorized time reparametrization formula.
Warning
Shapes of tensors must be compatible between them.
- Parameters:
- t
torch.Tensor Timepoints to reparametrize
- alpha
torch.Tensor Acceleration factors of individual(s)
- tau
torch.Tensor Time-shift(s) of individual(s)
- t
- Returns:
torch.TensorReparametrized time of same shape as timepoints
- Parameters:
- Return type:
- get_variables_specs()[source]¶
Return the specifications of the variables (latent variables, derived variables, model ‘parameters’) that are part of the model.
- Returns:
- NamedVariables
A dictionary-like object containing specifications for the variables
- Return type:
- put_individual_parameters(state, dataset)[source]¶
Initialize individual latent parameters in the given state if not already set.
- to_dict(*, with_mixing_matrix=True)[source]¶
Export model object as dictionary ready for JSON saving.
- Parameters:
- with_mixing_matrix
bool(defaultTrue) Save the mixing matrix in the exported file in its ‘parameters’ section.
Warning
It is not a real parameter and its value will be overwritten at model loading (orthonormal basis is recomputed from other “true” parameters and mixing matrix is then deduced from this orthonormal basis and the betas)! It was integrated historically because it is used for convenience in browser webtool and only there…
- with_mixing_matrix
- Returns:
- KwargsType
The object as a dictionary.
- Parameters:
with_mixing_matrix (bool)
- Return type:
- abstractmethod compute_individual_ages_from_biomarker_values(value, individual_parameters, feature=None)[source]¶
For one individual, compute age(s) at which the given features values are reached (given the subject’s individual parameters).
Consistency checks are done in the main API layer.
- Parameters:
- valuescalar or array_like[scalar] (
list,tuple,numpy.ndarray) Contains the biomarker value(s) of the subject.
- individual_parameters
dict Contains the individual parameters. Each individual parameter should be a scalar or array_like.
- feature
str(or None) Name of the considered biomarker.
Note
Optional for
UnivariateModel, compulsory forMultivariateModel.
- valuescalar or array_like[scalar] (
- Returns:
torch.TensorContains the subject’s ages computed at the given values(s). Shape of tensor is
(1, n_values).
- Raises:
LeaspyModelInputErrorIf computation is tried on more than 1 individual.
- Parameters:
individual_parameters (DictParams)
feature (Optional[FeatureType])
- Return type:
- abstractmethod compute_individual_ages_from_biomarker_values_tensorized(value, individual_parameters, feature)[source]¶
For one individual, compute age(s) at which the given features values are reached (given the subject’s individual parameters), with tensorized inputs.
- Parameters:
- value
torch.Tensorof shape(1, n_values) Contains the biomarker value(s) of the subject.
- individual_parametersDictParamsTorch
Contains the individual parameters. Each individual parameter should be a
torch.Tensor.- feature
str(or None) Name of the considered biomarker.
Note
Optional for
UnivariateModel, compulsory forMultivariateModel.
- value
- Returns:
torch.TensorContains the subject’s ages computed at the given values(s). Shape of tensor is
(n_values, 1).
- Parameters:
value (Tensor)
individual_parameters (DictParamsTorch)
feature (Optional[FeatureType])
- Return type: