Can somebody explain why I can't pass a NULL variable into a boost_tree()
?
library(tidyverse)
library(tidymodels)
library(xgboost)
set.seed(123)
#Load data
df <- as_tibble(iris)
# Split data
split <- initial_split(df, strata = Species)
train <- training(split)
test <- testing(split)
folds <- vfold_cv(train)
depth <- NULL # Defining an integer works fine
is.null(depth)
#Model
xg_model <-
boost_tree(
trees = 1000,
tree_depth = depth # Directly passing in NULL works fine
) %>%
set_engine("xgboost") %>%
set_mode("classification")
#Recipe
xg_recipe <-
recipe(Species ~., data=split)
#Workflow
xg_workflow <-
workflow() %>%
add_recipe(xg_recipe) %>%
add_model(xg_model)
#Fit
xg_fit <-
xg_workflow %>%
last_fit(split)
xg_fit_rs <-
xg_workflow %>%
fit_resamples(folds)
accuracy_xg <- xg_fit_rs %>% collect_metrics()
accuracy_xg
[1] TRUE
x train/test split: preprocessor 1/1, model 1/1: Error in xgb.iter.update(bst$handle, dtrain, iteration - 1, obj): Invalid Parameter format for max_de...