Cox regression python
Asked Answered
M

3

10

Are there any packages in Python for survival analysis? Specifically, I am interested in performing a Cox regression?

I know this example but it's in R. Could we just interface Python with R (using, for example, rpy2)?

Margueritamarguerite answered 15/3, 2016 at 20:44 Comment(2)
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.Barthold
Sorry, i didn't know this ruleMargueritamarguerite
H
8

The lifelines package in Python offers survival analysis, including the Cox proportional hazard fitter: https://lifelines.readthedocs.io/en/latest/

Hierophant answered 18/9, 2017 at 18:1 Comment(0)
T
7

I would just like to provide a more updated answer as of July 2020:

  • Like ilse mentioned, lifelines is a great package for all things survival analysis. It plays very nicely with pandas and has some great visualization tools out of the box. It is being constantly developed and updated. Moreover, its documentation is very thorough. I would even recommend reading it as a starting point for studying survival analysis in general.
  • scikit-surv is another option. While it lacks some of lifelines's features, its strong suit is that it is based on scikit-learn, which makes it very easy to couple with other building blocks in your pipeline. Moreover, it includes implementations of ML algorithms for survival, such as Random Survival Forests and SSVMs.
  • Lastly, we have PySurvival. I have no experience with this framework, but it looks like it has quite a few algorithms as well. It is built on top PyTorch, among others.
Tenne answered 30/7, 2020 at 16:41 Comment(0)
G
4

One more library to add to @arturo's list:

  • PyCox: built on top of PyTorch, and provides a handful of modern deep-learning based algorithms for survival prediction.
Gravely answered 2/8, 2020 at 19:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.