sksurv.nonparametric.CensoringDistributionEstimator#

class sksurv.nonparametric.CensoringDistributionEstimator(conf_level=0.95, conf_type=None)[source]#

Kaplan–Meier estimator for the censoring distribution.

__init__(conf_level=0.95, conf_type=None)[source]#

Methods

__init__([conf_level, conf_type])

fit(y)

Estimate censoring distribution from training data.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict_ipcw(y)

Return inverse probability of censoring weights at given time points.

predict_proba(time[, return_conf_int])

Return probability of remaining event-free at given time points.

set_params(**params)

Set the parameters of this estimator.

set_predict_proba_request(*[, ...])

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

fit(y)[source]#

Estimate censoring distribution from training data.

Parameters:

y (structured array, shape = (n_samples,)) – A structured array with two fields. The first field is a boolean where True indicates an event and False indicates right-censoring. The second field is a float with the time of event or time of censoring.

Return type:

self

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

get_params(deep=True)#

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

predict_ipcw(y)[source]#

Return inverse probability of censoring weights at given time points.

\(\omega_i = \delta_i / \hat{G}(y_i)\)

Parameters:

y (structured array, shape = (n_samples,)) – A structured array with two fields. The first field is a boolean where True indicates an event and False indicates right-censoring. The second field is a float with the time of event or time of censoring.

Returns:

ipcw – Inverse probability of censoring weights.

Return type:

ndarray, shape = (n_samples,)

predict_proba(time, return_conf_int=False)[source]#

Return probability of remaining event-free at given time points.

\(\hat{S}(t) = P(T > t)\)

Parameters:
  • time (array-like, shape = (n_samples,)) – Time to estimate probability at.

  • return_conf_int (bool, optional, default: False) – Whether to return the pointwise confidence interval of the survival function. Only available if fit() has been called with the conf_type parameter set.

Returns:

  • prob (ndarray, shape = (n_samples,)) – Probability of remaining event-free at the given time points.

  • conf_int (ndarray, shape = (2, n_samples)) – Pointwise confidence interval at the passed time points. Only provided if return_conf_int is True.

set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance

set_predict_proba_request(*, return_conf_int: bool | None | str = '$UNCHANGED$', time: bool | None | str = '$UNCHANGED$') CensoringDistributionEstimator#

Configure whether metadata should be requested to be passed to the predict_proba 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 predict_proba 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 predict_proba.

  • 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:
  • return_conf_int (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for return_conf_int parameter in predict_proba.

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

Returns:

self – The updated object.

Return type:

object