Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

torch-survival Logo

torch-survival: A PyTorch-based library for Deep Survival Analysis

docs

torch-survival is a library built upon PyTorch and scikit-survival to make survival analysis using deep learning more accessible.

It's main goal is to implement a diverse set of deep learning methods for survival analysis using scikit-survival's API design, thus offering an improved out-of-box experience compared to existing libraries (see alternatives). In addition, it provides many common loss functions and metrics that may also be used standalone in other PyTorch-based projects.

Installation

torch-survival is available from PyPI and only depends on PyTorch, scikit-survival, and (for now) pycox. To install:

pip install torch-survival

For now only alpha releases are available.

Getting Started

Since the API design of torch-survival closely mimics that of scikit-survival (and in extension scikit-learn) it only takes a few lines of code to get started:

import pandas as pd
from sklearn.model_selection import train_test_split
from sksurv.datasets import load_whas500
from torch_survival.models import DeepSurv

X, y = load_whas500()
X = pd.get_dummies(X, drop_first=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)

model = DeepSurv(random_state=42, device='cpu')
model.fit(X_train, y_train)
c_index = model.score(X_test, y_test)

Implemented Models

This list summarizes the currently available models. We aim to steadily improve coverage and also welcome community contributions.

Alternatives

While torch-survival is the first comprehensive and production-ready library for deep survival analysis, there are other related libraries that you may want to consider:

  • pycox has building blocks for both continuous-time models (think DeepSurv) and discrete-time models (think DeepHit) but lacks ready-to-use models.
  • torchsurv implements loss functions and metrics with a heavier focus on statistical evaluation at the expense of computational performance.

Metadata

Release files for torch-survival 0.2.0a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torch-survival 0.2.0a2
File Size Uploaded Provenance Actions
torch_survival-0.2.0a2.tar.gz 19.0 kB Without provenance Details for torch_survival-0.2.0a2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torch-survival 0.2.0a2
File Interpreter ABI Platform Actions
torch_survival-0.2.0a2-py3-none-any.whl Python 3 none any Details for torch_survival-0.2.0a2-py3-none-any.whl

Total release size: 51.6 kB

Release files / torch_survival-0.2.0a2.tar.gz

Download URL torch_survival-0.2.0a2.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9764be73b905b9bb761b9627240e52abef38ecd72b0e930bd7b2b9b61ff6ad04
BLAKE2b-256 checksum
How to use checksums
dfc0a5bf95aaa36bc3cbdaab13c8bc9da3ac0f09ba781db678bc1f2a1cf348da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torch_survival-0.2.0a2-py3-none-any.whl

Download URL torch_survival-0.2.0a2-py3-none-any.whl
Size 32.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6953f369dc7248c3d0267db476d2b3564b2ae69d27927287c28bd4ee7b9e5dd9
BLAKE2b-256 checksum
How to use checksums
90b7672ff5b31a20b975b93d377690211f96089a70013b714aafa31d8c29cec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for torch-survival 0.2.0a2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page