sksurv.nonparametric.kaplan_meier_estimator(event, time_exit, time_enter=None, time_min=None)

Kaplan-Meier estimator of survival function.

event : array-like, shape = (n_samples,)

Contains binary event indicators.

time_exit : array-like, shape = (n_samples,)

Contains event/censoring times.

time_enter : array-like, shape = (n_samples,), optional

Contains time when each individual entered the study for left truncated survival data.

time_min : float, optional

Compute estimator conditional on survival at least up to the specified time.

time : array, shape = (n_times,)

Unique times.

prob_survival : array, shape = (n_times,)

Survival probability at each unique time point. If time_enter is provided, estimates are conditional probabilities.


[1]Kaplan, E. L. and Meier, P., “Nonparametric estimation from incomplete observations”, Journal of The American Statistical Association, vol. 53, pp. 457-481, 1958.


Creating a Kaplan-Meier curve:

>>> x, y = kaplan_meier_estimator(event, time)
>>> plt.step(x, y, where="post")
>>> plt.ylim(0, 1)