survivalpredict.pipeline.SklearnSurvivalPipeline

class survivalpredict.pipeline.SklearnSurvivalPipeline(steps, max_time, *, memory=None)

Scikit-learn compatible pipeline class for survivalpredict.

A sequence of data transformers and strata preprocessing with a final predictor. Takes a feature matrix/X as well as the output ‘build_sklearn_pipeline_target’ as the ‘y’. Combined survivalpredict’s ‘sklearn_scorer’s, it allows users to build pipelines that can interface with the rest of Scikit-learn’s api. Parameters of the various steps using their names and the parameter name separated by a ‘__’, allowing for parameters of various steps to be tuned during cross-validation searches.

Parameters:
  • steps (list[tuple[str, BaseEstimator]]) – List of the tuples with names and class instances that are chained together. The class instances are assumped to be scikit-learn transformers/survivalpredict StrataBuilders/StrataColumnTransformers. The final instance is assumed to be a survivalpredict estimator predictor.

  • max_time (int) – Maximum time for building survival curves.

  • memory (str or object with the joblib.Memory interface, default=None) – Used to cache the fitted transformers of the pipeline. The last step will never be cached, even if it is a transformer. By default, no caching is performed. If a string is given, it is the path to the caching directory. Enabling caching triggers a clone of the transformers before fitting. Therefore, the transformer instance given to the pipeline cannot be inspected directly. Use the attribute named_steps or steps to inspect estimators within the pipeline. Caching the transformers is advantageous when fitting is time consuming.

Methods

fit(X, y)

Fit the model.

predict(X[, strata])

Predict using the pipeline.

fit_predict

__init__(steps, max_time, *, memory=None)
Parameters:
  • steps (list[tuple[str, BaseEstimator]])

  • max_time (int)

Methods

__init__(steps, max_time, *[, memory])

fit(X, y)

Fit the model.

fit_predict(X, y)

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X[, strata])

Predict using the pipeline.

set_params(**kwargs)

Set the parameters of this estimator.

set_predict_request(*[, strata])

Configure whether metadata should be requested to be passed to the predict method.

fit(X, y)

Fit the model.

Parameters:
  • X (ndarray of shape (n_samples, n_features)) – Training data.

  • y (ndarray of shape) – Target values. Assumes that output of ‘build_sklearn_pipeline_target’.

Returns:

Returns the instance itself.

Return type:

object

predict(X, strata=None)

Predict using the pipeline.

Parameters:
  • X (ndarray of shape (n_samples, n_features)) – Samples.

  • strata (array-like of shape (n_samples,), dtype=np.int64, default=None) – If y from training/fit had prebuilt strata; strata can be passed into fit.

Returns:

The estimated survival curves, the left-most column is the probability of survival at time 1, and the right-most column ends at max_time.

Return type:

ndarray of shape (n_samples, max_time), dtype=np.float64