Model-agnostic explainability for survival analysis models.
Project description
pysurvex
Model-agnostic explainability for survival analysis models in Python.
pysurvex is a Python adaptation of the R package
survex. Its goal is to provide a
unified, model-agnostic interface for explaining the predictions of survival
analysis models (Cox PH, Random Survival Forests, DeepSurv, etc.) using
time-dependent variants of popular interpretability methods.
Supported models
Auto-detected (no configuration needed):
- scikit-survival
CoxPHSurvivalAnalysis - scikit-survival
RandomSurvivalForest - pycox DeepSurv (
pycox.models.CoxPH)
Any other survival model is supported by supplying a manual
predict_survival_function override (see below).
Roadmap
Currently implemented xAI methods:
- Partial Dependence Profiles (PDP) — via
model_profile(..., method="pdp") - Accumulated Local Effects (ALE) — via
model_profile(..., method="ale") - Individual Conditional Expectation (ICE) — via
predict_profile(...)
Methods to be implemented
- SurvLIME
- SurvSHAP
Installation
For local development:
git clone https://github.com/vedvatsal3/pysurvex.git
cd pysurvex
pip install -e ".[dev]"
Runtime dependencies: numpy, pandas, scikit-survival, scikit-learn.
matplotlib is additionally required only when you call a result object's
.plot() method — the numeric layer (computing PDP / ICE / ALE matrices) needs
only numpy, pandas, and scikit-survival.
Supplying a custom prediction interface
For models that are not auto-detected, pass a predict_survival_function with
the signature (model, X, times) -> np.ndarray of shape (n_obs, n_times):
def my_predict(model, X, times):
# e.g. wrap pycox, lifelines, torchsurv, ...
return model.survival_matrix(X, times)
explainer = SurvivalExplainer(
model=my_model,
data=X,
y=y,
predict_survival_function=my_predict,
)
References
- R package: https://modeloriented.github.io/survex/
- Paper: Spytek et al., survex: an R package for explaining machine learning survival models, Bioinformatics, 2023.
License
MIT -- see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysurvex-0.1.2.tar.gz.
File metadata
- Download URL: pysurvex-0.1.2.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
962b0132a1c74965e8400b7514602cf6b3623492123c1807091ca5bce624ab83
|
|
| MD5 |
f6551d833dfc9949ded5e3b4c6146cd0
|
|
| BLAKE2b-256 |
6f7c95f4445a24e842306828131f55ccb5db90ff075e79b96b67b243d07b06b7
|
File details
Details for the file pysurvex-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pysurvex-0.1.2-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5dabbd71d3db556e9241fbbd5f29a51966b5a41858c846c605e9f4983cebf34
|
|
| MD5 |
f5560a1b934773f8967ad50c8117afde
|
|
| BLAKE2b-256 |
623eb8069798e5ea15771abd93c302dbfadb717ca084a6f9e9936e558dab0ef1
|