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

Python CoxPHFitter to extract hazard ratio and confidence intervals

I am new to survival analysis and I have been reading many research paper where the authors report adjusted (age and gender) and unadjusted hazard ratios along with confidence intervals. I am currently using CoxPHFitter from lifelines python package…
Taby
  • 75
  • 5
1
vote
1 answer

Survival function in python lifelines too optimistic?

I'm new to survival analysis and quickly coded a baseline survival function with Python's Lifeline. But the graphs I get are too optimistic compared to the retention curves I plotted myself based on my data. Below is a graph I made based on my data.…
Ruben_G
  • 11
  • 3
1
vote
2 answers

How do I find the best categorization for survival analysis?

I have a question concerning survival analysis. However, I have the following data (just an excerpt): Now I am trying to do Survival Analysis with Python lifelines package. For example I want to find out if T-cells influence the Overall Survival…
Hashriama
  • 173
  • 11
1
vote
1 answer

Survival Analysis in Python - Is there any survminer equivalent in Python?

I am a Data Scientist who is an avid R user and currently exploring Python if it helps to broaden my analytics reach. As a first step, I am trying to replicate my current R analyses using Python. Having worked in oncology, I frequently perform…
Navdeep_DS
  • 85
  • 7
1
vote
1 answer

plot_covariate_groups in lifiline gives NameError: name 'self' is not defined

I am running survival cox regression with time-varying covariates : from lifelines import CoxTimeVaryingFitter ctv = CoxTimeVaryingFitter(penalizer=0.1) ctv.fit(train_long, id_col="ID", event_col="daysInDeliquency", start_col="start",…
Shota
  • 11
  • 3
1
vote
2 answers

ConvergenceError: Convergence halted due to matrix inversion problems

I keep having error messages anytime I try running CoxPH regression in Python. I'm not a pro in python still learning. import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import numpy as np from lifelines import…
Soloibom
  • 11
  • 2
  • 6
1
vote
0 answers

Cox PH on Lifelines shows convergence problem

I'm running a Cox PH model using lifelines package on Python. I find it strange that if I run the model on the whole data there is no problem running it, however when I do a cross-validation (using the package's own validation function) a…
1
vote
0 answers

Difference between Cox Proportional Hazrd Method and Weibull AFT model in lifelines package in Python

I am going through survival analysis using Python's lifelines package. https://lifelines.readthedocs.io/en/latest/Survival%20Regression.html While reading ATF; Accelerated Failure time model and Cox Propositional Hazard method, I came to know AFT…
1
vote
1 answer

Duration of censored events on lifelines package of survival analysis

I am working with lifelines package in python which is for survival analysis. when I set different values on duration_col for censored events (the ones that have 0 on event_col), I get different results. The fact is that censored events have no…
Kosar Kazemi
  • 65
  • 1
  • 6
1
vote
1 answer

Is it possible to run a Cox-Proportional-Hazards-Model with an exponential distribution for the baseline hazard in `lifelines` or another package?

I consider using the lifelines package to fit a Cox-Proportional-Hazards-Model. I read that lifelines uses a nonparametric approach to fit the baseline hazard, which results in different baseline_hazards for some time points (see code example…
Qaswed
  • 3,649
  • 7
  • 27
  • 47
1
vote
1 answer

Predicting survival probability at current time

I train my survival model with the following lines: wft = WeibullAFTFitter() wft.fit(train, 'duration', event_col='y') After this I wish to see what the survival probability at the current time (duration column). The way that I am currently doing…
sachinruk
  • 9,571
  • 12
  • 55
  • 86
1
vote
1 answer

python 3.6 virtualenv - openblas crashes

I'm running on Win7 64 bit, and have created a virtualenv with Python 3.6. For a start, I've installed the latest numpy from pypi (numpy-1.16.2-cp36-cp36m-win_amd64). However, even just importing numpy will result in python.exe crashing…
Bogey
  • 4,926
  • 4
  • 32
  • 57
1
vote
0 answers

Large Dataframe slow with Lifelines Survival Analysis

I'm trying to run a survival analysis on a large dataset (about 80 rows x 12,000 cols) in python. Currently I'm using: from lifelines import CoxPHFitter cf = CoxPHFitter() cf.fit(df, duration_col='Time', event_col='Status') But it is extremely…
zhivaga
  • 11
  • 3
1
vote
1 answer

Getting survival function estimates group by attribute level in Lifelines

I have a challenge with using Lifelines for KM estimates. I have a variable column called worker type (Full Time, Part Time, etc) that I would like to group the KM estimates for, then output to a CSV file. Here's a snippet: worker_types =…
TBoneATL
  • 33
  • 1
  • 5
0
votes
0 answers

Weird Error message: Lifelines package predict_survival_function for Weibull AFT model

I am trying to write code that will give me the change in the survival function for a 1 unit change in a particular covariate (pay_rate_mat in this case). I am receiving the error: ValueError: matmul: Input operand 1 has a mismatch in its core…
McGez
  • 49
  • 3