Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cox regression python

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

like image 386
Edward Avatar asked Mar 15 '16 20:03

Edward


People also ask

What is Cox regression used for?

Cox regression (or proportional hazards regression) is method for investigating the effect of several variables upon the time a specified event takes to happen. In the context of an outcome such as death this is known as Cox regression for survival analysis.

What is Python survival analysis?

Survival analysis is a set of statistical approaches used to find out the time it takes for an event of interest to occur. Survival analysis is used to study the time until some event of interest (often referred to as death) occurs. Time could be measured in years, months, weeks, days, etc.

Is Cox a regression model?

The Cox proportional-hazards model (Cox, 1972) is essentially a regression model commonly used statistical in medical research for investigating the association between the survival time of patients and one or more predictor variables.


3 Answers

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

like image 133
ilse Avatar answered Sep 27 '22 21:09

ilse


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.
like image 30
Arturo Moncada-Torres Avatar answered Sep 27 '22 21:09

Arturo Moncada-Torres


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.
like image 25
Cam.Davidson.Pilon Avatar answered Sep 27 '22 23:09

Cam.Davidson.Pilon