I'm going through the tfhub-recipes example here. However, after running the basic example, I tried to add in hyperparamter tuning and got the error
internal: Error: Only strings can be converted to symbols
Does anyone know why that might happen when adding in a workflow and hyperparameter tuning?
library(tfhub)
library(tidyverse)
library(tidymodels)
library(here)
#> here() starts at C:/Users/ChadPeltier/AppData/Local/Temp/RtmpcXVvsD/reprex59f4226d175a
library(furrr)
#> Loading required package: future
comments <- read_csv("https://github.com/cgpeltier/non_defense_projects/raw/master/comments_sample.csv")
#>
#> -- Column specification --------------------------------------------------------
#> cols(
#> obscene = col_double(),
#> comment_text = col_character()
#> )
comments_split <- initial_split(comments, strata = obscene)
comments_train <- training(comments_split)
comments_test <- testing(comments_split)
comments_folds <- vfold_cv(comments_train, strata = obscene)
ctrl_grid <- stacks::control_stack_grid()
rec <- recipe(obscene ~ comment_text, data = comments_train) %>%
step_pretrained_text_embedding(comment_text, handle = "https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim-with-oov/1") %>%
step_bin2factor(obscene)
glmnet_spec <- logistic_reg(penalty = tune(), mixture = tune()) %>%
set_mode("classification") %>%
set_engine("glmnet")
glmnet_workflow <- workflow() %>%
add_recipe(rec) %>%
add_model(glmnet_spec)
glmnet_grid <- crossing(penalty = 10^seq(-6, -1, length.out = 20),
mixture = c(0.05, 0.2, 0.4, 0.6, 0.8, 1))
n_cores <- availableCores() - 1
plan(multiprocess, workers = n_cores)
glmnet_tune <- tune_grid(glmnet_workflow,
resamples = comments_folds,
control = control_grid(save_pred = TRUE),
grid = glmnet_grid)
#> x Fold01: internal: Error: Only strings can be converted to symbols
#> x Fold02: internal: Error: Only strings can be converted to symbols
#> x Fold03: internal: Error: Only strings can be converted to symbols
#> x Fold04: internal: Error: Only strings can be converted to symbols
#> x Fold05: internal: Error: Only strings can be converted to symbols
#> x Fold06: internal: Error: Only strings can be converted to symbols
#> x Fold07: internal: Error: Only strings can be converted to symbols
#> x Fold08: internal: Error: Only strings can be converted to symbols
#> x Fold09: internal: Error: Only strings can be converted to symbols
#> x Fold10: internal: Error: Only strings can be converted to symbols
#> Warning: All models failed. See the `.notes` column.
future:::ClusterRegistry("stop")
Created on 2021-04-01 by the reprex package (v1.0.0)