100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Survival Analysis Cheat Sheet

Survival Analysis Cheat Sheet

Covers censoring, the survival and hazard functions, Kaplan-Meier estimation, and Cox proportional hazards regression using the lifelines library.

2 PagesAdvancedMar 20, 2026

Core Concepts

Vocabulary specific to time-to-event data.

  • Censoring- When the event (e.g., death, churn, failure) hasn't occurred by the end of observation; right-censoring is most common
  • Survival function S(t)- Probability that the event has not yet occurred by time t
  • Hazard function h(t)- Instantaneous risk of the event occurring at time t, given survival up to t
  • Kaplan-Meier estimator- Non-parametric estimate of the survival function from censored data
  • Proportional hazards assumption- Cox model assumption that covariates' effect on the hazard ratio is constant over time
  • Log-rank test- Hypothesis test comparing survival curves between two or more groups

Kaplan-Meier Estimator

Estimate and plot the survival curve for a cohort.

python
from lifelines import KaplanMeierFitterkmf = KaplanMeierFitter()kmf.fit(durations=df['time'], event_observed=df['event'], label='All customers')kmf.plot_survival_function()print(kmf.median_survival_time_)

Cox Proportional Hazards Model

Model how covariates affect the hazard rate.

python
from lifelines import CoxPHFittercph = CoxPHFitter()cph.fit(df, duration_col='time', event_col='event')cph.print_summary()             # coefficients, hazard ratios, p-valuescph.plot()                      # forest plot of hazard ratios# hazard ratio > 1 => higher risk; < 1 => protective effecthr = cph.hazard_ratios_

When to Reach for Survival Analysis

Signals that ordinary regression is the wrong tool.

  • Time-to-churn modeling- Predicting when a subscriber will cancel rather than just whether they will
  • Equipment failure / reliability- Estimating time until a machine part fails
  • Clinical trials- Comparing time-to-event (e.g., relapse) between treatment and control groups
  • Right-censored data present- Use survival methods instead of dropping or imputing censored rows, which biases estimates
Pro Tip

Never drop censored observations to run ordinary linear regression -- that discards the very information (that the event hadn't happened yet) survival models are built to use correctly.

Was this cheat sheet helpful?

Explore Topics

#SurvivalAnalysis#SurvivalAnalysisCheatSheet#DataScience#Advanced#CoreConcepts#KaplanMeierEstimator#Cox#Proportional#Functions#MachineLearning#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet