| Xsurv.cv | R Documentation | 
This function can use cv to automatically tuning the paramter to fit the survival model for xgboost and lightgbm.
Xsurv.cv(
  datax,
  datay,
  top_n = NULL,
  option = c("defaut", "xgb", "lgb", "gbm", "rf"),
  method = c("defaut", "pl", "C"),
  search = c("rd", "grid"),
  nfolds = 5,
  cvfrac = 0.8,
  rdtime = 10,
  nround = NULL,
  Lambda = NULL,
  Alpha = NULL,
  Eta = NULL,
  early_stopping_rounds = NULL,
  cp = NULL,
  maxdpth = NULL
)
datax | 
 X data set  | 
datay | 
 Y data set including time and event status  | 
top_n | 
 number of top features for survival tree fitting  | 
option | 
 model fitting option,defaut is xgb  | 
method | 
 fitting metohd,defaut is 'pl' means using loss function:coxph likelihood  | 
nfolds | 
 number of folds for crossvalidation  | 
early_stopping_rounds | 
 force a stopping round  | 
number | 
 of rounds  | 
lambda | 
 l1 penalty parameter  | 
alpha | 
 l2 penalty parameter  | 
eta | 
 learning rate  | 
a list object containing:model,cindex,tree,SHAP and risk
#example library(survival) library(Xsurv) data(lung) mydata<-(lung[,-1]) mydata[,2]<-mydata[,2]-1 length(mydata[,1]) names(mydata)<-colnames(mydata) datay_train<-mydata[1:180,c(1,2)] datax_train<-mydata[1:180,-c(1,2)] datay_test<-mydata[181:228,c(1,2)] datax_test<-mydata[181:228,-c(1,2)] xs<-Xsurv(datax_train,datay_train,top_n = 5,cp=0.01) #xs<-Xsurv.cv(datax_train,datay_train,top_n=5) xm<-xs$model xtree<-xs$tree x_ctree<-xtree$tree2 #plot(x_ctree) shap=xs$SHAP shap risk=xs$risk fit=risk$fit #plot(fit) #prediction pre_time<-pre<-Xsurv_predict(xm,datax_train,datay_train,datax_test) #predict survival probabilty pre_x<-Xsurv_predict_sv(xm,datax_train,datay_train,datax_test[1,]) plot(pre_x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.