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
2 answers

Right censoring visualization of survival data

I am wondering if there is a way we can produce a graph like this using survival data. For example suppose we have this dataframe d = {'time_in_weeks': [0, 10, 20, 30, 50, 170], 'failure_status': [0, 0, 0, 0, 1, 1]} df = pd.DataFrame(data=d) How…
Snorrlaxxx
  • 168
  • 1
  • 3
  • 18
0
votes
1 answer

How to indicate Kaplan-Meier Fitter (python) to plot 90% of datapoints to avoid sudden drops

I am writing some python code to do Kaplan-Meier (KM) curves using the KM Fitter and usually plot 4 curves in the same graph to compare different groups. The basic way to get a KM curve is: from lifelines import KaplanMeierFitter #Create the KMF…
Ed R05
  • 3
  • 2
0
votes
1 answer

lifetimes plot upside down

I am learning survival analysis using the lifelines library. I am using the leukemia dataset. I was trying to plot the lifetimes plot. However, I am getting a plot which is upside down (i.e., flipped vertically). I am using this notebook as a…
A Q
  • 166
  • 2
  • 13
0
votes
2 answers

Getting Concordance result of lifelines CoxPH model in a dataframe

I am using CoxPH implementation of lifelines package in python. Currently, results are in tabular view of coefficients and related stats and can be seen with print_summary(). Here is an example df = pd.DataFrame({'duration': [4, 6, 5, 5, 4, 6], …
0
votes
1 answer

Spline regression analyses for COX survival analysis in Python

I'm currently using lifelines to carry out coxph survival analysis. I'm wondering if there's any library or functions that can help me to carry out spline regression analyses for the coxph model? Something like…
0
votes
1 answer

Predicting survival probability at current time censored subjects

I’m trying to produce the predict survival function for censored subjects at their current time using this: def predict_cumulative_hazard_at_single_time(self, X, times, ancillary_X=None): lambda_, rho_ =…
0
votes
0 answers

Lifelines logrank p doesn't match with KM-plotter

I am trying to get the logrank p value from a survival Kaplan-Meier plot comparing cancer patients expressing low levels or the gene BRCA1 and patients expressing high levels of BRCA1 (BRCA1 -BReast CAncer gene 1) So, I downloaded the cancer data -a…
daniel_hck
  • 1,100
  • 3
  • 19
  • 38
0
votes
1 answer

Is there a way to extract data from plot_covariate_groups method in CPH fitter package?

I ran a Cox Proportional Hazard model using CPH.fitter from lifelines. Now I want the survival function for some individual parameters in the cohort. Using plot_covariate_groups method, I got the image of the survival function but I need to extract…
0
votes
1 answer

Plotting KMF curve using lifelines in Pycharm exit code 0 but no output

Sorry am quite new to this but I tried running some code and I get exit code 0 (no errors) but I do not see any output (in the Python console) Am using PyCharm Python 3.7 with lifelines package from lifelines import KaplanMeierFitter durations =…
0
votes
0 answers

Failed to loading lifelines (Result shows: Attribute error: module 'scipy.misc' has no attribute 'logsumexp')

I am trying to run the lifelines package, import numpy as np from scipy import stats import pandas as pd from scipy.special import logsumexp from lifelines import KaplanMeierFitter, CoxPHFitter from lifelines.statistics import logrank_test And the…
pill45
  • 599
  • 3
  • 8
  • 23
0
votes
0 answers

Upper limit on duration for Survival Analysis

I have a lifelines model which I fit using the following: model = WeibullAFTFitter() model.fit(train, 'duration', event_col='y', show_progress=True) However, the time duration it predicts for my test set is extremely large (by using predicted_time…
sachinruk
  • 9,571
  • 12
  • 55
  • 86
0
votes
1 answer

How to modify the output of my COXPH image drawn by cph.plot_covariate_groups

I do not know how I can modify the output image provide by lifelines since I am unfamiliar with "cph.plot_covariate_groups". Unfortunately, there seems no detailed description about it in the link here;…
0
votes
0 answers

Wordpress Custom Query - Comparing Dates and Making Events List

this is a WordPress (lifeline theme ) I want to show upcoming event ... & past event separately ... Help me to write Custom Query
Depak Raut
  • 17
  • 4
0
votes
0 answers

Python - lifelines - add_covariate_to_timeline

I want to run a CoxTimeVaryingFitter on some data though I'm having some troubles with the add_covariate_to_timeline function which gives me the following error message: File "C:\Anaconda3\lib\site-packages\pandas\core\generic.py", line 692, in…
0
votes
1 answer

Lifelines boolean index in Python did not match indexed array along dimension 0; dimension is 88 but corresponding boolean dimension is 76

This very simple piece of code, # imports... from lifelines import CoxPHFitter import pandas as pd src_file = "Pred.csv" df = pd.read_csv(src_file, header=0, delimiter=',') df = df.drop(columns=['score']) cph = CoxPHFitter() cph.fit(df,…
slesher
  • 109
  • 2
  • 13