Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Complete survival analysis library in Python. Handles right-censored data, Kaplan-Meier curves, and Cox regression. Standard for clinical trial analysis and epidemiology.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | 3% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 60% | 0% |
| case-09 | ✗→✓ | ▲ Improved | -48% | 0% |
| case-01 | ✓→✓ | = Same ✓ | -5% | 0% |
| case-02 | ✓→✓ | = Same ✓ | -2% | 0% |
In medicine, we often care about "Time to Event" (death, recovery, relapse). Lifelines handles the complexity of "censored" data (patients who left the study).
Patients who haven't experienced the event by the end of the study are "censored". Lifelines properly accounts for this.
In Cox regression, a hazard ratio > 1 means increased risk; < 1 means decreased risk.
Kaplan-Meier estimates the probability of survival over time without assuming a distribution.
pythonfrom lifelines import KaplanMeierFitter, CoxPHFitter from lifelines.statistics import logrank_test import pandas as pd
python# 1. Kaplan-Meier (Visualizing survival) kmf = KaplanMeierFitter() kmf.fit(durations=df['days'], event_observed=df['died']) kmf.plot_survival_function() kmf.median_survival_time_ # Time when 50% have died # 2. Cox Proportional Hazards (Risk factors) cph = CoxPHFitter() cph.fit(df, duration_col='days', event_col='died') cph.print_summary() # See hazard ratios for age, drug type, etc. cph.plot_partial_effects_on_outcome(covariates=['age'], values=[30, 50, 70])
cph.check_assumptions() to validate Cox model.pythonfrom lifelines.statistics import multivariate_logrank_test # Compare survival across treatment groups results = multivariate_logrank_test(df['days'], df['group'], df['died']) print(results.p_value)
pythonfrom lifelines import WeibullFitter, ExponentialFitter # When you need to extrapolate beyond observed data wf = WeibullFitter() wf.fit(df['days'], df['died']) wf.plot()
Lifelines transforms complex survival data into actionable medical insights, enabling evidence-based decisions in clinical research and practice.
Other measured skills in the registry, with their headline benchmark lift.