Today in the R package, there are a lot of internal function calls which use only positional arguments. Change them to use keyword arguments for extra safety.
I've added this issue to provide a small, focused contribution opportunity for Hacktoberfest 2020 participants. If you are an experienced open source contributor, please leave this for beginners and consider contributing on a different backlog item.
Using positional arguments in internal code is dangerous, because it can allow mistakes to slip through or can lead to confusing errors.
This is especially dangerous for cases where the values you'd pass to two parameters take on similar values. For example, in lightgbm(), eval_freq and early_stopping_rounds are both positive integers and can take on similar values. You might not known, unless you're very careful, that you accidentally specified them in the wrong order.
To help with this issue, propose a pull request which replaces uses of positional arguments in the R package with keyword arguments.
That means changing calls like this:
# before
folds <- generate.cv.folds(
nfold
, nrow(data)
, stratified
, getinfo(data, "label")
, getinfo(data, "group")
, params
)
# after
folds <- generate.cv.folds(
nfold = nfold
, nrows = nrow(data)
, stratified = stratified
, label = getinfo(data, "label")
, group = getinfo(data, "group")
, params = params
)
R-package/R/{roxygen2} 7.1.1 installed. If you have any issues with this, just ask when you submit your PR and I can regenerate the docs for youshell
sh build-cran-package.sh
R CMD INSTALL --with-keep.source lightgbm_3.*.tar.gz
cd R-package
Rscript -e "roxygen2::roxygenize(load = 'installed')"
lgb.call()print(), length(), is.character(), etc.)r
result <- some_function(
arg1 = TRUE
, arg2 = 4
, arg3 = "hello"
, ...
)
Refer to #3391 as an example. If you have any questions, tag me on this issue and I can help.
If you are interested, please comment on this issue and indicate which file in R-package/R/ you'd like to help on. PLEASE ONLY TAKE ONE FILE, so that multiple people can use this as a learning experience.
This issue is not urgent, so you can claim a file now and not contribute until Hacktoberfest begins on October 1st.
The list below tracks the assignments and completions so far.
Thanks for contributing to LightGBM!
can I claim callback.R please?
Hi @jameslamb , I'm working on lgb.train.R. Thanks!
thanks @iadi7ya ! I appreciate you taking the time to contribute to {lightgbm}!
@jameslamb I am working on lgb.Predictor.R
can i claim lgb.Booster.R?
can i claim lgb.Booster.R?
yes please!