tempor.methods.time_to_event.helper_embedding module

Helper class for embedding time-series data for time-to-event analysis using Dynamic DeepHit embeddings.

class tempor.methods.time_to_event.helper_embedding.OutputTimeToEventAnalysis[source]

Bases: object

Helper base class for time-to-event analysis models.

abstract fit(X: DataFrame, T: Series, Y: Series) Self[source]

Fit the model.

Parameters:
X : pd.DataFrame

Input covariates of fixed shape - time-series data should be embedded first.

T : pd.Series

Event times.

Y : pd.Series

Event values.

Returns:

Fitted model.

Return type:

Self

abstract predict_risk(X: DataFrame, time_horizons: list) DataFrame[source]

Predict risk scores.

Parameters:
X : pd.DataFrame

Input covariates of fixed shape - time-series data should be embedded first.

time_horizons : List

Time horizons to predict risk at.

Returns:

Risk scores.

Return type:

pd.DataFrame

class tempor.methods.time_to_event.helper_embedding.DDHEmbedding(emb_model: DynamicDeepHitModel)[source]

Bases: object

Survival analysis embedding creation for time-series with tempor.models.ddh.DynamicDeepHitModel.

Parameters:
emb_model : DynamicDeepHitModel

tempor.models.ddh.DynamicDeepHitModel to use for temporal feature embedding.

prepare_fit(data: BaseDataset) tuple[ndarray, ndarray, ndarray][source]

Prepare data for fitting.

Parameters:
data : dataset.BaseDataset

Input dataset.

Returns:

Processed covariate data, event times, event values.

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray]

prepare_predict(data: PredictiveDataset, horizons: list[float] | list[int] | list[Timestamp], *args: Any, **kwargs: Any) ndarray[source]

Prepare data for prediction.

Parameters:
data : dataset.PredictiveDataset

Input dataset.

horizons : data_typing.TimeIndex

Time horizons to predict risk at.

*args : Any

Additional arguments.

**kwargs : Any

Additional keyword arguments.

Returns:

Processed data.

Return type:

np.ndarray

static hyperparameter_space(*args: Any, **kwargs: Any) list[Params][source]
class tempor.methods.time_to_event.helper_embedding.DDHEmbeddingTimeToEventAnalysis(output_model: OutputTimeToEventAnalysis, emb_model: DynamicDeepHitModel)[source]

Bases: DDHEmbedding

Survival analysis embedding creation for time-series with tempor.models.ddh.DynamicDeepHitModel followed by output_model OutputTimeToEventAnalysis survival analysis estimator.

Parameters:
output_model : OutputTimeToEventAnalysis

Output model to use for predicting risk.

emb_model : DynamicDeepHitModel

tempor.models.ddh.DynamicDeepHitModel to use for temporal feature embedding.

fit(data: BaseDataset, *args: Any, **kwargs: Any) Self[source]

Fit the model.

Parameters:
data : dataset.BaseDataset

Input dataset.

*args : Any

Additional arguments.

**kwargs : Any

Additional keyword arguments.

Returns:

Fitted model.

Return type:

Self

predict(data: PredictiveDataset, horizons: list[float] | list[int] | list[Timestamp], *args: Any, **kwargs: Any) TimeSeriesSamplesBase[source]

Predict risk scores.

*args and **kwargs will be passed to self.emb_model.predict_emb(). E.g. batch_size batch size parameter can be provided this way.

Parameters:
data : dataset.PredictiveDataset

Input dataset.

horizons : data_typing.TimeIndex

Time horizons to predict risk at.

*args : Any

Additional arguments. Passed to self.emb_model.predict_emb()

**kwargs : Any

Additional keyword arguments. Passed to self.emb_model.predict_emb()

Returns:

Predicted risk scores.

Return type:

samples.TimeSeriesSamplesBase

static hyperparameter_space(*args: Any, **kwargs: Any) list[Params][source]