Questions tagged [lifelines]

lifelines is an implementation of survival analysis in Python. Use this tag for questions regarding lifelines.

lifelines is a python package specifically for Survival Analysis.

What is Survival Analytics?

Survival analysis is the statistics of censored time to event data, to which standard regression and classification techniques generally do not apply, due to the uncertain group memberships of the observations.

Survival analysis is generally defined as a set of methods for analyzing data where the outcome variable is the time until the occurrence of an event of interest. The event can be death, occurrence of a disease, marriage, divorce, etc. The time to event or survival time can be measured in days, weeks, years, etc.

For example, if the event of interest is heart attack, then the survival time can be the time in years until a person develops a heart attack.

lifelines package offers following:

  1. built on top of Pandas

  2. internal plotting methods

  3. simple and intuitive API

  4. only does survival analysis (No unnecessary features or second-class implementations)

For More Details Visit : lifelines Docs

63 questions
4
votes
2 answers

Feature (Covariates) selection in CoxPHFitter, Lifelines Survival Analysis

i am using this implemented model in Python for the purpose of survival analysis: from lifelines import CoxPHFitter Unfortunately i am not able(i do not know how) to loop over all covariates (features) to run the regression individualy for the…
4
votes
1 answer

AttributeError: '_process_plot_var_args' object has no attribute 'get_next_color'

I have tried to run the following code. but it gives an argument required error in lifelines/plotting.py file. i can't fix it . import pandas as pd from lifelines.datasets import load_dd import matplotlib.pyplot as plt data = load_dd() print…
Rabindra Nath Nandi
  • 1,433
  • 1
  • 15
  • 28
3
votes
1 answer

Cox regression using lifelines and categorical variables

Hi I'm using the lifelines package to do Cox regression. I want to examine the effects of a categorical variable which is non-binary. Is there a built-in way of doing this? Or should I transform each category factor into a number? Alternatively,…
Agustin
  • 1,458
  • 1
  • 13
  • 30
2
votes
0 answers

lifelines/scikit-survival: Calculation of the expected times

I am trying to understand how to calculate the expected time for the each of my ids in my dataset. I have a dataset that looks like a Dataframe shaped (500,4): ids var1 var2 churn time 0 1.738434 324 0 21.0 1 1.541176 …
2
votes
1 answer

Solving Cox Proportional Hazard after creating interaction variable with time

I am using lifelines package to do Cox Regression. After trying to fit the model, I checked the CPH assumptions for any possible violations and it returned some problematic variables, along with the suggested solutions. One of the solution that I…
2
votes
1 answer

how can i extract baseline hazards from a coxPHFitter function in Lifelines and the coefficients for my variates

Below is the sample code I got from the documentation website. I want to access the baseline hazards and the coefficients of the variates. ''' from lifelines import CoxPHFitter from lifelines.datasets import load_rossi rossi_dataset =…
2
votes
1 answer

Predict survival score and CLTV for contractual discrete policies/terms

I am trying to predict the survival score and LTV for contractual and discrete policies(in insurance) in python. I browsed number of sites but I could find many examples only for non-contractual(in retail). I have used the below code: from…
2
votes
1 answer

Cox PH model in `lifelines` - violated assumptions for dummy variables

I am using lifelines library to estimate Cox PH model. For the regression I have many categorical features, which I one-hot-encode and remove one column per feature to avoid multicollinearity issue (dummy variable trap). I am not attaching the code…
abu
  • 737
  • 5
  • 8
  • 19
2
votes
2 answers

How to deal with non invertible matrix in survival analysis

I am new to survival analysis. I tried to using CoxPHFitter, But I came across this error. numpy.linalg.linalg.LinAlgError: Matrix is singular. After went through this error, I came to know one of my column has non invertible matrix. So what…
Mohamed Thasin ah
  • 10,754
  • 11
  • 52
  • 111
2
votes
1 answer

Lifelines Survival Analysis in Python. What is the partial hazard in that method?

I am trying to use Python Lifelines package to calibrate and use Cox proportional hazard model. So, the result summary is: coef exp(coef) se(coef) z p lower 0.95 upper 0.95 PD -1.1446 0.3183 0.0814 -14.0563 0.0000 …
2
votes
1 answer

Plotting issues with python library lifelines

I try to use pythons lifelines package Package website and Github. After trying to run the example from the website which reads: from lifelines.datasets import load_waltons from lifelines import KaplanMeierFitter df = load_waltons() T =…
hhlw
  • 97
  • 1
  • 7
1
vote
0 answers

Decision Tree Based Survival Analysis with time-varying covariates in Python

I'd like to predict the remaining survival time with time-varying covariates using Python. I already used lifelines' CoxTimeVaryingFitter and would like to compare it to a decision tree based approach, such as Random Survival Forest. From this paper…
1
vote
1 answer

How to set "step_size" to a smaller value? because I got ConvergenceWarning: Newton-Rhaphson failed to converge sufficiently

In the estimation of CoxPH model I got the following error: ConvergenceWarning: Newton-Rhaphson failed to converge sufficiently. In the documentation they talks about setting "step_size" to smaller value, I coudn't find where I can use "fit_options"…
Khaled DELLAL
  • 871
  • 4
  • 16
1
vote
0 answers

How to plot survival probability calibration with Lifelines?

I am trying to use survival_probability_calibration to visualize the performance of Cox model but the calibration curve would always stay flat as shown in the following plot: Calibration curve with cox model What can be the reason of this issue?…
1
vote
0 answers

How to predict risk scores with Cox models using lifelines package?

I have made multiple cox models with Lifelines package and I am trying to predict the risk score of each individual following information in CoxPhFitter page. predict_hazard is a suggested command in that page, but when I use it to predict risk…
1
2 3 4 5