mllg / batchtools

Tools for computation on batch systems
https://mllg.github.io/batchtools/
GNU Lesser General Public License v3.0
172 stars 51 forks source link

Number of problems and algorithms not correct #170

Closed ghost closed 6 years ago

ghost commented 6 years ago

When using the example for an "ExperimentRegistry" from the package vignette, the number of problems and algorithms is not correctly displayed when printing the registry object:

library(batchtools)
reg = makeExperimentRegistry(file.dir = NA, seed = 1)
subsample = function(data, job, ratio, ...) {
  n = nrow(data)
  train = sample(n, floor(n * ratio))
  test = setdiff(seq_len(n), train)
  list(test = test, train = train)
}
data("iris", package = "datasets")
addProblem(name = "iris", data = iris, fun = subsample, seed = 42)
svm.wrapper = function(data, job, instance, ...) {
  library("e1071")
  mod = svm(Species ~ ., data = data[instance$train, ], ...)
  pred = predict(mod, newdata = data[instance$test, ], type = "class")
  table(data$Species[instance$test], pred)
}
addAlgorithm(name = "svm", fun = svm.wrapper)
reg

returns:

Experiment Registry
  Backend   : Interactive
  File dir  : C:/...
  Work dir  : C:/...
  Jobs      : 0
  Problems  : 0
  Algorithms: 0
  Seed      : 1
  Writeable : TRUE

However, there is one problem and one algorithm defined, as can be checked by:

reg$problems
reg$algorithms

Did I miss something or is this just a bug?

mllg commented 6 years ago

This was a bug, thanks for reporting. Fixed now.