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] Add parameters constructor #11072

Merged
merged 6 commits into from
Dec 8, 2024
Merged

Conversation

david-cortes
Copy link
Contributor

ref #9810

This PR adds a utility function to return a list of XGBoost parameters, with docs about all of them copied from the .rst files with slight modifications considering that they are meant exclusively for the R package. I'm not entirely sure whether all of them are applicable though.

The idea behind this constructor function is to offer an IDE-friendly way of creating and discovering XGBoost parameters, with full in-package documentation as is typical in R packages. It should be possible to reuse these same docs later on in xgboost() as needed through @inheritParams, but for now I'm only using this for xgb.train and xgb.cv.

Since this introduces a new function with a somewhat similar name as a completely different method in the package, it also renames that method in the process in order to avoid confusions and IDE miscompletions.

@trivialfis
Copy link
Member

Since this PR concerns the user interface, would be great if we could get some help for review from an R user's perspective @mayer79 @jameslamb

R-package/R/xgb.train.R Outdated Show resolved Hide resolved
@mayer79
Copy link
Contributor

mayer79 commented Dec 8, 2024

Very good idea!

#' - `"reg:absoluteerror"`: Regression with L1 error. When tree model is used, leaf value is refreshed after tree construction. If used in distributed training, the leaf value is calculated as the mean value from all workers, which is not guaranteed to be optimal.
#'
#' Version added: 1.7.0
#' - `"reg:quantileerror"`: Quantile loss, also known as "pinball loss". See later sections for its parameter and [Quantile Regression](https://xgboost.readthedocs.io/en/latest/python/examples/quantile_regression.html#sphx-glr-python-examples-quantile-regression-py) for a worked example.
Copy link
Member

Choose a reason for hiding this comment

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

This is a Python example, do we want to include it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd say python examples are still relevant.

@trivialfis trivialfis merged commit 85ccb8f into dmlc:master Dec 8, 2024
70 of 74 checks passed
@jameslamb
Copy link
Contributor

Since this PR concerns the user interface, would be great if we could get some help for review from an R user's perspective @mayer79 @jameslamb

Thanks for the @, sorry I did not get to it before this was merged.

The idea behind this constructor function is to offer an IDE-friendly way of creating and discovering XGBoost parameters, with full in-package documentation as is typical in R packages

I think it's a great idea, and would definitely be helpful for interactive development.

Some suggestions (to consider in follow-ups, given that this was already merged):

  • it would be good to have explicit unit tests on this new function, not just rely on implicit coverage from other tests. For example:
    • confirming that only non-NULL items show up in the return value
    • confirming that calling this with 0 arguments returns an empty list
  • I understand that existing names with . in them need to be preserved for backwards compatibility, but I'd stop adding new ones (e.g. I'd prefer xgb_params to xgb.params)
  • I'd have asked to change the line wrapping of the roxygen comments instead of ignoring the project's preferred line length with # nolint comments
    • or at least, asked that the linter be allowed to cover the function signature, which it currently cannot because of this placement:

# nolint end

I also would have asked for a little research supporting it being safe to change xgb.parameters to xgb.model.parameters without a deprecation cycle. For example, it looks to me like nothing on CRAN is currently using xgb.parameters (https://github.com/search?q=org%3Acran%20%22xgb.parameters%22&type=code), so I guess it at least won't break anything on CRAN. (I don't recall where the discussion about xgboost2 vs. releasing this as a new version of xgboost ended, disregard this last comment if the plan is to release a new package).

@trivialfis
Copy link
Member

@jameslamb Thank you for the suggestion, I have converted your comment into a new tracking issue #11083

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.

4 participants