[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71GEW35AB5QKDWEMFM0M2M2":3,"skill-same:01M71GEW35AB5QKDWEMFM0M2M2":95},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":54,"install":55,"resources":68},"01M71GEW35AB5QKDWEMFM0M2M2","scikit-survival",null,"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.","JSGforever\u002Fskillguard","JSGforever","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F85541948?v=4","01M71FQD3E132VMR5F4TAYX3YS","01M71FQD4DYW0XJ4XQ4YQH75Y9",2,"GPL-3.0","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"survival","scikit survival","Cox","toolkit","use","python","random","event","for","gradient","library","data","modeling","gradient boosting","analysis","workflow","predictions","when","implementing","time","2026-11-10 10:12:30",false,"---\nname: scikit-survival\ndescription: 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.\n---\n\n# scikit-survival: Survival Analysis in Python\n\n## Overview\n\nscikit-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.\n\nSurvival 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).\n\n## When to Use This Skill\n\nUse this skill when:\n- Performing survival analysis or time-to-event modeling\n- Working with censored data (right-censored, left-censored, or interval-censored)\n- Fitting Cox proportional hazards models (standard or penalized)\n- Building ensemble survival models (Random Survival Forests, Gradient Boosting)\n- Training Survival Support Vector Machines\n- Evaluating survival model performance (concordance index, Brier score, time-dependent AUC)\n- Estimating Kaplan-Meier or Nelson-Aalen curves\n- Analyzing competing risks\n- Preprocessing survival data or handling missing values in survival datasets\n- Conducting any analysis using the scikit-survival library\n\n## Core Capabilities\n\n### 1. Model Types and Selection\n\nscikit-survival provides multiple model families, each suited for different scenarios:\n\n#### Cox Proportional Hazards Models\n**Use for**: Standard survival analysis with interpretable coefficients\n- `CoxPHSurvivalAnalysis`: Basic Cox model\n- `CoxnetSurvivalAnalysis`: Penalized Cox with elastic net for high-dimensional data\n- `IPCRidge`: Ridge regression for accelerated failure time models\n\n**See**: `references\u002Fcox-models.md` for detailed guidance on Cox models, regularization, and interpretation\n\n#### Ensemble Methods\n**Use for**: High predictive performance with complex non-linear relationships\n- `RandomSurvivalForest`: Robust, non-parametric ensemble method\n- `GradientBoostingSurvivalAnalysis`: Tree-based boosting for maximum performance\n- `ComponentwiseGradientBoostingSurvivalAnalysis`: Linear boosting with feature selection\n- `ExtraSurvivalTrees`: Extremely randomized trees for additional regularization\n\n**See**: `references\u002Fensemble-models.md` for comprehensive guidance on ensemble methods, hyperparameter tuning, and when to use each model\n\n#### Survival Support Vector Machines\n**Use for**: Medium-sized datasets with margin-based learning\n- `FastSurvivalSVM`: Linear SVM optimized for speed\n- `FastKernelSurvivalSVM`: Kernel SVM for non-linear relationships\n- `HingeLossSurvivalSVM`: SVM with hinge loss\n- `ClinicalKernelTransform`: Specialized kernel for clinical + molecular data\n\n**See**: `references\u002Fsvm-models.md` for detailed SVM guidance, kernel selection, and hyperparameter tuning\n\n#### Model Selection Decision Tree\n\n```\nStart\n├─ High-dimensional data (p > n)?\n│  ├─ Yes → CoxnetSurvivalAnalysis (elastic net)\n│  └─ No → Continue\n│\n├─ Need interpretable coefficients?\n│  ├─ Yes → CoxPHSurvivalAnalysis or ComponentwiseGradientBoostingSurvivalAnalysis\n│  └─ No → Continue\n│\n├─ Complex non-linear relationships expected?\n│  ├─ Yes\n│  │  ├─ Large dataset (n > 1000) → GradientBoostingSurvivalAnalysis\n│  │  ├─ Medium dataset → RandomSurvivalForest or FastKernelSurvivalSVM\n│  │  └─ Small dataset → RandomSurvivalForest\n│  └─ No → CoxPHSurvivalAnalysis or FastSurvivalSVM\n│\n└─ For maximum performance → Try multiple models and compare\n```\n\n### 2. Data Preparation and Preprocessing\n\nBefore modeling, properly prepare survival data:\n\n#### Creating Survival Outcomes\n```python\nfrom sksurv.util import Surv\n\n# From separate arrays\ny = Surv.from_arrays(event=event_array, time=time_array)\n\n# From DataFrame\ny = Surv.from_dataframe('event', 'time', df)\n```\n\n#### Essential Preprocessing Steps\n1. **Handle missing values**: Imputation strategies for features\n2. **Encode categorical variables**: One-hot encoding or label encoding\n3. **Standardize features**: Critical for SVMs and regularized Cox models\n4. **Validate data quality**: Check for negative times, sufficient events per feature\n5. **Train-test split**: Maintain similar censoring rates across splits\n\n**See**: `references\u002Fdata-handling.md` for complete preprocessing workflows, data validation, and best practices\n\n### 3. Model Evaluation\n\nProper evaluation is critical for survival models. Use appropriate metrics that account for censoring:\n\n#### Concordance Index (C-index)\nPrimary metric for ranking\u002Fdiscrimination:\n- **Harrell's C-index**: Use for low censoring (\u003C40%)\n- **Uno's C-index**: Use for moderate to high censoring (>40%) - more robust\n\n```python\nfrom sksurv.metrics import concordance_index_censored, concordance_index_ipcw\n\n# Harrell's C-index\nc_harrell = concordance_index_censored(y_test['event'], y_test['time'], risk_scores)[0]\n\n# Uno's C-index (recommended)\nc_uno = concordance_index_ipcw(y_train, y_test, risk_scores)[0]\n```\n\n#### Time-Dependent AUC\nEvaluate discrimination at specific time points:\n\n```python\nfrom sksurv.metrics import cumulative_dynamic_auc\n\ntimes = [365, 730, 1095]  # 1, 2, 3 years\nauc, mean_auc = cumulative_dynamic_auc(y_train, y_test, risk_scores, times)\n```\n\n#### Brier Score\nAssess both discrimination and calibration:\n\n```python\nfrom sksurv.metrics import integrated_brier_score\n\nibs = integrated_brier_score(y_train, y_test, survival_functions, times)\n```\n\n**See**: `references\u002Fevaluation-metrics.md` for comprehensive evaluation guidance, metric selection, and using scorers with cross-validation\n\n### 4. Competing Risks Analysis\n\nHandle situations with multiple mutually exclusive event types:\n\n```python\nfrom sksurv.nonparametric import cumulative_incidence_competing_risks\n\n# Estimate cumulative incidence for each event type\ntime_points, cif_event1, cif_event2 = cumulative_incidence_competing_risks(y)\n```\n\n**Use competing risks when**:\n- Multiple mutually exclusive event types exist (e.g., death from different causes)\n- Occurrence of one event prevents others\n- Need probability estimates for specific event types\n\n**See**: `references\u002Fcompeting-risks.md` for detailed competing risks methods, cause-specific hazard models, and interpretation\n\n### 5. Non-parametric Estimation\n\nEstimate survival functions without parametric assumptions:\n\n#### Kaplan-Meier Estimator\n```python\nfrom sksurv.nonparametric import kaplan_meier_estimator\n\ntime, survival_prob = kaplan_meier_estimator(y['event'], y['time'])\n```\n\n#### Nelson-Aalen Estimator\n```python\nfrom sksurv.nonparametric import nelson_aalen_estimator\n\ntime, cumulative_hazard = nelson_aalen_estimator(y['event'], y['time'])\n```\n\n## Typical Workflows\n\n### Workflow 1: Standard Survival Analysis\n\n```python\nfrom sksurv.datasets import load_breast_cancer\nfrom sksurv.linear_model import CoxPHSurvivalAnalysis\nfrom sksurv.metrics import concordance_index_ipcw\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\n\n# 1. Load and prepare data\nX, y = load_breast_cancer()\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n\n# 2. Preprocess\nscaler = StandardScaler()\nX_train_scaled = scaler.fit_transform(X_train)\nX_test_scaled = scaler.transform(X_test)\n\n# 3. Fit model\nestimator = CoxPHSurvivalAnalysis()\nestimator.fit(X_train_scaled, y_train)\n\n# 4. Predict\nrisk_scores = estimator.predict(X_test_scaled)\n\n# 5. Evaluate\nc_index = concordance_index_ipcw(y_train, y_test, risk_scores)[0]\nprint(f\"C-index: {c_index:.3f}\")\n```\n\n### Workflow 2: High-Dimensional Data with Feature Selection\n\n```python\nfrom sksurv.linear_model import CoxnetSurvivalAnalysis\nfrom sklearn.model_selection import GridSearchCV\nfrom sksurv.metrics import as_concordance_index_ipcw_scorer\n\n# 1. Use penalized Cox for feature selection\nestimator = CoxnetSurvivalAnalysis(l1_ratio=0.9)  # Lasso-like\n\n# 2. Tune regularization with cross-validation\nparam_grid = {'alpha_min_ratio': [0.01, 0.001]}\ncv = GridSearchCV(estimator, param_grid,\n                  scoring=as_concordance_index_ipcw_scorer(), cv=5)\ncv.fit(X, y)\n\n# 3. Identify selected features\nbest_model = cv.best_estimator_\nselected_features = np.where(best_model.coef_ != 0)[0]\n```\n\n### Workflow 3: Ensemble Method for Maximum Performance\n\n```python\nfrom sksurv.ensemble import GradientBoostingSurvivalAnalysis\nfrom sklearn.model_selection import GridSearchCV\n\n# 1. Define parameter grid\nparam_grid = {\n    'learning_rate': [0.01, 0.05, 0.1],\n    'n_estimators': [100, 200, 300],\n    'max_depth': [3, 5, 7]\n}\n\n# 2. Grid search\ngbs = GradientBoostingSurvivalAnalysis()\ncv = GridSearchCV(gbs, param_grid, cv=5,\n                  scoring=as_concordance_index_ipcw_scorer(), n_jobs=-1)\ncv.fit(X_train, y_train)\n\n# 3. Evaluate best model\nbest_model = cv.best_estimator_\nrisk_scores = best_model.predict(X_test)\nc_index = concordance_index_ipcw(y_train, y_test, risk_scores)[0]\n```\n\n### Workflow 4: Comprehensive Model Comparison\n\n```python\nfrom sksurv.linear_model import CoxPHSurvivalAnalysis\nfrom sksurv.ensemble import RandomSurvivalForest, GradientBoostingSurvivalAnalysis\nfrom sksurv.svm import FastSurvivalSVM\nfrom sksurv.metrics import concordance_index_ipcw, integrated_brier_score\n\n# Define models\nmodels = {\n    'Cox': CoxPHSurvivalAnalysis(),\n    'RSF': RandomSurvivalForest(n_estimators=100, random_state=42),\n    'GBS': GradientBoostingSurvivalAnalysis(random_state=42),\n    'SVM': FastSurvivalSVM(random_state=42)\n}\n\n# Evaluate each model\nresults = {}\nfor name, model in models.items():\n    model.fit(X_train_scaled, y_train)\n    risk_scores = model.predict(X_test_scaled)\n    c_index = concordance_index_ipcw(y_train, y_test, risk_scores)[0]\n    results[name] = c_index\n    print(f\"{name}: C-index = {c_index:.3f}\")\n\n# Select best model\nbest_model_name = max(results, key=results.get)\nprint(f\"\\nBest model: {best_model_name}\")\n```\n\n## Integration with scikit-learn\n\nscikit-survival fully integrates with scikit-learn's ecosystem:\n\n```python\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.model_selection import cross_val_score, GridSearchCV\n\n# Use pipelines\npipeline = Pipeline([\n    ('scaler', StandardScaler()),\n    ('model', CoxPHSurvivalAnalysis())\n])\n\n# Use cross-validation\nscores = cross_val_score(pipeline, X, y, cv=5,\n                         scoring=as_concordance_index_ipcw_scorer())\n\n# Use grid search\nparam_grid = {'model__alpha': [0.1, 1.0, 10.0]}\ncv = GridSearchCV(pipeline, param_grid, cv=5)\ncv.fit(X, y)\n```\n\n## Best Practices\n\n1. **Always standardize features** for SVMs and regularized Cox models\n2. **Use Uno's C-index** instead of Harrell's when censoring > 40%\n3. **Report multiple evaluation metrics** (C-index, integrated Brier score, time-dependent AUC)\n4. **Check proportional hazards assumption** for Cox models\n5. **Use cross-validation** for hyperparameter tuning with appropriate scorers\n6. **Validate data quality** before modeling (check for negative times, sufficient events per feature)\n7. **Compare multiple model types** to find best performance\n8. **Use permutation importance** for Random Survival Forests (not built-in importance)\n9. **Consider competing risks** when multiple event types exist\n10. **Document censoring mechanism** and rates in analysis\n\n## Common Pitfalls to Avoid\n\n1. **Using Harrell's C-index with high censoring** → Use Uno's C-index\n2. **Not standardizing features for SVMs** → Always standardize\n3. **Forgetting to pass y_train to concordance_index_ipcw** → Required for IPCW calculation\n4. **Treating competing events as censored** → Use competing risks methods\n5. **Not checking for sufficient events per feature** → Rule of thumb: 10+ events per feature\n6. **Using built-in feature importance for RSF** → Use permutation importance\n7. **Ignoring proportional hazards assumption** → Validate or use alternative models\n8. **Not using appropriate scorers in cross-validation** → Use as_concordance_index_ipcw_scorer()\n\n## Reference Files\n\nThis skill includes detailed reference files for specific topics:\n\n- **`references\u002Fcox-models.md`**: Complete guide to Cox proportional hazards models, penalized Cox (CoxNet), IPCRidge, regularization strategies, and interpretation\n- **`references\u002Fensemble-models.md`**: Random Survival Forests, Gradient Boosting, hyperparameter tuning, feature importance, and model selection\n- **`references\u002Fevaluation-metrics.md`**: Concordance index (Harrell's vs Uno's), time-dependent AUC, Brier score, comprehensive evaluation pipelines\n- **`references\u002Fdata-handling.md`**: Data loading, preprocessing workflows, handling missing data, feature encoding, validation checks\n- **`references\u002Fsvm-models.md`**: Survival Support Vector Machines, kernel selection, clinical kernel transform, hyperparameter tuning\n- **`references\u002Fcompeting-risks.md`**: Competing risks analysis, cumulative incidence functions, cause-specific hazard models\n\nLoad these reference files when detailed information is needed for specific tasks.\n\n## Additional Resources\n\n- **Official Documentation**: https:\u002F\u002Fscikit-survival.readthedocs.io\u002F\n- **GitHub Repository**: https:\u002F\u002Fgithub.com\u002Fsebp\u002Fscikit-survival\n- **Built-in Datasets**: Use `sksurv.datasets` for practice datasets (GBSG2, WHAS500, veterans lung cancer, etc.)\n- **API Reference**: Complete list of classes and functions at https:\u002F\u002Fscikit-survival.readthedocs.io\u002Fen\u002Fstable\u002Fapi\u002Findex.html\n\n## Quick Reference: Key Imports\n\n```python\n# Models\nfrom sksurv.linear_model import CoxPHSurvivalAnalysis, CoxnetSurvivalAnalysis, IPCRidge\nfrom sksurv.ensemble import RandomSurvivalForest, GradientBoostingSurvivalAnalysis\nfrom sksurv.svm import FastSurvivalSVM, FastKernelSurvivalSVM\nfrom sksurv.tree import SurvivalTree\n\n# Evaluation metrics\nfrom sksurv.metrics import (\n    concordance_index_censored,\n    concordance_index_ipcw,\n    cumulative_dynamic_auc,\n    brier_score,\n    integrated_brier_score,\n    as_concordance_index_ipcw_scorer,\n    as_integrated_brier_score_scorer\n)\n\n# Non-parametric estimation\nfrom sksurv.nonparametric import (\n    kaplan_meier_estimator,\n    nelson_aalen_estimator,\n    cumulative_incidence_competing_risks\n)\n\n# Data handling\nfrom sksurv.util import Surv\nfrom sksurv.preprocessing import OneHotEncoder, encode_categorical\nfrom sksurv.datasets import load_gbsg2, load_breast_cancer, load_veterans_lung_cancer\n\n# Kernels\nfrom sksurv.kernels import ClinicalKernelTransform\n```\n","# scikit-survival: Survival Analysis in Python\n\n## Overview\n\nscikit-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.\n\nSurvival 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).\n\n## When to Use This Skill\n\nUse this skill when:\n- Performing survival analysis or time-to-event modeling\n- Working with censored data (right-censored, left-censored, or interval-censored)\n- Fitting Cox proportional hazards models (standard or penalized)\n- Building ensemble survival models (Random Survival Forests, Gradient Boosting)\n- Training Survival Support Vector Machines\n- Evaluating survival model performance (concordance index, Brier score, time-dependent AUC)\n- Estimating Kaplan-Meier or Nelson-Aalen curves\n- Analyzing competing risks\n- Preprocessing survival data or handling missing values in survival datasets\n- Conducting any analysis using the scikit-survival library\n\n## Core Capabilities\n\n### 1. Model Types and Selection\n\nscikit-survival provides multiple model families, each suited for different scenarios:\n\n#### Cox Proportional Hazards Models\n**Use for**: Standard survival analysis with interpretable coefficients\n- `CoxPHSurvivalAnalysis`: Basic Cox model\n- `CoxnetSurvivalAnalysis`: Penalized Cox with elastic net for high-dimensional data\n- `IPCRidge`: Ridge regression for accelerated failure time models\n\n**See**: `references\u002Fcox-models.md` for detailed guidance on Cox models, regularization, and interpretation\n\n#### Ensemble Methods\n**Use for**: High predictive performance with complex non-linear relationships\n- `RandomSurvivalForest`: Robust, non-parametric ensemble method\n- `GradientBoostingSurvivalAnalysis`: Tree-based boosting for maximum performance\n- `ComponentwiseGradientBoostingSurvivalAnalysis`: Linear boosting with feature selection\n- `ExtraSurvivalTrees`: Extremely randomized trees for additional regularization\n\n**See**: `references\u002Fensemble-models.md` for comprehensive guidance on ensemble methods, hyperparameter tuning, and when to use each model\n\n#### Survival Support Vector Machines\n**Use for**: Medium-sized datasets with margin-based learning\n- `FastSurvivalSVM`: Linear SVM optimized for speed\n- `FastKernelSurvivalSVM`: Kernel SVM for non-linear relationships\n- `HingeLossSurvivalSVM`: SVM with hinge loss\n- `ClinicalKernelTransform`: Specialized kernel for clinical + molecular data\n\n**See**: `references\u002Fsvm-models.md` for detailed SVM guidance, kernel selection, and hyperparameter tuning\n\n#### Model Selection Decision Tree\n\n```\nStart\n├─ High-dimensional data (p > n)?\n│  ├─ Yes → CoxnetSurvivalAnalysis (elastic net)\n│  └─ No → Continue\n│\n├─ Need interpretable coefficients?\n│  ├─ Yes → CoxPHSurvivalAnalysis or ComponentwiseGradientBoostingSurvivalAnalysis\n│  └─ No → Continue\n│\n├─ Complex non-linear relationships expected?\n│  ├─ Yes\n│  │  ├─ Large dataset (n > 1000) → GradientBoostingSurvivalAnalysis\n│  │  ├─ Medium dataset → RandomSurvivalForest or FastKernelSurvivalSVM\n│  │  └─ Small dataset → RandomSurvivalForest\n│  └─ No → CoxPHSurvivalAnalysis or FastSurvivalSVM\n│\n└─ For maximum performance → Try multiple models and compare\n```\n\n### 2. Data Preparation and Preprocessing\n\nBefore modeling, properly prepare survival data:\n\n#### Creating Survival Outcomes\n```python\nfrom sksurv.util import Surv\n\n# From separate arrays\ny = Surv.from_arrays(event=event_array, time=time_array)\n\n# From DataFrame\ny = Surv.from_dataframe('event', 'time', df)\n```\n\n#### Essential Preprocessing Steps\n1. **Handle missing values**: Imputation strategies for features\n2. **Encode categorical variables**: One-hot encoding or label encoding\n3. **Standardize features**: Critical for SVMs and regularized Cox models\n4. **Validate data quality**: Check for negative times, sufficient events per feature\n5. **Train-test split**: Maintain similar censoring rates across splits\n\n**See**: `references\u002Fdata-handling.md` for complete preprocessing workflows, data validation, and best practices\n\n### 3. Model Evaluation\n\nProper evaluation is critical for survival models. Use appropriate metrics that account for censoring:\n\n#### Concordance Index (C-index)\nPrimary metric for ranking\u002Fdiscrimination:\n- **Harrell's C-index**: Use for low censoring (\u003C40%)\n- **Uno's C-index**: Use for moderate to high censoring (>40%) - more robust\n\n```python\nfrom sksurv.metrics import concordance_index_censored, concordance_index_ipcw\n\n# Harrell's C-index\nc_harrell = concordance_index_censored(y_test['event'], y_test['time'], risk_scores)[0]\n\n# Uno's C-index (recommended)\nc_uno = concordance_index_ipcw(y_train, y_test, risk_scores)[0]\n```\n\n#### Time-Dependent AUC\nEvaluate discrimination at specific time points:\n\n```python\nfrom sksurv.metrics import cumulative_dynamic_auc\n\ntimes = [365, 730, 1095]  # 1, 2, 3 years\nauc, mean_auc = cumulative_dynamic_auc(y_train, y_test, risk_scores, times)\n```\n\n#### Brier Score\nAssess both discrimination and calibration:\n\n```python\nfrom sksurv.metrics import integrated_brier_score\n\nibs = integrated_brier_score(y_train, y_test, survival_functions, times)\n```\n\n**See**: `references\u002Fevaluation-metrics.md` for comprehensive evaluation guidance, metric selection, and using scorers with cross-validation\n\n### 4. Competing Risks Analysis\n\nHandle situations with multiple mutually exclusive event types:\n\n```python\nfrom sksurv.nonparametric import cumulative_incidence_competing_risks\n\n# Estimate cumulative incidence for each event type\ntime_points, cif_event1, cif_event2 = cumulative_incidence_competing_risks(y)\n```\n\n**Use competing risks when**:\n- Multiple mutually exclusive event types exist (e.g., death from different causes)\n- Occurrence of one event prevents others\n- Need probability estimates for specific event types\n\n**See**: `references\u002Fcompeting-risks.md` for detailed competing risks methods, cause-specific hazard models, and interpretation\n\n### 5. Non-parametric Estimation\n\nEstimate survival functions without parametric assumptions:\n\n#### Kaplan-Meier Estimator\n```python\nfrom sksurv.nonparametric import kaplan_meier_estimator\n\ntime, survival_prob = kaplan_meier_estimator(y['event'], y['time'])\n```\n\n#### Nelson-Aalen Estimator\n```python\nfrom sksurv.nonparametric import nelson_aalen_estimator\n\ntime, cumulative_hazard = nelson_aalen_estimator(y['event'], y['time'])\n```\n\n## Typical Workflows\n\n### Workflow 1: Standard Survival Analysis\n\n```python\nfrom sksurv.datasets import load_breast_cancer\nfrom sksurv.linear_model import CoxPHSurvivalAnalysis\nfrom sksurv.metrics import concordance_index_ipcw\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\n\n# 1. Load and prepare data\nX, y = load_breast_cancer()\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n\n# 2. Preprocess\nscaler = StandardScaler()\nX_train_scaled = scaler.fit_transform(X_train)\nX_test_scaled = scaler.transform(X_test)\n\n# 3. Fit model\nestimator = CoxPHSurvivalAnalysis()\nestimator.fit(X_train_scaled, y_train)\n\n# 4. Predict\nrisk_scores = estimator.predict(X_test_scaled)\n\n# 5. Evaluate\nc_index = concordance_index_ipcw(y_train, y_test, risk_scores)[0]\nprint(f\"C-index: {c_index:.3f}\")\n```\n\n### Workflow 2: High-Dimensional Data with Feature Selection\n\n```python\nfrom sksurv.linear_model import CoxnetSurvivalAnalysis\nfrom sklearn.model_selection import GridSearchCV\nfrom sksurv.metrics import as_concordance_index_ipcw_scorer\n\n# 1. Use penalized Cox for feature selection\nestimator = CoxnetSurvivalAnalysis(l1_ratio=0.9)  # Lasso-like\n\n# 2. Tune regularization with cross-validation\nparam_grid = {'alpha_min_ratio': [0.01, 0.001]}\ncv = GridSearchCV(estimator, param_grid,\n                  scoring=as_concordance_index_ipcw_scorer(), cv=5)\ncv.fit(X, y)\n\n# 3. Identify selected features\nbest_model = cv.best_estimator_\nselected_features = np.where(best_model.coef_ != 0)[0]\n```\n\n### Workflow 3: Ensemble Method for Maximum Performance\n\n```python\nfrom sksurv.ensemble import GradientBoostingSurvivalAnalysis\nfrom sklearn.model_selection import GridSearchCV\n\n# 1. Define parameter grid\nparam_grid = {\n    'learning_rate': [0.01, 0.05, 0.1],\n    'n_estimators': [100, 200, 300],\n    'max_depth': [3, 5, 7]\n}\n\n# 2. Grid search\ngbs = GradientBoostingSurvivalAnalysis()\ncv = GridSearchCV(gbs, param_grid, cv=5,\n                  scoring=as_concordance_index_ipcw_scorer(), n_jobs=-1)\ncv.fit(X_train, y_train)\n\n# 3. Evaluate best model\nbest_model = cv.best_estimator_\nrisk_scores = best_model.predict(X_test)\nc_index = concordance_index_ipcw(y_train, y_test, risk_scores)[0]\n```\n\n### Workflow 4: Comprehensive Model Comparison\n\n```python\nfrom sksurv.linear_model import CoxPHSurvivalAnalysis\nfrom sksurv.ensemble import RandomSurvivalForest, GradientBoostingSurvivalAnalysis\nfrom sksurv.svm import FastSurvivalSVM\nfrom sksurv.metrics import concordance_index_ipcw, integrated_brier_score\n\n# Define models\nmodels = {\n    'Cox': CoxPHSurvivalAnalysis(),\n    'RSF': RandomSurvivalForest(n_estimators=100, random_state=42),\n    'GBS': GradientBoostingSurvivalAnalysis(random_state=42),\n    'SVM': FastSurvivalSVM(random_state=42)\n}\n\n# Evaluate each model\nresults = {}\nfor name, model in models.items():\n    model.fit(X_train_scaled, y_train)\n    risk_scores = model.predict(X_test_scaled)\n    c_index = concordance_index_ipcw(y_train, y_test, risk_scores)[0]\n    results[name] = c_index\n    print(f\"{name}: C-index = {c_index:.3f}\")\n\n# Select best model\nbest_model_name = max(results, key=results.get)\nprint(f\"\\nBest model: {best_model_name}\")\n```\n\n## Integration with scikit-learn\n\nscikit-survival fully integrates with scikit-learn's ecosystem:\n\n```python\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.model_selection import cross_val_score, GridSearchCV\n\n# Use pipelines\npipeline = Pipeline([\n    ('scaler', StandardScaler()),\n    ('model', CoxPHSurvivalAnalysis())\n])\n\n# Use cross-validation\nscores = cross_val_score(pipeline, X, y, cv=5,\n                         scoring=as_concordance_index_ipcw_scorer())\n\n# Use grid search\nparam_grid = {'model__alpha': [0.1, 1.0, 10.0]}\ncv = GridSearchCV(pipeline, param_grid, cv=5)\ncv.fit(X, y)\n```\n\n## Best Practices\n\n1. **Always standardize features** for SVMs and regularized Cox models\n2. **Use Uno's C-index** instead of Harrell's when censoring > 40%\n3. **Report multiple evaluation metrics** (C-index, integrated Brier score, time-dependent AUC)\n4. **Check proportional hazards assumption** for Cox models\n5. **Use cross-validation** for hyperparameter tuning with appropriate scorers\n6. **Validate data quality** before modeling (check for negative times, sufficient events per feature)\n7. **Compare multiple model types** to find best performance\n8. **Use permutation importance** for Random Survival Forests (not built-in importance)\n9. **Consider competing risks** when multiple event types exist\n10. **Document censoring mechanism** and rates in analysis\n\n## Common Pitfalls to Avoid\n\n1. **Using Harrell's C-index with high censoring** → Use Uno's C-index\n2. **Not standardizing features for SVMs** → Always standardize\n3. **Forgetting to pass y_train to concordance_index_ipcw** → Required for IPCW calculation\n4. **Treating competing events as censored** → Use competing risks methods\n5. **Not checking for sufficient events per feature** → Rule of thumb: 10+ events per feature\n6. **Using built-in feature importance for RSF** → Use permutation importance\n7. **Ignoring proportional hazards assumption** → Validate or use alternative models\n8. **Not using appropriate scorers in cross-validation** → Use as_concordance_index_ipcw_scorer()\n\n## Reference Files\n\nThis skill includes detailed reference files for specific topics:\n\n- **`references\u002Fcox-models.md`**: Complete guide to Cox proportional hazards models, penalized Cox (CoxNet), IPCRidge, regularization strategies, and interpretation\n- **`references\u002Fensemble-models.md`**: Random Survival Forests, Gradient Boosting, hyperparameter tuning, feature importance, and model selection\n- **`references\u002Fevaluation-metrics.md`**: Concordance index (Harrell's vs Uno's), time-dependent AUC, Brier score, comprehensive evaluation pipelines\n- **`references\u002Fdata-handling.md`**: Data loading, preprocessing workflows, handling missing data, feature encoding, validation checks\n- **`references\u002Fsvm-models.md`**: Survival Support Vector Machines, kernel selection, clinical kernel transform, hyperparameter tuning\n- **`references\u002Fcompeting-risks.md`**: Competing risks analysis, cumulative incidence functions, cause-specific hazard models\n\nLoad these reference files when detailed information is needed for specific tasks.\n\n## Additional Resources\n\n- **Official Documentation**: https:\u002F\u002Fscikit-survival.readthedocs.io\u002F\n- **GitHub Repository**: https:\u002F\u002Fgithub.com\u002Fsebp\u002Fscikit-survival\n- **Built-in Datasets**: Use `sksurv.datasets` for practice datasets (GBSG2, WHAS500, veterans lung cancer, etc.)\n- **API Reference**: Complete list of classes and functions at https:\u002F\u002Fscikit-survival.readthedocs.io\u002Fen\u002Fstable\u002Fapi\u002Findex.html\n\n## Quick Reference: Key Imports\n\n```python\n# Models\nfrom sksurv.linear_model import CoxPHSurvivalAnalysis, CoxnetSurvivalAnalysis, IPCRidge\nfrom sksurv.ensemble import RandomSurvivalForest, GradientBoostingSurvivalAnalysis\nfrom sksurv.svm import FastSurvivalSVM, FastKernelSurvivalSVM\nfrom sksurv.tree import SurvivalTree\n\n# Evaluation metrics\nfrom sksurv.metrics import (\n    concordance_index_censored,\n    concordance_index_ipcw,\n    cumulative_dynamic_auc,\n    brier_score,\n    integrated_brier_score,\n    as_concordance_index_ipcw_scorer,\n    as_integrated_brier_score_scorer\n)\n\n# Non-parametric estimation\nfrom sksurv.nonparametric import (\n    kaplan_meier_estimator,\n    nelson_aalen_estimator,\n    cumulative_incidence_competing_risks\n)\n\n# Data handling\nfrom sksurv.util import Surv\nfrom sksurv.preprocessing import OneHotEncoder, encode_categorical\nfrom sksurv.datasets import load_gbsg2, load_breast_cancer, load_veterans_lung_cancer\n\n# Kernels\nfrom sksurv.kernels import ClinicalKernelTransform\n```\n",{"name":5,"description":7},"main","f2ec4b3b9133d34eeaf9b38e4b0a97e8e5705a7f","benchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival",0,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard","https:\u002F\u002Fgithub.com\u002FJSGforever","2026-08-29 18:27:56",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add JSGforever\u002Fskillguard --skill scikit-survival",{"tool":61,"command":62},"bunx","bunx skills add JSGforever\u002Fskillguard --skill scikit-survival",{"tool":64,"command":65},"pnpm","pnpm dlx skills add JSGforever\u002Fskillguard --skill scikit-survival","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival\u002FSKILL.md",true,[69,75,79,83,87,91],{"path":70,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fcompeting-risks.md","REFERENCE","参考文档",11986,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival\u002Freferences\u002Fcompeting-risks.md",{"path":76,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fcox-models.md",5238,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival\u002Freferences\u002Fcox-models.md",{"path":80,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fdata-handling.md",12094,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival\u002Freferences\u002Fdata-handling.md",{"path":84,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fensemble-models.md",9529,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival\u002Freferences\u002Fensemble-models.md",{"path":88,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fevaluation-metrics.md",10850,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival\u002Freferences\u002Fevaluation-metrics.md",{"path":92,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Fsvm-models.md",11096,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__Microck--claude-scientific-skills\u002Fscientific-skills\u002Fscikit-survival\u002Freferences\u002Fsvm-models.md",[96,123,138,164,186,207],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":103,"publishedAt":43},"01M71HY2SNXBA9Q00WZDTZQ31Z","skillguard-codex-scanner","Hybrid deterministic+LLM agent-skill security scanner. Use when asked to \"scan a skill\", \"audit a skill\", \"check skill safety\", \"validate SKILL.md\", \"is this skill safe to install\", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fsrc\u002Fskillguard\u002Fstatic_scanner\u002Fskillguard-codex-scanner\u002FSKILL.md",[102],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[104,105,106,107,108,109,110,111,112,113,114,115,40,116,117,118,119,120,121,122],"scanner","skillguard codex scanner","skillguard","codex","chain","skill security","security-review","review report","structural","secret","prompt injection","security scanner","review","malicious","permissions","exposure","audit","scripts","safe",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":127,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":135,"publishedAt":43},"01M71HY0SPKTT3S27BC2HPAC5M","data-exfiltrator","Analyzes data files","MIT","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Fsmoke-one-skill\u002Fasset1__cisco-ai-defense--data-exfiltrator\u002FSKILL.md",[130],{"categoryNo":131,"categoryName":132,"taxonomyType":133,"taxonomyTypeDesc":134},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[34,136,137],"data exfiltrator","files",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":43},"01M71HXVS9EMN44BGDW215FZ72","real-time-collaboration-engine","Build real-time collaborative editing with WebSockets, OT\u002FCRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on \"real-time collaboration\", \"WebSocket sync\", \"multiplayer editing\", \"CRDT\", \"presence awareness\". NOT for simple chat, request-response APIs, or single-user apps.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--real-time-collaboration-engine\u002FSKILL.md",[],[42,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163],"real time collaboration engine","real time collaboration","collaboration","engine","real time","Video","reliability","video editing","performance","conflict resolution","presence","access","apps","updates","Bash","activate","optimizer","react","streaming",{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":173,"publishedAt":43},"01M71HXP6CTY4KFN0QVMMN0V7J","react-performance-optimizer","Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on \"React performance\", \"slow render\", \"useMemo\", \"bundle size\", \"virtualization\". NOT for backend optimization, non-React frameworks, or premature optimization.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--react-performance-optimizer\u002FSKILL.md",[170],{"categoryNo":171,"categoryName":172,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000009","前端开发",[153,174,161,162,175,176,177,178,179,180,42,181,182,157,159,183,160,163,184,185],"react performance optimizer","react performance","performance optimizer","app","nextjs","expert","re","render","2025","code","router","strategies",{"skillNo":187,"name":188,"nameZh":6,"description":189,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":190,"categories":191,"keywords":193,"publishedAt":43},"01M71HXH7QXSQB4QTDZ7SP7YXQ","llm-streaming-response-handler","Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI\u002FAnthropic\u002FClaude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on \"LLM streaming\", \"SSE\", \"token stream\", \"chat UI\", \"real-time AI\". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--llm-streaming-response-handler\u002FSKILL.md",[192],{"categoryNo":171,"categoryName":172,"taxonomyType":20,"taxonomyTypeDesc":21},[194,163,195,196,197,198,153,42,199,200,201,159,160,161,202,162,203,204,205,206],"llm streaming response handler","handler","error","processing","retry","chat ui","error recovery","critical","batch","display","text","server","read",{"skillNo":208,"name":209,"nameZh":6,"description":210,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":211,"categories":212,"keywords":220,"publishedAt":43},"01M71HXCB0E1YRKYW1Y8T0Y106","github-actions-pipeline-builder","Build production CI\u002FCD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on \"GitHub Actions\", \"CI\u002FCD\", \"workflow\", \"deployment pipeline\", \"automated testing\". NOT for Jenkins\u002FCircleCI, manual deployments, or non-GitHub repositories.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--github-actions-pipeline-builder\u002FSKILL.md",[213,216,219],{"categoryNo":214,"categoryName":215,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":217,"categoryName":218,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000011","运维与部署",{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[221,222,223,224,225,226,227,151,179,228,229,230,160,185,231,206,232,233,234,235],"github actions pipeline builder","actions","github actions","pipeline builder","github","builder","pipeline","testing","ci","workflows","run","release","write","edit","git"]