scikit-survival

Fit and evaluate survival analysis models on censored time-to-event data in Python.

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill scikit-survival-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: scikit-survival
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/scikit-survival
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill scikit-survival-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires scikit-survival, scikit-learn, numpy, pandas, matplotlib, and includes references (resource) components.

What problem does it solve? Standard machine learning libraries cannot handle censored survival data where some subjects never experience the event during observation. This Skill guides you through time-to-event modeling with scikit-survival, from data preparation through model fitting and proper evaluation. ## Core Features & Use Cases - Multiple Model Families: Fit Cox proportional hazards models (standard and penalized Coxnet), Random Survival Forests, Gradient Boosting, and Survival SVMs depending on data size and interpretability needs. - Censoring-Aware Evaluation: Compute Harrell's and Uno's concordance index, time-dependent AUC, and integrated Brier score with correct handling of censored observations. - Competing Risks & Non-parametric Estimation: Estimate cumulative incidence functions for multiple event types, plus Kaplan-Meier and Nelson-Aalen curves. - Use Case: Given a clinical dataset with patient follow-up times and event indicators, build a Gradient Boosting survival model, tune it with cross-validation using the IPCW concordance scorer, and report Uno's C-index and integrated Brier score on held-out patients. ## Quick Start Ask the AI to fit a Cox proportional hazards model on your survival dataset and evaluate it with Uno's concordance index.

Frequently Asked Questions about scikit-survival

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fit a Cox proportional hazards model in Python?

Use CoxPHSurvivalAnalysis from sksurv.linear_model: create the outcome with Surv.from_arrays(event, time), then call estimator.fit(X, y). Coefficients are log hazard ratios, so exp(coef) gives the hazard ratio per unit increase.

What is the difference between Harrell's and Uno's concordance index?

Harrell's C-index is the traditional estimator but becomes biased when censoring exceeds roughly 40 percent. Uno's C-index (concordance_index_ipcw) uses inverse probability of censoring weighting and stays reliable under high censoring, making it the recommended choice.

Which survival model should I use for high-dimensional data?

Use CoxnetSurvivalAnalysis with an elastic net penalty when features outnumber samples. It performs automatic feature selection; tune l1_ratio and alpha_min_ratio with GridSearchCV using the IPCW concordance scorer.

Does scikit-survival support competing risks analysis?

Yes, cumulative_incidence_competing_risks estimates the cumulative incidence function for each mutually exclusive event type. For modeling, fit separate cause-specific Cox models treating other event types as censored; Fine-Gray models require other packages.

Why do survival SVMs need standardized features?

Survival SVMs are margin-based and sensitive to feature scale, so unstandardized features distort the optimization. Always apply StandardScaler before fitting FastSurvivalSVM or FastKernelSurvivalSVM, ideally inside a sklearn Pipeline.

When should I not use scikit-survival?

Avoid it for time-varying covariates, which it does not directly support, and for left- or interval-censored data, since it primarily handles right censoring. For those cases consider lifelines or specialized packages.