-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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-package] Add function to generate a list of parameters #4195
Comments
Thanks very much for the recommendation! I'm strongly opposed to removing the interface of passing parameters as a list to However, I'm open to more discussion on the idea of a function which can make the process of setting parameters easier. So far we've been hesitant to take that on because it introduces some maintenance burden and because copying the details of the LightGBM core library into wrapper packages introduces a risk of inconsistencies (like the one you've already noted in #4196). Some questions about such a function:
|
But it doesn't need to be a breaking change. What I suggest would be simply to make a function with documented arguments that would return a list with the same elements and values - e.g. Parameters <- function(arg1=10, arg2="a") {
return(as.list(environment()))
} But with those arguments documented and already set to their defaults (or perhaps to NULL, guess the effect is the same), so that it would play along with RStudio and other IDEs documentation browser, tooltips, and autocomplete. I think it should be possible to auto-generate such a file from the html or the documentation system of the C++ library, maybe adding a note that it's autogenerated. And yes, would be nice if the R package documentation would mention everything that's possible to pass. |
Right, but the other proposal in #4195 (comment), "The functions accepter their arguments without needing to pass them as a list", would be a breaking change.
I'm open to the idea of a function like
|
I'll pass on making a parser from the html, but can provide you some example libraries which have a parameters constructor:
Although those are all R exclusives and the functions are not auto-generated. |
Alright, thanks. Since you're not interested in contributing this, I'll add it to this project's backlog of feature requests. In this project, we manage feature requests in a single issue (see #2302). I'll move this there, close this issue, and update the title to more accurately reflect the feature request. Feature descriptionFor anyone arriving at this issue, please comment if you'd like to contribute this feature. It can be summarized as follows. Add a new exported function,
Since the goal of this function would be primarily to support interactive use, it does not need to support aliases for parameters (e.g. If possible, this function and its documentation should be automatically generated from https://github.com/microsoft/LightGBM/blob/7ea2bc4dbca53c03eaae2aa2b22f9b30447caea4/include/LightGBM/config.h. You can see https://github.com/microsoft/LightGBM/blob/7ea2bc4dbca53c03eaae2aa2b22f9b30447caea4/helpers/parameter_generator.py for inspiration. At a minimum, to ensure that this function remains consistent with LightGBM's core library, tests should be added which will break if any inconsistencies are detected (similar to Lines 50 to 51 in 7ea2bc4
|
In the R package, when one wants to fit a model, the functions have an argument
params
, where one passes an R list.This is inconvenient and makes it hard to find the right parameter names. Would be better if either:
lgb.Params
which would simply be a constructor wrapper returning a list of the parameters but with documented arguments, so that one could get autocomplete and pop-up documentation in IDEs by doing something like this:The text was updated successfully, but these errors were encountered: