Skip to content
Skillpedia
Machine learning33k Β· #9026

scikit-survival

What it does

This skill teaches your agent to use scikit-survival for survival analysis. It handles censored data, where some outcomes are not yet known. It is for researchers studying time until events such as relapse or failure.

When to use it

  • βœ“When you have time-to-event data where some subjects did not have the event by the end of the study.
  • βœ“When you want to fit a Cox model or a random survival forest to predict survival.
  • βœ“When you need to check a survival model with the concordance index or Brier score.

Skill link

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/scikit-survival/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/scikit-survival/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œFit a Cox model and a random survival forest on my patient data, and compare their concordance index.”

5 new skills a week. 1 minute to read.

How it works

The agent prepares the censored outcome data, fits each model, and evaluates it with metrics such as the concordance index. It then reports which model predicts survival better.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

scikit-survival: Survival Analysis in Python

Overview

scikit-survival is a Python library for survival analysis built on top of scikit-learn. It provides specialized tools for time-to-event analysis, handling the unique challenge of censored data where some observations are only partially known.

Survival analysis aims to establish connections between covariates and the time of an event, accounting for censored records (particularly right-censored data from studies where participants don't experience events during observation periods).

When to Use This Skill

Use this skill when:

  • Performing survival analysis or time-to-event modeling
  • Working with censored data (right-censored, left-censored, or interval-censored)
  • Fitting Cox proportional hazards models (standard or penalized)
  • Building ensemble survival models (Random Survival Forests, Gradient Boosting)
  • Training Survival Support Vector Machines
  • Evaluating survival model performance (concordance index, Brier score, time-dependent AUC)
  • Estimating Kaplan-Meier or Nelson-Aalen curves
  • Analyzing competing risks
  • Preprocessing survival data or handling missing values in survival datasets
  • Conducting any analysis using the scikit-survival library

Core Capabilities

1. Model Types and Selection

scikit-survival provides multiple model families, each suited for different scenarios:

Cox Proportional Hazards Models

Use for: Standard survival analysis with interpretable coefficients

  • CoxPHSurvivalAnalysis: Basic Cox model
  • CoxnetSurvivalAnalysis: Penalized Cox with elastic net for high-dimensional data
  • IPCRidge: Ridge regression for accelerated failure time models

See: references/cox-models.md for detailed guidance on Cox models, regularization, and interpretation

Ensemble Methods

Use for: High predictive performance with complex non-linear relationships

  • RandomSurvivalForest: Robust, non-parametric ensemble method
  • GradientBoostingSurvivalAnalysis: Tree-based boosting for maximum performance
  • ComponentwiseGradientBoostingSurvivalAnalysis: Linear boosting with feature selection
  • ExtraSurvivalTrees: Extremely randomized trees for additional regularization

See: references/ensemble-models.md for comprehensive guidance on ensemble methods, hyperparameter tuning, and when to use each model

Survival Support Vector Machines

Use for: Medium-sized datasets with margin-based learning

  • FastSurvivalSVM: Linear SVM optimized for speed
  • FastKernelSurvivalSVM: Kernel SVM for non-linear relationships
  • HingeLossSurvivalSVM: SVM with hinge loss
  • ClinicalKernelTransform: Specialized kernel for clinical + molecular data

See: references/svm-models.md for detailed SVM guidance, kernel selection, and hyperparameter tuning

Model Selection Decision Tree

Start
β”œβ”€ High-dimensional data (p > n)?
β”‚  β”œβ”€ Yes β†’ CoxnetSurvivalAnalysis (elastic net)
β”‚  └─ No β†’ Continue
β”‚
β”œβ”€ Need interpretable coefficients?
β”‚  β”œβ”€ Yes β†’ CoxPHSurvivalAnalysis or ComponentwiseGradientBoostingSurvivalAnalysis
β”‚  └─ No β†’ Continue
β”‚
β”œβ”€ Complex non-linear relationships expected?
β”‚  β”œβ”€ Yes
β”‚  β”‚  β”œβ”€ Large dataset (n > 1000) β†’ GradientBoostingSurvivalAnalysis
β”‚  β”‚  β”œβ”€ Medium dataset β†’ RandomSurvivalForest or FastKernelSurvivalSVM
β”‚  β”‚  └─ Small dataset β†’ RandomSurvivalForest
β”‚  └─ No β†’ CoxPHSurvivalAnalysis or FastSurvivalSVM
β”‚
└─ For maximum performance β†’ Try multiple models and compare

2. Data Preparation and Preprocessing

Before modeling, properly prepare survival data:

Creating Survival Outcomes

from sksurv.util import Surv

# From separate arrays
y = Surv.from_arrays(event=event_array, time=time_array)

# From DataFrame
y = Surv.from_dataframe('event', 'time', df)

Essential Preprocessing Steps

  1. Handle missing values: Imputation strategies for features
  2. Encode categorical variables: One-hot encoding or label encoding
  3. Standardize features: Critical for SVMs and regularized Cox models
  4. Validate data quality: Check for negative times, sufficient events per feature
  5. Train-test split: Maintain similar censoring rates across splits

See: references/data-handling.md for complete preprocessing workflows, data validation, and best practices

3. Model Evaluation

Proper evaluation is critical for survival models. Use appropriate metrics that account for censoring:

Concordance Index (C-index)

Primary metric for ranking/discrimination:

FAQ

What is censored data?

It is data where the event time is only partly known, such as when a patient leaves the study before the event.

Which models are included?

The skill covers Cox models, random survival forests, gradient boosting, and survival SVMs.

Can it draw survival curves?

Yes. The skill covers Kaplan-Meier and Nelson-Aalen estimates.

Details

Original description by the author

Comprehensive toolkit for survival analysis and time-to-event modeling in Python using scikit-survival. Use this skill when working with censored survival data, performing time-to-event analysis, fitting Cox models, Random Survival Forests, Gradient Boosting models, or Survival SVMs, evaluating survival predictions with concordance index or Brier score, handling competing risks, or implementing any survival analysis workflow with the scikit-survival library.

repo: davila7/claude-code-templates

Popularity

GitHub stars
33k
Ranking position
#9026
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills