havakv / pycox

Survival analysis with PyTorch
BSD 2-Clause "Simplified" License
780 stars 180 forks source link

logistichazard and coxph basics #133

Open mahootiha-maryam opened 2 years ago

mahootiha-maryam commented 2 years ago

Hi Havard. I wanted to use Logistichazard that is based on Nnet_survival. I couldnt find the architecture of this net. In which file I can understand the architecture? In addition I wanted to ask you what is the difference between cox-ph in your repository and cox-ph in lifelines library of python. First I wanted to use lifelines python package but because I didn't see any codes for images as input I tried to use your amazing repository.

havakv commented 2 years ago

So, the reason we called it a LogisticHazard, rather than Nnet-survival, is that this is a know statistical model for discrete-time survival analysis (so no need to come up with a new name for it). I don't think any of the authors considered a specific network architecture for this. It's essentially just a loss function, and you need to specify your own neural net (which can be an MLP or CNN or whatever). From the Nnet-survival repo they give examples of multiple network architectures.

CoxPH in this repo is also an example of a model without a specific network. If you give it a linear function (single dense layer) you would end up with essentially the same model as in lifelines, but you can also give it a deep net.

On approach very small image datasets is to use a pretrained network to get features (you just get the output in the second-to-last layer or so), and give them to your favorite survival method. In general this is much faster and simpler than training your own thing, so might be worth testing that out anyways

zapaishchykova commented 1 year ago

Hi @havakv, is there an intuition behind when to use these two options:

havakv commented 1 year ago

@zapaishchykova I don't think I'm an authority on this. This is something that is relevant in pretty much every neural net application and really not specific to survival analysis. But my guess would be that using features from a pre-trained model + a survival model would require less data than fine-tuning an CoxPh with a pretrained CNN inside. So maybe that's a rule of thumb?

zapaishchykova commented 1 year ago

@havakv that is super insightful Thanks!