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)

Bases: leaspy.models.generic.GenericModel

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.

**kwargs

Hyperparameters for the model. None supported for now.

Attributes:
namestr

The model’s name.

is_initializedbool

Always True (no true initialization needed for constant model).

featureslist of str

List of the model features. Unlike most models features will be determined at personalization only (because it does not needed any fit).

dimensionint

Number of features (read-only).

parametersdict

The model has no parameters: empty dictionary. The prediction_type parameter should be defined during personalization. Example:

>>> AlgorithmSettings('constant_prediction', prediction_type='last_known')
Parameters:

name (str)

See also

ConstantPredictionAlgorithm
is_initialized = True
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_parametersdict [ str, Any]

Contains the individual parameters. Each individual parameter should be a scalar or array_like.

Returns:
torch.Tensor

Contains the subject’s scores computed at the given age(s). The shape of the tensor is (1, n_tpts, n_features).

Parameters:
  • timepoints (Tensor)

  • individual_parameters (dict)

Return type:

Tensor