Scikit survival cox

From XuShuwenn/RedAct · View interactive version

Scikit survival cox is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Fit Cox proportional hazards model to survival data using scikit-survival and extract concordance index.

How to use this skill

Skill file

Cox Proportional Hazards Model

When to Use

Input

File /root/input.csv with columns:

Output Format

To /root/output.txt:

Concordance index: X.XXXX

Round to 4 decimal places.

After writing /root/output.txt, read it back and confirm it exactly matches the required single-line format: Concordance index: X.XXXX.

Using scikit-survival

from scikit-survival import CoxPHSurvivalAnalysis


**Required model fidelity**
- If the task asks for a Cox proportional hazards model, use `CoxPHSurvivalAnalysis()` with default settings unless the task explicitly permits changes.
- Do **not** switch to `CoxnetSurvivalAnalysis` or another survival model, and do not silently add regularization or change hyperparameters just because warnings appear.
- If `fit()` emits warnings, treat them as investigation signals, not automatic failure: first check whether `model.fit(X, y)` completed and whether `model.score(X, y)` returns a valid concordance index before trying any workaround.

from sksurv.util import Surv
from sksurv.metrics import concordance_index_censored


# Fit model
model.fit(X, y)
c_index = model.score(X, y)

Concordance Index

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.