I am using DeepSurv model from R package survivalmodels, which is a wrapper of the equivalent python package. There is L2 regularisation https://github.com/jaredleekatzman/DeepSurv/blob/master/notebooks/DeepSurv%20Example.ipynb in the original package (“L2_reg”), and in pysurvival, https://square.github.io/pysurvival/models/nonlinear_coxph.html (“l2_reg”), but I can not see how to tune this parameter out of R?
Seems that R passes parameters through the “get_pycox_optim” (https://rdrr.io/cran/survivalmodels/man/get_pycox_optim.html), which does not have l2.
I also tried to use “SGD” optimizer with “weight_decay” option, but it does not seem to do much for my data, and it is probably not doing the same as L2_reg in the original package.
library(survivalmodels)
library(survival)
# get GBSG data from survival package
mydata = gbsg
params = c("age","meno", "size", "grade","nodes","pgr", "er","hormon")
mydata =mydata[,c("rfstime", "status", params)]
# train and test
traindata = mydata[1:550, ]
testdata = mydata[-(1:550), ]
# train "deepsurv" model using default hyperparams
dsmodel <-
deepsurv(data = traindata,
time_variable = "rfstime",
status_variable = "status",
epochs = 50)
predicted_r <- 1 - predict(dsmodel, testdata[params], type = "risk")
concordance(Surv(testdata$rfstime, testdata$status) ~ predicted_r)$concordance
# between 0.51 and 0.61 depending on random seed
# trying to change L2_reg
dsmodel2 <-
deepsurv(data = traindata,
time_variable = "rfstime",
status_variable = "status", epochs = 50, frac = 0.2, "L2_reg" = 0.1)
# Error in get_pycox_optim(net = net, ...) : unused argument (L2_reg = 0.1)