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.
Metadata
Release files for pysurvex 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysurvex-0.1.2.tar.gz | 26.2 kB | Without provenance | Details for pysurvex-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pysurvex-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for pysurvex-0.1.2-py3-none-any.whl |
Total release size: 49.0 kB
Release files / pysurvex-0.1.2.tar.gz
| Download URL | pysurvex-0.1.2.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
962b0132a1c74965e8400b7514602cf6b3623492123c1807091ca5bce624ab83
|
|
BLAKE2b-256 checksum How to use checksums |
6f7c95f4445a24e842306828131f55ccb5db90ff075e79b96b67b243d07b06b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / pysurvex-0.1.2-py3-none-any.whl
| Download URL | pysurvex-0.1.2-py3-none-any.whl |
|---|---|
| Size | 22.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5dabbd71d3db556e9241fbbd5f29a51966b5a41858c846c605e9f4983cebf34
|
|
BLAKE2b-256 checksum How to use checksums |
623eb8069798e5ea15771abd93c302dbfadb717ca084a6f9e9936e558dab0ef1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for pysurvex 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.