causallib.survival.univariate_curve_fitter module

class causallib.survival.univariate_curve_fitter.UnivariateCurveFitter(learner: Optional[sklearn.base.BaseEstimator] = None)[source]

Bases: object

Default implementation of a univariate survival curve fitter. Construct a curve fitter, either non-parametric (Kaplan-Meier) or parametric. API follows ‘lifelines’ convention for univariate models, see here for example: https://lifelines.readthedocs.io/en/latest/fitters/univariate/KaplanMeierFitter.html#lifelines.fitters.kaplan_meier_fitter.KaplanMeierFitter.fit :param learner: optional scikit-learn estimator (needs to implement predict_proba). If provided, will

compute parametric curve by fitting a time-varying hazards model. if None, will compute non-parametric Kaplan-Meier estimator.

fit(durations, event_observed=None, weights=None)[source]

Fits a univariate survival curve (Kaplan-Meier or parametric, if a learner was provided in constructor)

Parameters
  • durations (Iterable) – Duration subject was observed

  • event_observed (Optional[Iterable]) – Boolean or 0/1 iterable, where True means ‘outcome event’ and False means ‘right censoring’. If unspecified, assumes that all events are ‘outcome’ (no censoring).

  • weights (Optional[Iterable]) – Optional subject weights

Returns

Self

predict(times=None, interpolate=False)[source]

Compute survival curve for time points given in ‘times’ param. :param times: sequence of time points for prediction :param interpolate: if True, linearly interpolate non-observed times. Otherwise, repeat last observed time point.

Returns

with times index and survival values

Return type

pd.Series