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

[R] Check invalid input for the cv function. #11264

Merged
merged 6 commits into from
Feb 20, 2025

Conversation

trivialfis
Copy link
Member

Followup: #11255

Note: the save_best in Python is implemented in R with the keep_all_iter parameter. Not sure if this is intended.

@trivialfis
Copy link
Member Author

cc @david-cortes

@david-cortes
Copy link
Contributor

Note: the save_best in Python is implemented in R with the keep_all_iter parameter. Not sure if this is intended.

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.

Copy link
Contributor

@david-cortes david-cortes left a 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.

@@ -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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'.")

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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
stop("`xgb.QuantileDMatrix` is not yet supported for the cv function.")
stop("'xgb.QuantileDMatrix' is not supported as input to 'xgb.cv'.")

rename.
@trivialfis
Copy link
Member Author

Thank you for the quick review. I have renamed the parameter, and corrected the quotes.

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
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@trivialfis trivialfis merged commit a792cd0 into dmlc:master Feb 20, 2025
59 of 60 checks passed
@trivialfis trivialfis deleted the R-cv-checks branch February 20, 2025 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants