mlr-org/mlrMBO

n=4 getting error from proposePoints

dipenpatel235 opened this issue · 5 comments

look below code and see variable n=4 in des <- generateDesign(n = 4, par.set = ps) line.
so according current parameter set when n=4 then getting error on print(prop)
so if i wull change n=4 to n=5 then getting success response.

library(rpart)
library(rjson)
library(mlrMBO)
library(synchronicity)

ps <- makeParamSet(
  makeIntegerParam("R_FLAGS_MY_UNITS1", lower = 10, upper = 100),
  makeIntegerParam("R_FLAGS_MY_UNITS2", lower = 10, upper = 100),
  makeIntegerParam("R_FLAGS_MY_UNITS3", lower = 1, upper = 10),
  makeNumericParam("R_FLAGS_DROPOUT1", lower = 0.1, upper = 1.1),
  makeNumericParam("R_FLAGS_DROPOUT2", lower = 0.1, upper = 1.1),
  makeNumericParam("R_FLAGS_DROPOUT3", lower = 0.1, upper = 1.1),
  makeDiscreteParam("R_FLAGS_MY_BATCHSIZE", values = c('16', '32', '64')),
  makeNumericParam("R_FLAGS_MY_LR", lower = 0.1, upper = 1.1)
)

des <- generateDesign(n = 4, par.set = ps)

des$y <- 9999

ctrl <-  makeMBOControl(output.num.format = "%.7g")

ctrl <- setMBOControlInfill(ctrl, crit = crit.ei)

opt.state <- initSMBO(
  par.set = ps,
  design = des,
  control = ctrl,
  minimize = TRUE,
  noisy = FALSE)

#mutex
m = boost.mutex()

  lock(m)
  prop <- proposePoints(opt.state)
  unlock(m)
  print(prop)

Are you referring to the warning:

Warning message:
In randomForest.default(x = data[["data"]], y = data[["target"]],  :
  The response has five or fewer unique values.  Are you sure you want to do regression?

Then there is nothing to fix. You can mute warnings if you want.

I see the line:

des$y <- 9999

This will break your tuning because it will always lead to a wrong surrogate.

How can we run without using generateDesign

I cannot feed n=4,6,8 results without knowing the results.

MBO can not generate feasible proposals without a proper initial design.
If you don't know the results of the initial design you have to evaluate them first: e.g.:

xs = dfRowsToList(des, ps)
y = sapply(xs, fun)

according above warning message it is looks warning but it is crashed the code and stopped working.

Then you have to post a minimal working example that produces this crash. Or at least provide a traceback() or a concrete error message.