tempor.metrics.time_to_event.plugin_builtin_time_to_event module

Module with built-in metric plugins for the time-to-event (survival) analysis task.

class tempor.metrics.time_to_event.plugin_builtin_time_to_event.CIndexTimeToEventMetric[source]

Bases: TimeToEventMetric

IPCW concordance index metric for time-to-event (survival) analysis tasks.

The base class that all plugins must inherit from.

property direction : Literal[minimize] | Literal[maximize]

The direction of the metric

evaluate(actual: tuple[ndarray, ndarray], predicted: ndarray, horizons: list[float] | list[int] | list[Timestamp], actual_train: tuple[ndarray, ndarray], *args: Any, **kwargs: Any) list[float][source]

The metric evaluation call.

Parameters:
actual : metric_typing.EventArrayTimeArray

A tuple of two numpy arrays: the event values array and the event times array, for the actual event vales.

predicted : np.ndarray

A numpy array of shape (n_samples, n_horizons_timesteps, n_features) with the predicted risk estimates.

horizons : data_typing.TimeIndex

List of horizons time points.

actual_train : metric_typing.EventArrayTimeArray

A tuple of two numpy arrays: the event values array and the event times array, for the actual event vales - in the training set.

*args : Any

Additional positional arguments.

**kwargs : Any

Additional keyword arguments.

Returns:

The metric values for each horizon time point.

Return type:

List[float]

category : ClassVar[str] = 'time_to_event'

Plugin category, such as 'prediction.one_off.classification'. Must be set by the plugin class using @register_plugin.

name : ClassVar[str] = 'c_index'

Plugin name, such as 'my_nn_classifier'. Must be set by the plugin class using @register_plugin.

plugin_type : ClassVar[None | Literal[all] | str] = 'metric'

Plugin type, such as 'method'. May be optionally set by the plugin class using @register_plugin, else will set the default plugin type.

class tempor.metrics.time_to_event.plugin_builtin_time_to_event.BrierScoreTimeToEventMetric[source]

Bases: TimeToEventMetric

Time-dependent Brier score metric for time-to-event (survival) analysis tasks.

The base class that all plugins must inherit from.

property direction : Literal[minimize] | Literal[maximize]

The direction of the metric

evaluate(actual: tuple[ndarray, ndarray], predicted: ndarray, horizons: list[float] | list[int] | list[Timestamp], actual_train: tuple[ndarray, ndarray], *args: Any, **kwargs: Any) list[float][source]

The metric evaluation call.

Parameters:
actual : metric_typing.EventArrayTimeArray

A tuple of two numpy arrays: the event values array and the event times array, for the actual event vales.

predicted : np.ndarray

A numpy array of shape (n_samples, n_horizons_timesteps, n_features) with the predicted risk estimates.

horizons : data_typing.TimeIndex

List of horizons time points.

actual_train : metric_typing.EventArrayTimeArray

A tuple of two numpy arrays: the event values array and the event times array, for the actual event vales - in the training set.

*args : Any

Additional positional arguments.

**kwargs : Any

Additional keyword arguments.

Returns:

The metric values for each horizon time point.

Return type:

List[float]

category : ClassVar[str] = 'time_to_event'

Plugin category, such as 'prediction.one_off.classification'. Must be set by the plugin class using @register_plugin.

name : ClassVar[str] = 'brier_score'

Plugin name, such as 'my_nn_classifier'. Must be set by the plugin class using @register_plugin.

plugin_type : ClassVar[None | Literal[all] | str] = 'metric'

Plugin type, such as 'method'. May be optionally set by the plugin class using @register_plugin, else will set the default plugin type.