You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to train a model using lgb.train() without specifying an objective in the list of params. However, if you try to print the booster it will fail. This is because print.lgb.Booster() checks if obj == "none" which does not play well with NULL.
library(lightgbm)
ds<-lgb.Dataset(
data= as.matrix(mtcars[, -1])
, label=mtcars[, 1]
)
lgb.train(
# Empty paramsparams=list()
, data=ds
, verbose=-1
)
#> Error in `if (obj == "none") ...`:#> ! argument is of length zero#> Show Traceback
The simplest thing is just to handle the possibility of NULL in print.lgb.Booster(), but it could also be addressed in lgb.train() upstream.
Thanks for the report! We'd welcome a PR to fix this.
it could also be addressed in lgb.train() upstream
I'm not sure exactly what you're envisioning, but I would not want to see something like this added in lgb.train:
if (is.null(params$objective)) {
params$objective<-"regression"
}
I'd be opposed to that because it duplicates logic that is already in the core LightGBM C/C++ library. That's already leaked a bit into the R package, e.g. here:
The params object in LightGBM's interface isn't really like "the full state of all configuration"... it should be thought of as "overrides of LightGBM's default configuration".
If you're familiar with REST APIs, the params object is like the body you'd attach with a PATCH request, not the one you'd attached with a POST / PUT request.
So given all that.... if I've understood correctly what you mean by "addressed in lgb.train()", then I think a PR just updating print.lgb.Booster() (and covering print(), show(), and summary() with tests) would be better. You can see the existing tests on those methods for reference:
Description
It is possible to train a model using
lgb.train()
without specifying an objective in the list ofparams
. However, if you try to print the booster it will fail. This is becauseprint.lgb.Booster()
checks ifobj == "none"
which does not play well withNULL
.The simplest thing is just to handle the possibility of
NULL
inprint.lgb.Booster()
, but it could also be addressed inlgb.train()
upstream.LightGBM/R-package/R/lgb.Booster.R
Lines 1236 to 1240 in 6b624fb
Happy to make a PR if you want to go in a specific direction.
The text was updated successfully, but these errors were encountered: