leaspy.models.constant

Classes

ConstantModel

ConstantModel` is a benchmark model that predicts constant values (no matter what the patient's ages are).

Module Contents

class ConstantModel(name, **kwargs)[source]

Bases: leaspy.models.stateless.StatelessModel

ConstantModel` is a benchmark model that predicts constant values (no matter what the patient’s ages are).

These constant values depend on the algorithm setting and the patient’s values provided during calibration.

It could predict:
  • last: last value seen during calibration (even if NaN).

  • last_known: last non NaN value seen during calibration.

  • max: maximum (=worst) value seen during calibration.

  • mean: average of values seen during calibration.

Warning

Depending on features, the last_known / max value may correspond to different visits.

Warning

For a given feature, value will be NaN if and only if all values for this feature were NaN.

Parameters:
namestr

The model’s name.

Parameters:

name (str)

property hyperparameters: DictParamsTorch

Dictionary of values for model hyperparameters.

Returns:
DictParamsTorch

Dictionary of hyperparameters.

Return type:

DictParamsTorch

compute_individual_trajectory(timepoints, individual_parameters)[source]

Compute the individual trajectory based on the model’s features and parameters.

Parameters:
timepointstorch.Tensor

The time points at which to compute the trajectory.

individual_parametersdict

Dictionary containing the individual’s parameters, where keys are feature names.

Returns:
torch.Tensor

A tensor containing the computed trajectory for the individual.

Raises:
LeaspyModelInputError

If the model was not properly initialized or if features are not set.

Parameters:
  • timepoints (Tensor)

  • individual_parameters (dict)

Return type:

Tensor