1

I am trying to optimize an SVR model within the mlr3 ecosystem with the kernlab package and I am getting the following error:

The parameter 'C' can only be set if the following condition is met 'type <U+2208> {eps-svr, eps-bsvr}'. Instead the current parameter value is: type=nu-svr.

I find it very weird that cost parameter C cannot be optimized for type 'nu-svr'.

This is a part of my code:

library(mlr3tuning)

learner_ksvm$param_set

search_space = ps(
  C = p_dbl(lower = 0.01, upper = 1),
  type = p_fct(levels = c("eps-svr", "nu-svr")),
  epsilon = p_dbl(lower = 0.01, upper = 1)
)

measure = msr("regr.rmse")

terminator = trm("evals", n_evals = 10)

instance = TuningInstanceSingleCrit$new(
  task = task_train_prerp,
  learner = learner_ksvm,
  resampling = rsmp_cv,
  measure = measure,
  search_space = search_space,
  terminator = terminator
)

tuner = tnr("random_search")

library(progressr)
handlers(global = TRUE)
handlers("rstudio")

tuner$optimize(instance)
desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • I think this actually does end up being a question about statistical modeling, so I've answered [the copy over at stats.SE](https://stats.stackexchange.com/q/545881/232706). – Ben Reiniger Sep 26 '21 at 17:00
  • As answered on stats.SE, this parameter simply doesn't apply for this kernel. – Lars Kotthoff Sep 26 '21 at 18:13
  • 1
    Thanks for your answer on stats.SE. However, your argument is based on SVM for classification. My problem is focused on regression. Thus, from the reference of Schölkop et al, it can be observed that the parameter C does not disappear for nu-SVR. In this sense, in the abstract of this work it is already indicated that the nu parameter replaces epsilon, not the C parameter, as it does for C-SVC. – Eduardo A. Sánchez Torres Sep 27 '21 at 09:55
  • Thanks for that; indeed I was wrong, and it's looking more like a potential software bug. Can you fit the nu-svr without the mlr3 wrap (and without tuning, just setting `C`)? – Ben Reiniger Sep 27 '21 at 14:31
  • @BenReiniger I have fitted the nu-svr model without problems by varying C manually with the kernlab package ('ksvm ()') and also with the e1071 package ('svm ()'). I need to know why C cannot be set for nu-svr within the mlr3 ecosystem. It already returns error from the configuration of the learner object itself. Please help me to find the error. – Eduardo A. Sánchez Torres Sep 30 '21 at 10:40
  • "It already returns error from the configuration of the learner object itself." Could you share that bit of code, and the full error traceback? – Ben Reiniger Sep 30 '21 at 12:41
  • 1
    @BenReiniger I have opened a issue about it [here](https://github.com/mlr-org/mlr3/issues/700) – Eduardo A. Sánchez Torres Sep 30 '21 at 17:41

0 Answers0