Skip to content

Python survival analysis with Kaplan-Meier curves, log-rank tests, and Cox proportional hazards models on censored data.

CCM score
40 of 100
skills.sh installs
454
GitHub stars
396
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers time-to-event workflows: Kaplan-Meier estimates, group comparisons, Cox regression, and survival prediction for new subjects
  • Includes runnable lifelines code that simulates censored data and plots survival curves by group and risk quartile
  • Reports hazard ratios, concordance index, and a proportional hazards assumption test alongside model fits
  • Designed for analysts who need survival probabilities at fixed horizons and a check on the Cox model's assumptions

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill 'Survival Analysis' -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Survival Analysis

Overview

Survival analysis studies time until an event occurs, handling censored data where events haven't happened for some subjects, enabling prediction of lifetimes and risk assessment.

Key Concepts

  • Survival Time: Time until event
  • Censoring: Event not observed (subject dropped out)
  • Hazard: Instantaneous risk at time t
  • Survival Curve: Probability of surviving past time t
  • Hazard Ratio: Relative risk between groups

Common Models

  • Kaplan-Meier: Non-parametric survival curves
  • Cox Proportional Hazards: Semi-parametric regression
  • Weibull/Exponential: Parametric models
  • Log-rank Test: Comparing survival curves
  • Competing Risks: Multiple event types

Implementation with Python

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from lifelines import KaplanMeierFitter, CoxPHFitter, WeibullAFTFitter
from lifelines.statistics import logrank_test
import warnings
warnings.filterwarnings('ignore')

# Generate sample survival data
np.random.seed(42)
n_patients = 200

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Data Science & Analytics, Research & Academic
First seen
Jun 3, 2026

Questions

What does the Survival Analysis skill do?

Survival Analysis analyzes time-to-event data, calculates survival probabilities, and compares groups using Kaplan-Meier and Cox proportional hazards models. It handles censored data, where the event was not observed for some subjects, and supports prediction of lifetimes and risk assessment.

How do I install the Survival Analysis skill?

Run npx -y skills add aj-geddes/useful-ai-prompts --skill 'Survival Analysis' -y in your project. Once installed, the Survival Analysis skill lets your agent fit Kaplan-Meier curves, run log-rank tests and fit Cox proportional hazards models.

Which models does the Survival Analysis skill cover?

The Survival Analysis skill covers Kaplan-Meier survival curves, Cox proportional hazards regression, Weibull and exponential parametric models, the log-rank test for comparing curves, and competing risks. Its Python examples use the lifelines library.

Which other skills sit in the same category as Survival Analysis?

Survival Analysis is listed in the Data Science and Analytics category on Claude Marketplaces, alongside azure-kusto, analyze-project, run-train, explore-run and add-analytics-instrumentation. This skill focuses on time-to-event modeling with Kaplan-Meier and Cox methods.

More from aj-geddes/useful-ai-prompts

All 258

Similar to Survival Analysis

More Data Science & Analytics