scikit-survival
Analyze survival data with scikit-survival
Also available from: davila7
Survival analysis handles data where events may not have occurred for all subjects. This skill provides Python tools for time-to-event modeling with censored data using Cox models, Random Survival Forests, SVMs, and specialized evaluation metrics like concordance index.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "scikit-survival". Build a survival model for the veterans lung cancer dataset and evaluate performance
Expected outcome:
- Loaded veterans_lung_cancer dataset with 137 patients
- Censoring rate: 8.0% (11 events, 126 censored)
- Fitted CoxPHSurvivalAnalysis with concordance_index_ipcw = 0.73
- Top risk factors: Karnofsky score (HR=0.96), age (HR=1.02)
- Time-dependent AUC at 180 days: 0.81
Using "scikit-survival". Compare Random Survival Forest and Cox model on GBSG2 breast cancer data
Expected outcome:
- Loaded GBSG2 dataset with 2238 patients, 1548 events
- RandomSurvivalForest C-index: 0.68 (5-fold CV)
- CoxPHSurvivalAnalysis C-index: 0.66 (5-fold CV)
- RSF selected 12/7 features via permutation importance
- Recommendation: RSF provides slightly better ranking ability
Security Audit
SafeAll 277 static findings are FALSE POSITIVES. This skill contains only markdown documentation for the legitimate scikit-survival Python library. The 'Ruby/shell backtick execution' detections are markdown code fences (```python) for Python syntax highlighting. No executable code, scripts, or malicious patterns exist. The 'C2 keywords' and 'weak cryptographic algorithm' detections are false positives caused by statistical/medical terminology being misidentified by the pattern scanner.
Risk Factors
⚡ Contains scripts (2)
⚙️ External commands (3)
🌐 Network access (1)
Quality Score
What You Can Build
Patient survival prediction
Analyze clinical trial data to predict patient survival probabilities and identify risk factors for adverse outcomes.
Time-to-event machine learning
Build and compare multiple survival models including Cox, Random Survival Forest, and SVM for predictive maintenance or customer churn.
Disease progression modeling
Study time-to-event data with competing risks such as death from different causes in disease progression studies.
Try These Prompts
Use scikit-survival to load the breast cancer dataset, split it into train and test sets, fit a Cox Proportional Hazards model, and evaluate using Uno's concordance index.
Compare CoxPHSurvivalAnalysis, RandomSurvivalForest, GradientBoostingSurvivalAnalysis, and FastSurvivalSVM on the GBSG2 dataset using cross-validation with concordance index scoring.
Use CoxnetSurvivalAnalysis with elastic net regularization to perform feature selection on high-dimensional survival data, then identify which features were selected.
Demonstrate competing risks analysis using cumulative_incidence_competing_risks. Show how to estimate cumulative incidence for different event types and compare between treatment groups.
Best Practices
- Always standardize features for SVMs and regularized Cox models before fitting
- Use Uno's C-index (concordance_index_ipcw) instead of Harrell's when censoring exceeds 40%
- Report multiple evaluation metrics including C-index, integrated Brier score, and time-dependent AUC
Avoid
- Using Kaplan-Meier estimator when competing risks are present (use cumulative incidence instead)
- Using built-in feature importance for Random Survival Forests (use permutation importance)
- Not checking proportional hazards assumption for Cox models before interpretation
Frequently Asked Questions
What is the difference between Harrell's and Uno's C-index?
How do I handle competing risks?
Which model should I choose for high-dimensional data?
How do I evaluate model calibration?
Can I use scikit-survival with scikit-learn pipelines?
What preprocessing is required for survival data?
Developer Details
Author
K-Dense-AILicense
GPL-3.0 license
Repository
https://github.com/K-Dense-AI/claude-scientific-skills/tree/main/scientific-skills/scikit-survivalRef
main
File structure