xgboost icon indicating copy to clipboard operation
xgboost copied to clipboard

[R] Fix xgb.cv() for AFT models

Open mayer79 opened this issue 2 years ago • 5 comments

This PR fixes https://github.com/dmlc/xgboost/issues/7118

In order to keep the xgb.cv() API as it is:

  • data must be an xgb.DMatrix object
  • which contains the two infos 'label_lower_bound' and 'label_upper_bound'.

Automatic stratified splitting is deactivated with a warning. @david-cortes this is something we need to keep in mind for multioutput regressions as well.

mayer79 avatar Dec 08 '23 13:12 mayer79

Thanks for looking into this. Left a small comment.

Although I am also thinking: if it constructs a DMatrix directly from data and labels - wouldn't it also require just a few lines to allow such a transformation with bounds as function arguments?

david-cortes avatar Dec 08 '23 15:12 david-cortes

We could add more arguments to xgb.cv(). I was actually thinking in the other direction: let the function work only with xgb.DMatrix input and remove the "label" argument. Why? The current signature of xgb.cv() is very incomplete. For instance there is no "weight" argument.

mayer79 avatar Dec 08 '23 15:12 mayer79

We could add more arguments to xgb.cv(). I was actually thinking in the other direction: let the function work only with xgb.DMatrix input and remove the "label" argument. Why? The current signature of xgb.cv() is very incomplete. For instance there is no "weight" argument.

Yes, that makes sense too - then we wouldn't need to update things in two places if new parameters come out.

david-cortes avatar Dec 08 '23 17:12 david-cortes

cc @hcho3 for aft.

trivialfis avatar Dec 08 '23 19:12 trivialfis

There's now a function xgb.DMatrix.hasinfo which could be used here to check whether the DMatrix has a given field without involving data copies: https://github.com/dmlc/xgboost/blob/ff3d82c006083c01f7e1d9796564d32844ea952c/R-package/R/xgb.DMatrix.R#L223

david-cortes avatar Dec 18 '23 15:12 david-cortes

Closed in favour of #10031

mayer79 avatar Mar 31 '24 08:03 mayer79