roptimizationmlr

mlrMBO Error in validObject(model, complete = TRUE)


I'm trying to recreate the example from here using my data, but I'm getting an error

x <- structure(list(`1` = c(0L, 0L, 0L, 0L, 0L),
                    `2` = c(0L, 0L, 0L,  0L, 0L), 
                    `3` = c(1L, 0L, 0L, 0L, 0L), 
                    `4` = c(0L, 0L, 0L, 0L, 0L),
                    `5` = c(0L, 0L, 0L, 0L, 0L), 
                    `6` = c(0L, 0L, 0L, 0L, 0L), 
                    `7` = c(1L, 0L, 0L, 0L, 0L),
                    `8` = c(1L, 1L, 0L, 0L, 1L), 
                    `9` = c(0L, 0L, 0L, 0L, 0L), 
                    `10` = c(1L, 1L, 1L, 0L, 0L), 
                    `11` = c(0L, 0L, 0L, 0L, 0L), 
                    `12` = c(1L, 1L, 1L, 0L, 0L), 
                    `13` = c(0L, 1L, 0L, 0L, 1L), 
                    `14` = c(0L, 1L, 0L, 0L,  0L), 
                    `15` = c(0L, 1L, 1L, 0L, 0L), 
                    `16` = c(0L, 0L, 0L, 0L, 0L), 
                    `17` = c(1L, 1L, 0L, 0L, 0L), 
                    `18` = c(1L, 1L, 0L, 1L, 0L), 
                    y = c(75, 62.5, 50, 75, 62.5)), 
               class = "data.frame", row.names = c(NA,-5L))

clnm <- head(colnames(x), -1)

library(mlrMBO)

ps = makeParamSet(
  params = lapply(clnm, function(name) 
           makeIntegerParam(name, lower = 0, upper = 1)))


ctrl = makeMBOControl()
ctrl = setMBOControlInfill(ctrl, crit = crit.ei)

opt.state = initSMBO(par.set = ps, design = x, 
                     control = ctrl, minimize = FALSE, noisy = FALSE)

I would like get a new solution, but I get an error

proposePoints(opt.state)

Error in validObject(model, complete = TRUE) : 
  invalid class “km” object: the number of experiments must be larger than the spatial dimension
  [1]: https://mlrmbo.mlr-org.com/articles/supplementary/human_in_the_loop_MBO.html

Please tell me what need to do to make the code work.


Solution

  • The error message tells you what the problem is -- you have 18 dimensions, but only 5 evaluations for the initial design. You can either increase the number of evaluations to more than 18, or change the type of surrogate model (e.g. to a random forest).

    I would recommend the former, as 5 evaluations in an 18-dimensional space don't really tell you anything...

    How to change the surrogate model is documented e.g. at https://mlrmbo.mlr-org.com/articles/supplementary/mixed_space_optimization.html. In your case, this might look something like

    surr.rf = makeLearner("regr.randomForest", predict.type = "se")
    ...
    opt.state = initSMBO(par.set = ps, design = x, learner = surr.rf,
                         control = ctrl, minimize = FALSE, noisy = FALSE)