leaspy.models.time_reparametrized
Classes
Contains the common attributes & methods of the multivariate models. |
Module Contents
- class TimeReparametrizedModel(name, source_dimension=None, **kwargs)
Bases:
leaspy.models.mcmc_saem_compatible.McmcSaemCompatibleModelContains the common attributes & methods of the multivariate models.
- Parameters:
- name
str Name of the model.
- **kwargs
Hyperparameters for the model (including obs_models).
- name
- Raises:
LeaspyModelInputErrorIf inconsistent hyperparameters.
- Parameters:
- static time_reparametrization(*, t, alpha, tau)
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).
- t
- Returns:
torch.Tensorof same shape as timepoints
- Parameters:
- Return type:
leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float]
- get_variables_specs()
Return the specifications of the variables (latent variables, derived variables, model ‘parameters’) that are part of the model.
- Returns:
- NamedVariables
The specifications of the model’s variables.
- Return type:
- to_dict(*, with_mixing_matrix=True)
Export
Leaspyobject 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:
leaspy.utils.typing.KwargsType
- abstractmethod compute_individual_ages_from_biomarker_values(value, individual_parameters, feature=None)
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:
- Return type:
- abstractmethod compute_individual_ages_from_biomarker_values_tensorized(value, individual_parameters, feature)
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 (leaspy.utils.typing.DictParamsTorch)
feature (Optional[leaspy.utils.typing.FeatureType])
- Return type: