-
Notifications
You must be signed in to change notification settings - Fork 7
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
properly resolve obj
alias objective
#66
Comments
Thanks for the issue. Training for a multi-class task with early stopping indeed works fine: library(bonsai)
#> Loading required package: parsnip
library(modeldata)
data(penguins)
lgb_model <-
boost_tree("classification", stop_iter = 1000) %>%
set_engine("lightgbm", validation = 0.2, eval = 'auc_mu')
fit(
lgb_model,
formula = species ~ flipper_length_mm + island,
data = penguins
)
#> parsnip model object
#>
#> <lgb.Booster>
#> Public:
#> add_valid: function (data, name)
#> best_iter: 14
#> best_score: 0.973090277777778
#> current_iter: function ()
#> dump_model: function (num_iteration = NULL, feature_importance_type = 0L)
#> eval: function (data, name, feval = NULL)
#> eval_train: function (feval = NULL)
#> eval_valid: function (feval = NULL)
#> finalize: function ()
#> initialize: function (params = list(), train_set = NULL, modelfile = NULL,
#> lower_bound: function ()
#> params: list
#> predict: function (data, start_iteration = NULL, num_iteration = NULL,
#> raw: NA
#> record_evals: list
#> reset_parameter: function (params, ...)
#> rollback_one_iter: function ()
#> save: function ()
#> save_model: function (filename, num_iteration = NULL, feature_importance_type = 0L)
#> save_model_to_string: function (num_iteration = NULL, feature_importance_type = 0L)
#> set_train_data_name: function (name)
#> to_predictor: function ()
#> update: function (train_set = NULL, fobj = NULL)
#> upper_bound: function ()
#> Private:
#> eval_names: auc_mu
#> get_eval_info: function ()
#> handle: lgb.Booster.handle
#> higher_better_inner_eval: TRUE
#> init_predictor: NULL
#> inner_eval: function (data_name, data_idx, feval = NULL)
#> inner_predict: function (idx)
#> is_predicted_cur_iter: list
#> name_train_set: training
#> name_valid_sets: list
#> num_class: 3
#> num_dataset: 2
#> predict_buffer: list
#> set_objective_to_none: FALSE
#> train_set: lgb.Dataset, R6
#> train_set_version: 1
#> valid_sets: list Created on 2023-04-24 with reprex v2.0.2 bonsai handles setting the library(bonsai)
#> Loading required package: parsnip
library(modeldata)
data(penguins)
lgb_model <-
boost_tree("classification", stop_iter = 1000) %>%
# note `object = .`, since R partial-matches `obj` to `object`
set_engine(object = ., "lightgbm", obj = "multiclass", validation = 0.2, eval = 'auc_mu')
fit(
lgb_model,
formula = species ~ flipper_length_mm + island,
data = penguins
)
#> Warning: The following argument(s) are guarded by bonsai and will not be passed
#> to `lgb.train`: obj
#> parsnip model object
#> ... [clipped] Created on 2023-04-24 with reprex v2.0.2 but fails to do so when that argument is passed by its alias |
obj
alias objective
Your suggestion worked. I'm getting another error, not sure if it is related, tho.
Then |
See:
No need to pass that argument!👍 |
Error message
Error in init(env): For early stopping, valids must have at least one element
is produced when trying to train a multi-class model withThe text was updated successfully, but these errors were encountered: