question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Concordance index errors with repeated events

See original GitHub issue

The following produces a nan value in lifelines version 0.9.1.0.

>>> import lifelines
>>> import numpy as np
>>> from lifelines.utils import concordance_index
>>> times = np.arange(3)
>>> events = np.ones(3)
>>> concordance_index(events, times)
nan

I don’t think that’s the expected outcome, it should be 0.5, right?

The same error happens when n=1. In this case, I think a ValueError should be thrown for input validation though.

>>> import lifelines
>>> import numpy as np
>>> from lifelines.utils import concordance_index
>>> times = np.arange(1)
>>> events = np.ones(1)
>>> concordance_index(events, times)
nan

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AyuranScommented, Sep 2, 2019

@CamDavidsonPilon , I realised on trying to reproduce the bug, the issue was due to having some NaNs in the actual Time To Event column when the input is a DataFrame. This doesn’t really make it a use case for the function anymore but maybe the input error isn’t being handled correctly. I believe this would reproduce the error at least on my machine. `test1= pd.DataFrame(np.random.randint(800, size=800), columns=[‘prediction’])

test2= pd.DataFrame(np.random.randint(800, size=800), columns=[‘actuals’])

test2[-50:-1]=np.nan

print(test1.shape)

print(test2.shape)

print(lf.utils.concordance_index(test2, test1))`

1reaction
CamDavidsonPiloncommented, May 23, 2016

So I’ve added an ZeroDivisionError to the latest version of pypi, 0.9.2. I’ve left the c-index as is, according to the second paper there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A C-index for Recurrent Event Data - NCBI - NIH
We propose a C-index (index of concordance) applicable to recurrent event data. The present work addresses the dearth of measures for ...
Read more >
A C-index for recurrent event data - Deep Blue Repositories
We propose a C-index (index of concordance) applicable to recurrent event data. The present work addresses the dearth of measures for quantifying a...
Read more >
Use of the concordance index for predictors of censored ...
The concordance index is routinely used to measure how well a variable predicts the time to a censored event. However, current estimators depend...
Read more >
Concordance for Survival Time Data
Concordance, or synonymously the C-statistic, is a valuable measure of model discrimination in analyses involving survival time data.
Read more >
The Concordance Index decomposition A measure for a ...
The C-index can be decomposed into two parts; one to measure the relative ordering of cases with observed events and another to measure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found