5

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)?

4

3 回答 3

7

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

于 2017-09-18T18:01:25.057 回答
5

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.
于 2020-07-30T16:41:50.463 回答
3

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.
于 2020-08-02T19:49:53.397 回答