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
0
votes
0 answers

Two subperiods in survival curve using python lifelines

I have a general question on survival curves. I am using the lifelines package, although can also the scikit-survival package as well. I have a population that I track over a 50 year period. I want to break the period into two halves to understand…
akr24
  • 67
  • 3
0
votes
1 answer

Is there any way to predict survival probability for censored objects after historical dates (prediction in future)?

I am trying to understand the possibilities and limitations of Survival analysis, in particular lifelines python package. I fitted the Cox Proportional Hazard Model with some rossi data and got survival function showing the survival over historical…
0
votes
1 answer

Plot Kaplan Meier curves for all "object" data types in data frame

I am attempting to plot survival curves for all "object" data type columns in my data frame whereby each unique value in each column is plotted in its own subplot The resulting output should be "n" number of subplots whereby each subplot serves to…
JoMcGee
  • 47
  • 8
0
votes
0 answers

How to use KaplanMeierFitter for predictions

I have a huge dataset with subscriptions (ongoing ones and terminated ones) and I want to use the KaplanMeierFitter to predict for each cohort(=month in which subscription started) how many subscriptions will still be ongoing/active in the next…
0
votes
1 answer

Lifelines - CoxTimeVaryingFitter - 'numpy.float64' object has no attribute 'exp'

I am trying to use the CoxTimeVaryingFitter on my dataset, however there seems to be a type issue in baseline_cumulative_hazard_. I attempted reducing the individual features to isolate the problem but was not able to fit on the dataset below. Is…
0
votes
0 answers

Making a legend / getting handles of Kaplan Meier plot objects in python lifelines

I'm working with the lifelines package to make Kaplan-Meier curves. I'd like to add the censored data, but also have a legend that only mentions the two lines. I'm calling the function iteratively twice to plot two separate lines, as so: def…
Andrew M
  • 119
  • 6
0
votes
0 answers

Predict Cox model survival function with error

I’m using the lifelines package to fit a Cox model to my data. For new cases, I would like to predict my survival function and median survival time (or for any specific percentile for that matter) including the predictions for the upper and lower…
SvE
  • 61
  • 4
0
votes
1 answer

lifelines.CoxPHFitter - how are the p-values calculated?

I assume that lifelines.CoxPHFitter is using a Likelihood-ratio test (or is it using Wald?) to calculate p-values when testing for significance. But I have to be sure: is there an official source where I can find what test are used? (I was not…
0
votes
1 answer

Show Cancer Specific Survival at exact time (Kaplan Meier in Lifelines)

kmf.survival_function_ (LifeLines Package) shows me Cancer Specific Survival (CSS) of my cohort at different times (0, 4, 6...128 month). How can CSS be shown at exactly 120 month?
Mischa
  • 83
  • 1
  • 10
0
votes
0 answers

Getting error message when trying to get at risk numbers below KM-plot (lifelines)

I've used lifelines a lot, but when I'm re-running old code that previously worked fine I get the following error: KeyError: "None of [Index(['At risk', 'Censored', 'Events'], dtype='object')] are in the [index]" I'm guessing there has been some…
Sandus
  • 23
  • 6
0
votes
1 answer

First occurrence of a specific value in a row (prepping for survival analysis) - python

I have the following data (see attached - easier this way). I am trying to find the first occurrence of the value 0 for each customer ID. Then, I plan to use code similar to below to create a Kaplan-Meier curve: from lifelines import…
ZDR
  • 47
  • 6
0
votes
1 answer

Displaying statistical result in a GUI

I have a dataset and perform kaplan meier analysis on it using lifelines library, I then perform log rank and cox analysis, but the output i receieve are type 'statistical result' I would live to display this on a GUI but cannot figure it out.
0
votes
1 answer

Find local maximum for lifelines hazard function

I'm trying to find a method to detect local maximum points for hazard function (plotted using lifelines library). Lifelines library gives you the ability to plot visually the hazard function ( plot.hazard() ) but - as said - it's only the visual…
0
votes
0 answers

Cox proportional hazards model lifelines runtime warning divide by zero and invalid value encountered

I am building a Cox Proportional hazards model with the lifelines package to predict the time a borrower potentially prepays its mortgage. I fit a model by means of the cph.coxphfitter() within the liflines package. Despite the fact that the model…
0
votes
0 answers

Lifelines Hazard Ratio = 1 for all covariates

I'm running the following using the lifelines package: cph = CoxPHFitter() cph.fit(data, duration_col='T', event_col='vital_status', show_progress=True) cph.print_summary() However I'm getting all Hazard ratios equal to 1 (exp(coef) and the same…
Agustin
  • 1,458
  • 1
  • 13
  • 30