causallib.survival.WeightedSurvival#
- class WeightedSurvival(weight_model=None, survival_model=None)[source]#
Weighted survival estimator
Weighted survival estimator. :param weight_model: causallib compatible weight model (e.g., IPW) :param survival_model: Three alternatives:
None - compute non-parametric KaplanMeier survival curve
- Scikit-Learn estimator (needs to implement predict_proba) - compute parametric curve by fitting a
time-varying hazards model
lifelines UnivariateFitter - use lifelines fitter to compute survival curves from events and durations
- __init__(weight_model=None, survival_model=None)[source]#
Weighted survival estimator. :param weight_model: causallib compatible weight model (e.g., IPW) :param survival_model: Three alternatives:
None - compute non-parametric KaplanMeier survival curve
- Scikit-Learn estimator (needs to implement predict_proba) - compute parametric curve by fitting a
time-varying hazards model
lifelines UnivariateFitter - use lifelines fitter to compute survival curves from events and durations
- fit(X, a, t=None, y=None, fit_kwargs=None)[source]#
Fits internal weight module (e.g. IPW module, adversarial weighting, etc).
- Parameters:
X (
pandas.DataFrame) – Baseline covariate matrix of size (num_subjects, num_features).a (
pandas.Series) – Treatment assignment of size (num_subjects,).t (
pandas.Series) – NOT USED (for compatibility only)y (
pandas.Series) – NOT USED (for compatibility only)fit_kwargs (
dict) – Optional kwargs for fit call of survival model (NOT USED, since fit call of survival model occurs in ‘estimate_population_outcome’ rather than here)
- Returns:
self
- estimate_population_outcome(X, a, t, y, timeline_start=None, timeline_end=None)[source]#
Returns population averaged survival curves.
- Parameters:
X (
pandas.DataFrame) – Baseline covariate matrix of size (num_subjects, num_features).a (
pandas.Series) – Treatment assignment of size (num_subjects,).t (
pandas.Series|int) – Followup durations, size (num_subjects,).y (
pandas.Series) – Observed outcome (1) or right censoring event (0), size (num_subjects,).timeline_start (
int) – Common start time-step. If provided, will generate survival curves starting from ‘timeline_start’ for all patients. If None, will predict from first observed event.timeline_end (
int) – Common end time-step. If provided, will generate survival curves up to ‘timeline_end’ for all patients. If None, will predict up to last observed event.
- Returns:
with timestep index, treatment values as columns and survival as entries
- Return type: