survivalpredict.strata_preprocessing.StrataBuilderEncoder

class survivalpredict.strata_preprocessing.StrataBuilderEncoder

Builds strata keys from categorical data.

If existing strata are passed in, it adds onto existing strata. StrataBuilderEncoder works on categorical data encoded in numerical or string types. One or many columns of mixed types can be used.

Methods

fit(X[, times, events, strata, check_input])

Learn the strata.

fit_transform(X[, times, events, strata])

Fit and build strata.

set_output(*[, transform])

Set output container.

set_transform_request(*[, events, strata, times])

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

transform(X[, times, events, strata])

Encode categorical data to build strata.

__init__(*args, **kwargs)

Methods

__init__(*args, **kwargs)

fit(X[, times, events, strata, check_input])

Learn the strata.

fit_transform(X[, times, events, strata])

Fit and build strata.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_fit_request(*[, check_input, events, ...])

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

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

set_transform_request(*[, events, strata, times])

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

transform(X[, times, events, strata])

Encode categorical data to build strata.

fit(X, times=None, events=None, strata=None, check_input=True)

Learn the strata.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Data to be discretized.

  • times (array-like of shape n_samples, default=None) – Ignored.

  • events (array-like of shape n_samples, default=None) – Ignored.

  • strata (array-like of shape n_samples, default=None) – Preexsting strata, the strata built will add onto the preexsting strata.

  • check_input (bool, default True) – If True, runs checks and casting on data to ensure data is valid.

Returns:

Returns the instance itself.

Return type:

object

fit_transform(X, times=None, events=None, strata=None)

Fit and build strata.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Data to be encoded.

  • times (array-like of shape n_samples, default=None) – Ignored.

  • events (array-like of shape n_samples, default=None) – Ignored.

  • strata (array-like of shape n_samples, default=None) – Preexsting strata, the strata built will add onto the preexsting strata.

Returns:

Build strata.

Return type:

ndarray of shape (n_samples) , dtype=np.int64

set_output(*, transform=None)

Set output container.

See sphx_glr_auto_examples_miscellaneous_plot_set_output.py for an example on how to use the API.

Parameters:

transform ({"default", "pandas", "polars"}, default=None) –

Configure output of transform and fit_transform.

  • ”default”: Default output format of a transformer

  • ”pandas”: DataFrame output

  • ”polars”: Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: “polars” option was added.

Returns:

self – Estimator instance.

Return type:

estimator instance

set_transform_request(*, events='$UNCHANGED$', strata='$UNCHANGED$', times='$UNCHANGED$')

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

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to transform.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
  • events (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for events parameter in transform.

  • strata (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for strata parameter in transform.

  • times (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for times parameter in transform.

  • self (StrataBuilderEncoder)

Returns:

self – The updated object.

Return type:

object

transform(X, times=None, events=None, strata=None)

Encode categorical data to build strata.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Data to be encoded.

  • times (array-like of shape n_samples, default=None) – Ignored.

  • events (array-like of shape n_samples, default=None) – Ignored.

  • strata (array-like of shape n_samples, default=None) – Preexsting strata, the strata built will add onto the preexsting strata.

Returns:

Build strata.

Return type:

ndarray of shape (n_samples) , dtype=np.int64