havakv / pycox

Survival analysis with PyTorch
BSD 2-Clause "Simplified" License
803 stars 188 forks source link

Difference between Cox-PH and DeepSurv #98

Closed lintumk closed 3 years ago

lintumk commented 3 years ago

Hi, In the example codes I see a single code for both Cox-PH and DeepSurv. I want to fit both the models for my data. How can I get both Classical Cox(linear) and DeepSur ?

havakv commented 3 years ago

Hi, CoxPH is just a method for fitting Cox proportional hazards models with pytorch. If you use a neural network, you get DeepSurv and if us use a linear model (neural network with only one layer an no non-linear transforms) you get the classical Cox Regression.

To get a linear model, I think you can just use

net  = torch.nn.Linear(num_features, 1)
model = CoxPH(net, some_optimizer)

Does this answer your question?

lintumk commented 3 years ago

Yes, Perfect! Thanks for this wonderful package and your timely reply.