← 开源
havakv

pycox

Survival analysis with PyTorch

Model DevelopmentDomain-specific trainingPython
在 GitHub 打开
增长势头
+124 小时新增 Star+0.1%
1.00k
Star
205
Fork
+3
本周
4
贡献者
创建于 2018-02-12 · 更新于 2026-10-16 · 今日第 5947 名
主要开发者
havakvhartbnikolase90

havakv/pycox 排名第 5,947,有 1,000 个星标。

同类别比较

havakv/pycox 排名第 5,947,此处有 8 个同类条目;mees/calvin 排名第 5,950。

同类别比较
名称排名指标
mni-ml/framework5,928
语言:
Rust
星标数:
1,017
分叉数:
131
简介:
A machine learning library with a TypeScript API and Rust backend. CUDA and WebGPU compatibility. Built to understand how ML frameworks and models work internally.
LeCAR-Lab/dial-mpc5,932
语言:
Python
星标数:
1,011
分叉数:
104
简介:
Official implementation for the paper "Full-Order Sampling-Based MPC for Torque-Level Locomotion Control via Diffusion-Style Annealing". DIAL-MPC is a novel sampling-based MPC framework for legged robot full-order torque-level control with both precision and agility in a training-free manner.
TinyLLaVA/TinyLLaVA_Factory5,935
语言:
Python
星标数:
1,010
分叉数:
100
简介:
A Framework of Small-scale Large Multimodal Models
pjlab-sys4nlp/llama-moe5,940
语言:
Python
星标数:
1,005
分叉数:
60
简介:
⛷️ LLaMA-MoE: Building Mixture-of-Experts from LLaMA with Continual Pre-training (EMNLP 2024)
mees/calvin5,950
语言:
Python
星标数:
998
分叉数:
127
简介:
CALVIN - A benchmark for Language-Conditioned Policy Learning for Long-Horizon Robot Manipulation Tasks
zhouhaoyi/ETDataset5,957
星标数:
991
分叉数:
181
简介:
The Electricity Transformer dataset is collected to support the further investigation on the long sequence forecasting problem.
qiuzh20/gated_attention5,961
语言:
Jupyter Notebook
星标数:
987
分叉数:
61
简介:
The official implementation for [NeurIPS2025 Oral] Gated Attention for Large Language Models: Non-linearity, Sparsity, and Attention-Sink-Free
lucidrains/BS-RoFormer5,967
语言:
Python
星标数:
984
分叉数:
49
简介:
Implementation of Band Split Roformer, SOTA Attention network for music source separation out of ByteDance AI Labs
关键参数与规格
关键参数与规格
参数值
语言Python
类别Model Development
子类别Domain-specific training
关键词Biomedical
星标数1,000
分叉数205
贡献者4
创建日期2018-02-12
更新日期2026-10-16
1 天星标数1
7 天星标数3
排名5,947
上次排名6,116
排名变化169
7 天星标排名7,115
上次 7 天星标排名8,389
7 天星标排名变化1,274
总星标排名11,153
上次总星标排名11,135
总星标排名变化-18
国家Norway
README 摘录

**pycox** is a python package for survival analysis and time-to-event prediction with PyTorch, built on the torchtuples package for training PyTorch models. An R version of this package is available at survivalmodels. The package contains implementations of various survival models, some useful evaluation metrics, and a collection of event-time datasets. In addition, some useful preprocessing tools are available in the module. Get Started To get started you first need to install PyTorch. You can then install **pycox

** via pip: OR, via conda: We recommend to start with 01_introduction. ipynb, which explains the general usage of the package in terms of preprocessing, creation of neural networks, model training, and evaluation procedure. The notebook use the method for illustration, but most of the principles generalize to the other methods. Alternatively, there are many examples listed in the examples folder, or you can follow the tutorial based on the : 01_introduction. ipynb: General usage of the package in terms

of preprocessing, creation of neural networks, model training, and evaluation procedure. ipynb: Quantile based discretization scheme, nested tuples with , entity embedding of categorical variables, and cyclical learning rates. ipynb: Extending the framework with custom networks and custom loss functions. The example combines an autoencoder with a survival network, and considers a loss that combines the autoencoder loss with the loss of the . ipynb: Using dataloaders and convolutional networks for the MNIST data set. We repeat the simulations of [\[8\]](#references

) where each digit defines the scale parameter of an exponential distribution. Methods The following methods are available in the module. Continuous-Time Models: Discrete-Time Models: Evaluation Criteria The following evaluation metrics are available with . Datasets A collection of datasets are available through the module. For example, the following code will download the dataset and load it in the form of a pandas dataframe The module will store datasets under the installation directory by default. You can specify a different

directory by setting the environment variable. Real Datasets: Simulated Datasets: Installation **Note:** *This package is still in its early stages of development, so please don't hesitate to report any problems you may experience. Before installing **pycox**, please install PyTorch (version >= 1. You can then install the package with For the bleeding edge version, you can instead install directly from github (consider adding ): Install from Source Installation from source depends on PyTorch, so make sure a it is installed. Next, clone

and install with References \[1\] Håvard Kvamme, Ørnulf Borgan, and Ida Scheel. Time-to-event prediction with neural networks and Cox regression. *Journal of Machine Learning Research*, 20(129):1–30, 2019. Katzman, Uri Shaham, Alexander Cloninger, Jonathan Bates, Tingting Jiang, and Yuval Kluger. Deepsurv: personalized treatment recommender system using a Cox proportional hazards deep neural network. *BMC Medical Research Methodology*, 18(1), 2018. \[paper\] \[3\] Changhee Lee, William R Zame, Jinsung Yoon, and Mihaela van der Schaar. Deephit

: A deep learning approach to survival analysis with competing risks. *In Thirty-Second AAAI Conference on Artificial Intelligence*, 2018. \[paper

常见问题

记录了多少星标和分叉?

havakv/pycox 有 1,000 个星标和 205 个分叉。

仓库排名是多少?

havakv/pycox 排名第 5,947。

记录的语言和类别是什么?

havakv/pycox 有 1,000 个星标,语言为 Python,类别为 Model Development。

哪个仓库排名最接近?

havakv/pycox 与 mees/calvin 比较,后者排名第 5,950,有 998 个星标。

README
 ![pycox](https://github.com/havakv/pycox/blob/master/figures/logo.svg) 





Time-to-event prediction with PyTorch





 [![GitHub Actions status](https://github.com/havakv/pycox/workflows/Python%20package/badge.svg)](https://github.com/havakv/pycox/actions)
 [![PyPI](https://img.shields.io/pypi/v/pycox.svg)](https://pypi.org/project/pycox/)
 [![PyPI](https://img.shields.io/conda/vn/conda-forge/pycox)](https://anaconda.org/conda-forge/pycox)
 [![Hei](https://img.shields.io/pypi/pyversions/pycox.svg)](https://pypi.org/project/pycox/)
[![](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://github.com/havakv/pycox/blob/master/LICENSE)






[Get Started](#get-started) •
[Methods](#methods) •
[Evaluation Criteria](#evaluation-criteria) •
[Datasets](#datasets) •
[Installation](#installation) •
[References](#references)

pycox is a python package for survival analysis and time-to-event prediction with PyTorch, built on the torchtuples package for training PyTorch models. An R version of this package is available at survivalmodels.

The package contains implementations of various survival models, some useful evaluation metrics, and a collection of event-time datasets. In addition, some useful preprocessing tools are available in the pycox.preprocessing module.

Get Started

To get started you first need to install PyTorch. You can then install pycox via pip:

pip install pycox

OR, via conda:

conda install -c conda-forge pycox

We recommend to start with 01_introduction.ipynb, which explains the general usage of the package in terms of preprocessing, creation of neural networks, model training, and evaluation procedure. The notebook use the LogisticHazard method for illustration, but most of the principles generalize to the other methods.

Alternatively, there are many examples listed in the examples folder, or you can follow the tutorial based on the LogisticHazard:

  • 01_introduction.ipynb: General usage of the package in terms of preprocessing, creation of neural networks, model training, and evaluation procedure.

  • 02_introduction.ipynb: Quantile based discretization scheme, nested tuples with tt.tuplefy, entity embedding of categorical variables, and cyclical learning rates.

  • 03_network_architectures.ipynb: Extending the framework with custom networks and custom loss functions. The example combines an autoencoder with a survival network, and considers a loss that combines the autoencoder loss with the loss of the LogisticHazard.

  • 04_mnist_dataloaders_cnn.ipynb: Using dataloaders and convolutional networks for the MNIST data set. We repeat the simulations of [8] where each digit defines the scale parameter of an exponential distribution.

Methods

The following methods are available in the pycox.methods module.

Continuous-Time Models:

Method

Description

Example

CoxTime

    Cox-Time is a relative risk model that extends Cox regression beyond the proportional hazards [[1]](#references).

notebook

CoxCC

    Cox-CC is a proportional version of the Cox-Time model [[1]](#references).

notebook

CoxPH (DeepSurv)

    CoxPH is a Cox proportional hazards model also referred to as DeepSurv [[2]](#references).

notebook

PCHazard

    The Piecewise Constant Hazard (PC-Hazard) model [[12]](#references) assumes that the continuous-time hazard function is constant in predefined intervals.
    It is similar to the Piecewise Exponential Models [[11]](#references) and PEANN [[14]](#references), but with a softplus activation instead of the exponential function.

notebook

Discrete-Time Models:

Method

Description

Example

LogisticHazard (Nnet-survival)

    The Logistic-Hazard method parametrize the discrete hazards and optimize the survival likelihood [[12]](#references) [[7]](#references).
    It is also called Partial Logistic Regression [[13]](#references) and Nnet-survival [[8]](#references).

notebook

PMF

    The PMF method parametrize the probability mass function (PMF) and optimize the survival likelihood [[12]](#references). It is the foundation of methods such as DeepHit and MTLR.

notebook

DeepHit, DeepHitSingle

    DeepHit is a PMF method with a loss for improved ranking that 
    can handle competing risks [[3]](#references).

single competing

MTLR (N-MTLR)

    The (Neural) Multi-Task Logistic Regression is a PMF methods proposed by 
    [[9]](#references) and [[10]](#references).

notebook

BCESurv

    A method representing a set of binary classifiers that remove individuals as they are censored [[15]](#references). The loss is the binary cross entropy of the survival estimates at a set of discrete times, with targets that are indicators of surviving each time.

bs_example

Evaluation Criteria

The following evaluation metrics are available with pycox.evalutation.EvalSurv.

Metric

Description

concordance_td

    The time-dependent concordance index evaluated at the event times [[4]](#references).

brier_score

    The IPCW Brier score (inverse probability of censoring weighted Brier score) [[5]](#references)[[6]](#references)[[15]](#references).
    See Section 3.1.2 of [[15]](#references) for details.

nbll

    The IPCW (negative) binomial log-likelihood [[5]](#references)[[1]](#references). I.e., this is minus the binomial log-likelihood and should not be confused with the negative binomial distribution.
    The weighting is performed as in Section 3.1.2 of [[15]](#references) for details.

integrated_brier_score

    The integrated IPCW Brier score. Numerical integration of the `brier_score` [[5]](#references)[[6]](#references).

integrated_nbll

    The integrated IPCW (negative) binomial log-likelihood. Numerical integration of the `nbll` [[5]](#references)[[1]](#references).

brier_score_admin integrated_brier_score_admin

    The administrative Brier score [[15]](#references). Works well for data with administrative censoring, meaning all censoring times are observed.
    See this [example notebook](https://nbviewer.jupyter.org/github/havakv/pycox/blob/master/examples/administrative_brier_score.ipynb).

nbll_admin integrated_nbll_admin

    The administrative (negative) binomial log-likelihood [[15]](#references). Works well for data with administrative censoring, meaning all censoring times are observed.
    See this [example notebook](https://nbviewer.jupyter.org/github/havakv/pycox/blob/master/examples/administrative_brier_score.ipynb).

Datasets

A collection of datasets are available through the pycox.datasets module. For example, the following code will download the metabric dataset and load it in the form of a pandas dataframe

from pycox import datasets
df = datasets.metabric.read_df()

The datasets module will store datasets under the installation directory by default. You can specify a different directory by setting the PYCOX_DATA_DIR environment variable.

Real Datasets:

Dataset

Size

Dataset

Data source

flchain

6,524

    The Assay of Serum Free Light Chain (FLCHAIN) dataset. See 
    [[1]](#references) for preprocessing.

source

gbsg

2,232

    The Rotterdam & German Breast Cancer Study Group.
    See [[2]](#references) for details.

source

kkbox

2,814,735

    A survival dataset created from the WSDM - KKBox's Churn Prediction Challenge 2017 with administrative censoring.
    See [[1]](#references) and [[15]](#references) for details.
    Compared to kkbox_v1, this data set has more covariates and censoring times.
    Note: You need 
    [Kaggle credentials](https://github.com/Kaggle/kaggle-api#api-credentials) to access the dataset.

source

kkbox_v1

2,646,746

    A survival dataset created from the WSDM - KKBox's Churn Prediction Challenge 2017. 
    See [[1]](#references) for details.
    This is not the preferred version of this data set. Use kkbox instead.
    Note: You need 
    [Kaggle credentials](https://github.com/Kaggle/kaggle-api#api-credentials) to access the dataset.

source

metabric

1,904

    The Molecular Taxonomy of Breast Cancer International Consortium (METABRIC).
    See [[2]](#references) for details.

source

nwtco

4,028

    Data from the National Wilm's Tumor (NWTCO).

source

support

8,873

    Study to Understand Prognoses Preferences Outcomes and Risks of Treatment (SUPPORT).
    See [[2]](#references) for details.

source

Simulated Datasets:

Dataset

Size

Dataset

Data source

rr_nl_nph

25,000

    Dataset from simulation study in [[1]](#references).
    This is a continuous-time simulation study with event times drawn from a
    relative risk non-linear non-proportional hazards model (RRNLNPH).

SimStudyNonLinearNonPH

sac3

100,000

    Dataset from simulation study in [[12]](#references).
    This is a discrete time dataset with 1000 possible event-times.

SimStudySACCensorConst

sac_admin5

50,000

    Dataset from simulation study in [[15]](#references).
    This is a discrete time dataset with 1000 possible event-times.
    Very similar to `sac3`, but with fewer survival covariates and administrative censoring determined by 5 covariates.

SimStudySACAdmin

Installation

Note: This package is still in its early stages of development, so please don't hesitate to report any problems you may experience.

The package only works for python 3.6+.

Before installing pycox, please install PyTorch (version >= 1.1). You can then install the package with

pip install pycox

For the bleeding edge version, you can instead install directly from github (consider adding --force-reinstall):

pip install git+git://github.com/havakv/pycox.git

Install from Source

Installation from source depends on PyTorch, so make sure a it is installed. Next, clone and install with

git clone https://github.com/havakv/pycox.git
cd pycox
pip install .

References

[1] Håvard Kvamme, Ørnulf Borgan, and Ida Scheel. Time-to-event prediction with neural networks and Cox regression. Journal of Machine Learning Research, 20(129):1–30, 2019. [paper]

[2] Jared L. Katzman, Uri Shaham, Alexander Cloninger, Jonathan Bates, Tingting Jiang, and Yuval Kluger. Deepsurv: personalized treatment recommender system using a Cox proportional hazards deep neural network. BMC Medical Research Methodology, 18(1), 2018. [paper]

[3] Changhee Lee, William R Zame, Jinsung Yoon, and Mihaela van der Schaar. Deephit: A deep learning approach to survival analysis with competing risks. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018. [paper]

[4] Laura Antolini, Patrizia Boracchi, and Elia Biganzoli. A time-dependent discrimination index for survival data. Statistics in Medicine, 24(24):3927–3944, 2005. [paper]

[5] Erika Graf, Claudia Schmoor, Willi Sauerbrei, and Martin Schumacher. Assessment and comparison of prognostic classification schemes for survival data. Statistics in Medicine, 18(17-18):2529–2545, 1999. [paper]

[6] Thomas A. Gerds and Martin Schumacher. Consistent estimation of the expected brier score in general survival models with right-censored event times. Biometrical Journal, 48 (6):1029–1040, 2006. [paper]

[7] Charles C. Brown. On the use of indicator variables for studying the time-dependence of parameters in a response-time model. Biometrics, 31(4):863–872, 1975. [paper]

[8] Michael F. Gensheimer and Balasubramanian Narasimhan. A scalable discrete-time survival model for neural networks. PeerJ, 7:e6257, 2019. [paper]

[9] Chun-Nam Yu, Russell Greiner, Hsiu-Chin Lin, and Vickie Baracos. Learning patient- specific cancer survival distributions as a sequence of dependent regressors. In Advances in Neural Information Processing Systems 24, pages 1845–1853. Curran Associates, Inc., 2011. [paper]

[10] Stephane Fotso. Deep neural networks for survival analysis based on a multi-task framework. arXiv preprint arXiv:1801.05512, 2018. [paper]

[11] Michael Friedman. Piecewise exponential models for survival data with covariates. The Annals of Statistics, 10(1):101–113, 1982. [paper]

[12] Håvard Kvamme and Ørnulf Borgan. Continuous and discrete-time survival prediction with neural networks. arXiv preprint arXiv:1910.06724, 2019. [paper]

[13] Elia Biganzoli, Patrizia Boracchi, Luigi Mariani, and Ettore Marubini. Feed forward neural networks for the analysis of censored survival data: a partial logistic regression approach. Statistics in Medicine, 17(10):1169–1186, 1998. [paper]

[14] Marco Fornili, Federico Ambrogi, Patrizia Boracchi, and Elia Biganzoli. Piecewise exponential artificial neural networks (PEANN) for modeling hazard function with right censored data. Computational Intelligence Methods for Bioinformatics and Biostatistics, pages 125–136, 2014. [paper]

[15] Håvard Kvamme and Ørnulf Borgan. The Brier Score under Administrative Censoring: Problems and Solutions. arXiv preprint arXiv:1912.08581, 2019. [paper]

排名相邻
同类项目