care-survival
Upgrading survival models with CARE.
This repository contains a Python implementation of the methodology proposed by Underwood, Reeve, Feng, Lambert, Mukherjee and Samworth, 2025.
Building the Python package
This project uses
uv
to manage Python dependencies.
To build the Python package, run uv build.
To update the lockfile, use uv lock.
Running the simulation scripts
For running scripts,
just
and parallel
should be installed.
To execute all of the simulations and generate the plots,
run just.
The recipes can be found in the
justfile.
The scripts to run the SCORE2 data analysis are also available in the bin directory, but require access to UK Biobank data.
Example usage
import numpy as np
import care_survival
# generate some sample data
n = 60
d = 2
X = np.random.random((n, d))
T = X.sum(axis=1) + 1 + np.random.random(n)
I = (np.random.random(n) > 0.8) * 1
f = (-X.sum(axis=1) / 2 + np.random.random(n)).reshape(-1, 1)
# split data into training and validation sets
n_train = int(np.ceil(n / 2))
X_train = X[0:n_train]
T_train = T[0:n_train]
I_train = I[0:n_train]
f_train = f[0:n_train]
X_valid = X[n_train:n]
T_valid = T[n_train:n]
I_valid = I[n_train:n]
f_valid = f[n_train:n]
# define a kernel and use the feature map optimisation method
a = 1
p = 2
kernel = care_survival.PolynomialKernel(a, p)
method = "feature_map"
# set up the kernel tuning parameters
n_gammas = 20
gamma_min = 1e-6
gamma_max = 1e1
# set up the simplex tuning parameters
simplex_resolution = 0.05
# compute concordance score on all data
with_concordance = ["train", "valid"]
# fit CARE
care = care_survival.care(
X_train,
T_train,
I_train,
f_train,
X_valid,
T_valid,
I_valid,
f_valid,
kernel,
method,
n_gammas,
gamma_min,
gamma_max,
simplex_resolution,
with_concordance,
)
# view diagnostics
best = care.best["aggregated"]["ln"]["valid"]
print("best theta value:", best.theta)
print("best gamma value:", best.gamma)
print("concordance index:", best.score["concordance"]["valid"])
Publishing to PyPI
First build the package with
uv build
To publish to TestPyPI with an API token, run
uv publish --index testpypi --token <token>
To publish to PyPI with an API token, run
uv publish --token <token>
Metadata
Release files for care-survival 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 |
|---|---|---|---|---|
| care_survival-0.1.2.tar.gz | 71.8 kB | Without provenance | Details for care_survival-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| care_survival-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for care_survival-0.1.2-py3-none-any.whl |
Total release size: 82.7 kB
Release files / care_survival-0.1.2.tar.gz
| Download URL | care_survival-0.1.2.tar.gz |
|---|---|
| Size | 71.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1af8012c0a8f2e390c5a00c1487fab33d1114c7c7b91e7278554237ed91f526b
|
|
BLAKE2b-256 checksum How to use checksums |
595ad152d516c5782a00f399c91c1291e9be678c752d8763a0fb4bf7ce225c53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Release files / care_survival-0.1.2-py3-none-any.whl
| Download URL | care_survival-0.1.2-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04c65e2cb70c3dea8ee4b1fc259b033e3134acf90ee1e8200b77ac9193e92778
|
|
BLAKE2b-256 checksum How to use checksums |
bf51de326141f5b0787ac5370f0b6a18a3457ddc8a8be52b42bf226023485780
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Security for care-survival 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.