1

I'm using the mlr3 to build a machine learning workflow using SVM classfier. When I try to tune the parameter

library(mlr3)
library(mlr3learners)
library(paradox)
library(mlr3tuning)


task = tsk("pima")
learner = lrn("classif.svm")
learner$param_set
tune_ps = ParamSet$new(list(
  ParamDbl$new("cost", lower = 0.001, upper = 0.1)
))

tune_ps
hout = rsmp("holdout")
measure = msr("classif.ce")
evals20 = term("evals", n_evals = 20)
instance = TuningInstance$new(
  task = task,
  learner = learner,
  resampling = hout,
  measures = measure,
  param_set = tune_ps,
  terminator = evals20
)

tuner = tnr("grid_search", resolution = 10)
result<-tuner$tune(instance)

It outputs the error

Error in (function (xs) : Assertion on 'xs' failed: Condition for 'cost' not ok: type equal C-classification; instead: type=

I can't figure out what is happening there.

UseR10085
  • 7,120
  • 3
  • 24
  • 54
Jiahao-AI
  • 39
  • 4
  • Can you try adding `learner$param_set$values$type = "C-classification"` after constructing the svm – RaphaelS Jan 08 '20 at 20:42
  • Please do not double-tag. I removed the `mlr` tag the second time now. In addition, this looks like a bug? `C-classification` is the default for the param_set and should be used as a fixed setting during tuning? I'll inspect. – pat-s Jan 08 '20 at 21:07
  • 2
    This is a bug, see the issue upstream: https://github.com/mlr-org/paradox/issues/259 – pat-s Jan 08 '20 at 23:46

1 Answers1

1

We decided to solve this with a more descriptive error message but still requiring to set parameters with dependencies explicitly in the ParamSet rather than falling back to ParamSet defaults.

See https://github.com/mlr-org/paradox/pull/262 and related issues/PRs for more information.

pat-s
  • 5,992
  • 1
  • 32
  • 60