DeepSurv
DeepSurv copied to clipboard
Question about use of partial_hazards in get_concordance_index()
I'm looking at both lifelines and your method for getting concordance index. In DeepSurv, you have:
return concordance_index(t,
partial_hazards,
e)
where t is time, e is event indicator, and partial_hazards is -self.partial_hazard.
In lifelines utils/init.py:
return _concordance_index(event_times,
predicted_event_times,
event_observed)
Where it differs in using predicted_event_times in place of partial_hazards.
Do you mind explaining the use of partial_hazards in place of predicted_event_times to calculate CI?
Also, is it incorrect to have risk values that are negative? Many of my risk values end up being negative when I do: self.network.predict_risk(x)
Thanks!
@dareneiri
When calculating the concordance index, the absolute event times are not necessary because the CI is calculated by comparing relative event times.
DeepSurv isn't predicting the event time for events, but the risk (effect of covariates on the hazard). We assume that an observation with a higher risk will cause an event to happen sooner. So, we take DeepSurv's predictions on a dataset as the reverse ranking (hence the negative sign) of event times.
This allows us to use the variable partial_hazards
in the place of predicted_event_times
in the lifelines package.
In our model, the network can predict negative risk because we take the exponent of the risk function. This transforms the values to be positive, which satisfies the constraint of the hazard function as positive.
@jaredleekatzman Thank you for taking the time explain more in detail how DeepSurv works. Could you provide more detail on what the expected range should be for these risk values? For me, this seems to be related to the size of my dataset and the set.seed() value, but I typically see a range of risk values from -5 to 5.
I obtain these values by running DeepSurv with the following changes in deep_surv.py near lines 163:
from theano import printing
risk = self.risk(deterministic)
risk_printed = theano.printing.Print('This is risk\n')(risk)
hazard_ratio = T.exp(risk_printed)
I collected these calculated risk values from Theano and created a historgram to see the spread.
I'm not looking at the hazard_ratio (relative risk), but the risk value itself. Shouldn't the risk values be between 0-1 (probability)?
Appreciate your time in providing a response!
Note that my concordance index is around 0.83 when these risk values result.
Hi @dareneiri , I saw you are very professional with deepsurv. Would you mind me ask you some questions about deepsurv? Now I can import deepsurv using pycharm but do I need to use docker in order to train my own model using my train data? If so, can you give some example code for begin? I am a beginner for this and many thanks for your reply in advance!
Hi @jaredleekatzman, let me know if you have any new thoughts on my second question regarding the range of the risk values and whether they should be between 0-1 (I see -5 to 5 from my normalized dataset). Much appreciated!
I have the same question regarding the range of the risk values I am using below code after the model is trained get_risk=model.predict_risk(train_data["x"]) print(get_risk)
for the metabric dataset, the range of this get_risk is (-0.016, 0.066)
for my own dataset (N quite large and rare event with event rate ~1% ), the range of this get_risk is (-32.398220, 151.645113)
Much appreciated!!!