简体   繁体   中英

Error related to labels when tuning catboost in tidymodels

Here is the model:

cb_spec <- boost_tree(
  mode = "classification",
  trees = 1000,
  tree_depth = tune(),
  min_n = tune(),
  mtry = tune(),
  learn_rate = tune()
) %>%
  set_engine("catboost", loss_function = "Logloss", task_type = "GPU")

Here is the recipe:

cb_rec <- recipe(covid_vaccination ~ ., data = cb_train) %>% 
  step_unknown(all_nominal_predictors()) %>%
  #step_dummy(all_nominal_predictors(), one_hot = TRUE) %>%
  step_impute_median(all_numeric_predictors()) %>% 
  step_nzv(all_predictors())

I combine them:

cb_wf <- workflow() %>% 
  add_model(cb_spec) %>% 
  add_recipe(cb_rec)

Then I try to tune to find optimal hyperparameters:

cb_tune <- tune_grid(
  object = cb_wf,
  resamples = cb_folds,
  grid = cb_grid,
  metrics = metric_set(roc_auc),
  control = control_grid(verbose = TRUE)
)

Here is the error I get:

Error in catboost.from_matrix(as.matrix(float_and_cat_features_data), : Unsupported label type, expecting double or integer.

I have already confirmed that categorical variables are changed to factors. There are absolutely no character type vectors in my dataset.

https://github.com/catboost/catboost/issues/1874

Solved thanks to someone awesome who made their own fork of treesnip as a workaround: Mikhail Rudakov

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM