-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
[R] Check invalid input for the cv function. #11264
Conversation
I didn't notice there was such a parameter in Python. Better to rename it straight away - there hasn't been any release with that function argument yet so no harm in modifying it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment: the error messages are using either single quotes or no quotes at all to refer to function names. There's no special visual rendering applied to backticks in error messages.
R-package/R/callbacks.R
Outdated
@@ -647,6 +649,9 @@ xgb.cb.early.stop <- function( | |||
if (inherits(model, "xgb.Booster") && !length(evals)) { | |||
stop("For early stopping, 'evals' must have at least one element") | |||
} | |||
if (!inherits(model, "xgb.Booster") && keep_all_iter) { | |||
stop("`keep_all_iter` must be set to FALSE for cv.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stop("`keep_all_iter` must be set to FALSE for cv.") | |
stop("'keep_all_iter' must be set to FALSE when using early stopping in 'xgb.cv'.") |
R-package/R/xgb.cv.R
Outdated
if (inherits(data, "xgb.DMatrix") && .Call(XGCheckNullPtr_R, data)) { | ||
stop("'data' is an invalid 'xgb.DMatrix' object. Must be constructed again.") | ||
} | ||
if (inherits(data, "xgb.QuantileDMatrix")) { | ||
stop("`xgb.QuantileDMatrix` is not yet supported for the cv function.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stop("`xgb.QuantileDMatrix` is not yet supported for the cv function.") | |
stop("'xgb.QuantileDMatrix' is not supported as input to 'xgb.cv'.") |
Thank you for the quick review. I have renamed the parameter, and corrected the quotes. |
python-package/xgboost/callback.py
Outdated
Whether training should return the best model or the last model. If set to | ||
`True`, it will only keep the boosting rounds up to the detected best iteration, | ||
discarding the ones that come after. This is only supported with tree | ||
methods. Also, the `cv` function doesn't return a model, the parameter is not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one could also mention the 'gblinear' part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Followup: #11255
Note: the
save_best
in Python is implemented in R with thekeep_all_iter
parameter. Not sure if this is intended.