You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
I'm having trouble with using tune_bayes() in my pipeline. I realized it also fails with the example found in the docs https://www.tidymodels.org/learn/work/bayes-opt/, with the exact same error.
Reproducible example
library(tidymodels)
#> ── Attaching packages ───────────────────────────────────────────── tidymodels 0.1.1 ──#> ✓ broom 0.7.0 ✓ recipes 0.1.13#> ✓ dials 0.0.8 ✓ rsample 0.0.7 #> ✓ dplyr 1.0.1 ✓ tibble 3.0.3 #> ✓ ggplot2 3.3.2 ✓ tidyr 1.1.1 #> ✓ infer 0.5.3 ✓ tune 0.1.1 #> ✓ modeldata 0.0.2 ✓ workflows 0.1.3 #> ✓ parsnip 0.1.3 ✓ yardstick 0.0.7 #> ✓ purrr 0.3.4#> ── Conflicts ──────────────────────────────────────────────── tidymodels_conflicts() ──#> x purrr::discard() masks scales::discard()#> x dplyr::filter() masks stats::filter()#> x dplyr::lag() masks stats::lag()#> x recipes::step() masks stats::step()
library(modeldata)
# Load data
data(cells)
set.seed(2369)
tr_te_split<- initial_split(cells %>% select(-case), prop=3/4)
cell_train<- training(tr_te_split)
cell_test<- testing(tr_te_split)
set.seed(1697)
folds<- vfold_cv(cell_train, v=10)
library(themis)
#> Registered S3 methods overwritten by 'themis':#> method from #> bake.step_downsample recipes#> bake.step_upsample recipes#> prep.step_downsample recipes#> prep.step_upsample recipes#> tidy.step_downsample recipes#> tidy.step_upsample recipes#> #> Attaching package: 'themis'#> The following objects are masked from 'package:recipes':#> #> step_downsample, step_upsample, tunable.step_downsample,#> tunable.step_upsamplecell_pre_proc<-
recipe(class~., data=cell_train) %>%
step_YeoJohnson(all_predictors()) %>%
step_normalize(all_predictors()) %>%
step_pca(all_predictors(), num_comp= tune()) %>%
step_downsample(class)
svm_mod<-
svm_rbf(mode="classification", cost= tune(), rbf_sigma= tune()) %>%
set_engine("kernlab")
svm_wflow<-
workflow() %>%
add_model(svm_mod) %>%
add_recipe(cell_pre_proc)
svm_set<- parameters(svm_wflow)
svm_set#> Collection of 3 parameters for tuning#> #> id parameter type object class#> cost cost nparam[+]#> rbf_sigma rbf_sigma nparam[+]#> num_comp num_comp nparam[+]svm_set<-svm_set %>%
update(num_comp= num_comp(c(0L, 20L)))
set.seed(12)
search_res<-svm_wflow %>%
tune_bayes(
resamples=folds,
# To use non-default parameter rangesparam_info=svm_set,
# Generate five at semi-random to startinitial=1,
iter=50,
# How to measure performance?metrics= metric_set(roc_auc),
control= control_bayes(no_improve=30, verbose=TRUE)
)
#> #> > Generating a set of 1 initial parameter results#> ✓ Initialization complete#> #> Optimizing roc_auc using the expected improvement#> #> ── Iteration 1 ────────────────────────────────────────────────────────────────────────#> #> i Current best: roc_auc=0.8678 (@iter 0)#> i Gaussian process model#> ! Gaussian process model: X should be in range (0, 1), data length exceeds...#> x Gaussian process model: Error in GP_deviance(beta = row, X = X, Y = Y, n...#> ! An error occurred when creating candidates parameters: Error in GP_deviance(beta = row, X = X, Y = Y, nug_thres = nug_thres, : #> Infinite values of the Deviance Function, #> unable to find optimum parameters#> x Skipping to next iteration#> Error in eval(expr, p): no loop for break/next, jumping to top level#> x Optimization stopped prematurely; returning current results.
You can't fit a model to one data point (not without getting infinite solutions). I try to make the initial set a minimum of the number of parameters + 1.
Yes that works :) it was not obvious at the time, but now it makes sense of course. I had a wrong understand of the system. Maybe it should have an if guard-rail for distracted people like me?
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
The problem
I'm having trouble with using
tune_bayes()
in my pipeline. I realized it also fails with the example found in the docs https://www.tidymodels.org/learn/work/bayes-opt/, with the exact same error.Reproducible example
Created on 2020-08-30 by the reprex package (v0.3.0)
Session info
Setting
initial
argument to> 1
fixes this issue.The text was updated successfully, but these errors were encountered: