Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Survival AFT analysis using xgb.cv #7118

Closed
mikecyterski opened this issue Jul 21, 2021 · 3 comments · Fixed by #10031
Closed

Survival AFT analysis using xgb.cv #7118

mikecyterski opened this issue Jul 21, 2021 · 3 comments · Fixed by #10031
Labels
cross-validation Issues related to cross validation implementation in XGBoost. feature-request

Comments

@mikecyterski
Copy link

Hello folks. Has anyone used Survival Analysis with AFT using xgb.cv in R? I see examples online using xgb.train, where you can set lower and upper limits on the label (response variable) within the xgb.DMatrix, but I keep getting errors in my code when trying to do this with xgb.cv. I set the lower and upper label bounds in this fashion:

y_lower_bound -> dataset[,1]
y_upper_bound -> dataset[,2]
setinfo(covar_train, 'label_lower_bound', y_lower_bound)
setinfo(covar_train, 'label_upper_bound', y_upper_bound)

But when I make the call to xgb.cv, I get an error about the label:

Error in xgb.cv(params = params, covar_train, early_stopping_rounds = 10, :
Labels must be provided for CV either through xgb.DMatrix, or through 'label=' when 'data' is matrix

covar_train is my DMatrix of model covariates. If I "getinfo" about the label of covar_train, it comes back "NULL", which isn't surprising, because I haven't set it, but how to indicate to xgb.cv to use the upper and lower label bounds in conjunction with the 'survival:aft' objective function and the 'aft-nloglik' evaluation metric? I've run very similar code using xgb.train, and that seems to work fine.

If anyone can share code that implements the Survival AFT model using xgb.cv, that'd be much appreciated!

@trivialfis
Copy link
Member

cc @hcho3

@mayer79
Copy link
Contributor

mayer79 commented Jul 23, 2021

I once had the same problem. IMHO, xgb.cv does not deal with label_lower_bound and label_upper_bound. My solution was to do the cross-validation without xgb.cv.

@mikecyterski
Copy link
Author

Thanks MM. Someone else recommended writing my own cross-validation routine but I was waiting to see if there was an easier solution. Would you mind sharing your code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-validation Issues related to cross validation implementation in XGBoost. feature-request
Projects
Status: 2.0 Done
3 participants