causallib.survival.RegressionCurveFitter#
- class RegressionCurveFitter(learner)[source]#
Default implementation of a parametric survival curve fitter with covariates (pooled regression). API follows ‘lifelines’ convention for regression models, see here for example: https://lifelines.readthedocs.io/en/latest/fitters/regression/CoxPHFitter.html#lifelines.fitters.coxph_fitter.CoxPHFitter.fit
- Parameters:
learner (BaseEstimator) – scikit-learn estimator (needs to implement predict_proba) - compute parametric curve by fitting a time-varying hazards model that includes baseline covariates. Note that the model is fitted on a person-time table with all covariates, and might be computationally and memory expansive.
- __init__(learner)[source]#
Default implementation of a parametric survival curve fitter with covariates (pooled regression). API follows ‘lifelines’ convention for regression models, see here for example: https://lifelines.readthedocs.io/en/latest/fitters/regression/CoxPHFitter.html#lifelines.fitters.coxph_fitter.CoxPHFitter.fit
- Parameters:
learner (BaseEstimator) – scikit-learn estimator (needs to implement predict_proba) - compute parametric curve by fitting a time-varying hazards model that includes baseline covariates. Note that the model is fitted on a person-time table with all covariates, and might be computationally and memory expansive.
- fit(df, duration_col, event_col=None, weights_col=None)[source]#
Fits a parametric curve with covariates.
- Parameters:
df (
pandas.DataFrame) – DataFrame, must contain a ‘duration_col’, and optional ‘event_col’ / ‘weights_col’. All other columns are treated as baseline covariates.duration_col (
str) – Name of column with subjects’ lifetimes (time-to-event)event_col (
Optional[str]) – Name of column with event type (outcome=1, censor=0). If unspecified, assumes that all events are ‘outcome’ (no censoring).weights_col (
Optional[str]) – Name of column with optional subject weights.
- Returns:
Self
- predict_survival_function(X=None, times=None)[source]#
Predicts survival function (table) for individuals, given their covariates. :param X: Subjects covariates :type X:
pandas.DataFrame / pandas.Series:param times: An iterable of increasing time points to predict cumulative hazard at.If unspecified, predict all observed time points in data.
- Returns:
Each column contains a survival curve for an individual, indexed by time-steps
- Return type: