Differences in concordance index results via lifelines and scikit-survival #499
-
Hi there! I am taking a look at using either lifelines and sksurv for some survival analysis, but I just discovered that I get different results for the same data on a concordance index. import numpy as np
from lifelines.utils import concordance_index
import lifelines
from sksurv.metrics import concordance_index_censored
# Generate some sample data
np.random.seed(42)
y_true = np.random.randint(1, 100, 100)
y_pred = np.random.randint(1, 100, 100)
event_observed = np.random.randint(2, size=100).astype(bool)
c_index_lifelines = concordance_index(y_true, y_pred, event_observed)
c_index_sksurv, _, _, _, _ = concordance_index_censored(event_indicator=event_observed, event_time=y_true, estimate=y_pred)
print(f"c-index lifelines: {c_index_lifelines}")
print(f"c-index sksurv: {c_index_sksurv}")
print(f"1 - c-index sksurv: {1 - c_index_sksurv}")
print(f"\nLifelines version: {lifelines.__version__}\n")
print("sksurv version information:")
print(sksurv.show_versions()) I get the following results:
Am I misunderstanding something about the implementation of the concordance index in scikit-survival? In the extreme case, where I set |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The semantics are different. For lifelines |
Beta Was this translation helpful? Give feedback.
The semantics are different. For lifelines
y_pred
is a score for survival, i.e. a higher score indicates longer survival, for sksurvy_pred
should be a risk score, i.e. higher values indicate shorter survival. As you wrote, you can also simply use1 - c_index
to make the results equivalent.