I keep getting the following error when attempting to tune an xgboost model for multiclass classification with 7 different classes in tidymodels using the tune_bayes() function:
Error in `estimate_tune_results()`:
! All of the models failed. See the .notes column.
Run `rlang::last_error()` to see where the error occurred.
Warning message:
All models failed. See the `.notes` column.
Code:
set.seed(123)
swing_split <- initial_split(swing_data, strata = outcome)
swing_train <- training(swing_split)
swing_test <- testing(swing_split)
head(swing_train, n = 15)
A tibble: 15 x 7
outcome plate_x plate_z pfx_x pfx_z release_speed stand
<fct> <dbl> <dbl> <dbl> <dbl> <dbl> <fct>
1 foul 0.19 1.89 0.36 -0.31 85.5 R
2 foul -0.16 2.95 -0.73 1.52 92.6 L
3 foul 0.43 2.1 0.99 -1.64 79.6 L
4 foul -0.35 2.74 -0.61 1.51 91.7 R
5 foul -1.09 2.69 -1.2 1.46 93.1 R
6 foul 0.86 2.8 1.09 0.29 79.9 L
7 foul -0.33 2.59 1.22 1.2 95.7 L
8 foul -0.39 2.31 -0.12 -0.46 78.5 R
9 foul 0.17 1.77 1.53 0.59 85.9 R
10 foul 0.17 3.54 -0.54 1.58 96.2 R
11 foul -0.69 3.01 0.96 1.57 94.7 L
12 foul 0.82 1.97 1.07 -0.62 79.7 L
13 foul 0.89 2.87 1.5 0.61 92.3 L
14 foul -0.07 1.5 1.46 0.55 81.8 L
15 foul -0.09 3.63 -0.57 1.37 91.1 L
set.seed(234)
swing_folds <- vfold_cv(swing_train, strata = outcome)
swing_rec <-
recipe(outcome ~ ., data = swing_train) %>%
step_dummy(stand, one_hot = T)
xgb_spec <- boost_tree(
trees = 175,
tree_depth = tune(), min_n = tune(),
loss_reduction = tune(),
sample_size = tune(), mtry = finalize(mtry(), swing_train),
learn_rate = 0.1) %>%
set_engine("xgboost", objective = "multi:softprob", num_class = 7) %>%
set_mode("classification")
swing_wf <- workflow(swing_rec, xgb_spec)
xgb_set <- extract_parameter_set_dials(swing_wf)
doParallel::registerDoParallel()
set.seed(345)
xgb_tune <- swing_wf %>%
tune_bayes(
iter = 25,
resamples = swing_folds,
param_info = xgb_set,
metrics = metric_set(accuracy),
initial = 10,
control = control_bayes(parallel_over = "everything", save_pred = T, verbose = T))
I have looked on the internet and tried a couple of things, but I continue to get that error.