Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Fits survival models in Python with lifelines, including Kaplan-Meier, Cox proportional hazards, Aalen additive, and parametric methods.
91% 100%+9 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 20 of 22 without it.
3 of 3 safety checks passed
Not used yet
Lifelines is a survival analysis library for Python. It implements Kaplan-Meier, Cox Proportional Hazard, parametric models (Weibull, Log-Normal), and Aalen's additive model. Use it for time-to-event data in clinical trials, churn analysis, reliability engineering, and customer retention studies.
uv pip install lifelines
from lifelines import KaplanMeierFitter
import pandas as pd
T = pd.Series([5, 10, 15, 20, 25, 30]) # durations
E = pd.Series([1, 1, 0, 1, 0, 0]) # event observed?
kmf = KaplanMeierFitter()
kmf.fit(T, E)
kmf.plot_survival_function()
print(kmf.median_survival_time_)
from lifelines import CoxPHFitter
df = pd.DataFrame({
"duration": [5, 10, 15, 20, 25, 30],
"event": [1, 1, 0, 1, 0, 0],
"age": [45, 60, 55, 70, 50, 65],
"treatment": [1, 0, 1, 0, 1, 0],
})
cph = CoxPHFitter()
cph.fit(df, duration_col="duration", event_col="event")
cph.print_summary()
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.